One effect of nested patterns is that the specified scale factors or rotations can be cumulative. For example, if one pattern contains a reference to another pattern, and the reference scales the pattern, as shown below:
pattern A is
scale 2:1 pattern B
then pattern A is pattern B at twice the size at which pattern B was defined. If you then specify:
pattern C is
scale 2:1 pattern A
then pattern C is actually pattern B, doubled in size to become pattern A, then doubled in size again to become pattern C.
The following examples illustrate the effects of scaling and rotating patterns. Take particular notice of the position of the pattern's reference point and of any effects of accumulation of the scale and rotate specifications. These examples use the two patterns defined below:
screen size 1200 900
pattern Box is
white shape # Box
boundary
draw 300 0, 0 150
draw arc 90 degrees center by -50 0
draw -250 0, 0 -100
end shape
solid white shape # Door
boundary
draw -10 0, 0 190, -10 0, 0 10, 20 0
end shape
pattern Flag is
solid red shape
boundary
draw 10 0, 0 160, 40 0, 0 40, -50 0
end shape
The first pattern is a mailbox. The second pattern is the red flag seen on mailboxes. The pattern defined below contains a reference to each of these patterns:
pattern Mailbox is
pattern Box
move 100 80
pattern Flag
Mailbox is displayed as shown below. The reference point for the pattern is marked.
The following are illustrations of transformations on these patterns.
scale 2:1 pattern Box
pattern MailArrivedBox is
pattern Box
move 100 80
rotate -90 pattern Flag
The following pattern definitions:
pattern BigBox is
scale 2:1
pattern Mailbox
pattern TippedBox is
rotate 30
pattern BigBox
contain an example of a nested pattern. The first pattern, BigBox, consists of a scaled version of Mailbox. The second pattern, TippedBox, consists of a rotated version of BigBox.
BigBox looks like this:
It is the pattern Mailbox shown at twice its size. When TippedBox is displayed, it is a rotated version of BigBox, as shown below:
If you then define:
pattern SmallBox is
scale 1:2
pattern BigBox
BigBox is Mailbox scaled to twice its size, and SmallBox is BigBox scaled to half its size. Thus, the pattern Mailbox is displayed in the size at which it was initially defined.