next up previous contents index
Next: Break commands Up: List of primitives Previous: File handling   Contents   Index


Advanced fill function:

Two primitives allow to colour a figure. The primitive fill and fillzone. These primitives allow a shape to be coloured in. These primitives can be compared with the 'fill' feature available in many image-retouching programs. This feature can extend to the margins of the design area. There are two rules that must be adhered to in order to use this primitive correctly:

  1. The pen must be lowered (pd).
  2. The turtle must not be located on a pixel of the colour with which the shape is to be filled. (If you want to colour things red, it can't be sitting on red...)
Let's take a look at an example to see the difference between fill and fillzone:
Figure: At the beginning
\includegraphics[scale=0.2, clip]{pics/remplis.eps}
The pixel under the turtle is white right now. The primitive fill will colour all the neighbouring white pixels with the current pen colour. If for example, you type: setpc 1 fill.
Figure: With the primitive fill
\includegraphics[scale=0.2, clip]{pics/remplis1.eps}
Let's now go back to the first case, if the pen colour of the turtle is black, the primitive fillzone colours all pixels until it encounters the current colour (here black).
Figure: With the primitive fillzone, if you type: setpc 0 fillzone
\includegraphics[scale=0.2, clip]{pics/remplis2.eps}

This is a good example of the use of this primitive:

to halfcirc :c
# draw a half-circle of diameter :c
repeat 180 [fd  :c*tan 0.5 rt 1]
fd :c*tan 0.5
rt 90 fd :c
end

to tan :angle
# renders the tangent of the angle 
output (sin :angle)/cos :angle
end

to rainbow :c
if :c<100 [stop]
halfcirc :c rt 180 fd 20 lt 90
rainbow :c-40
end

to dep
pu rt 90 fd 20 lt 90 pd
end

to arc
ht rainbow 400 pe lt 90 fd 20 bk 120 ppt pu rt 90 fd 20 pd
setpc 0 fill dep 
setpc 1 fill dep
setpc 2 fill dep
setpc 3 fill dep
setpc 4 fill dep
setpc 5 fill dep
setpc 6 fill dep
end

Figure: Arc-in-LOGO
\includegraphics[clip]{pics/arc.eps}


next up previous contents index
Next: Break commands Up: List of primitives Previous: File handling   Contents   Index
Loïc 2008-06-08