Using GCOLPAT to define custom fill patterns.

This statement allows you to define a custom 8×8 pixel pattern that is used in place of the standard dither patterns when a shape is filled. You must use DIM to allocate 8 bytes of memory to store the pattern then pass the address of the memory to the GCOLPAT statement.

The pattern is anchored to the top-left hand corner of the screen, not the graphics viewport.

Graphics operations that are affected include:

The specified pattern replaces the foreground and background colour in fill operations. However, certain plotting operations that rely on a background or foreground colour (such as the flood-filling boundaries) will continue to use the colour values previously set with GCOL.

GCOLPAT does not copy the pattern data, it merely keeps track of the address you passed it. This means that you can modify the pattern memory between plotting operations without invoking GCOLPAT again.

The image above was created with the following code:

 10 DIM pattern 7
 20 GCOLPAT pattern
 30 pattern?0=&F8
 40 pattern?1=&74
 50 pattern?2=&22
 60 pattern?3=&47
 70 pattern?4=&8F
 80 pattern?5=&17
 90 pattern?6=&22
100 pattern?7=&71
110 CLG
120 pattern?0=&77
130 pattern?1=&89
140 pattern?2=&8F
150 pattern?3=&8F
160 pattern?4=&77
170 pattern?5=&98
180 pattern?6=&F8
190 pattern?7=&F8
200 MOVE 48,32
210 PLOT 153,24,0
220 MOVE 48,32
230 PLOT 145,24,0

Passing FALSE or 0 to GCOLPAT reverts to using the dither pattern set by GCOL. Setting a new foreground or background colour with GCOL will also disable your custom fill pattern.


Associated Keywords