Hardware Reference
In-Depth Information
he bulk of the code is the same. Where it difers is that drawing is done in a memory area
called segment . When it comes to updating the screen, this segment is drawn four times
on the screen in each quadrant of the screen. Each time it is drawn it is lipped either hori-
zontally or vertically to show mirror symmetry in each quadrant. he variable segSize at
the start of the code makes it easy to deine any size of square window you like for your sys-
tem. he results of a few tests are shown in Figure 15-8.
Figure 15-8:
Some drawings
with four-fold
symmetry.
Over to You
Improvements you could make include a stealth mode in which the drawing point is moved
without leaving a trail or cutting through existing drawings. For that you have to look at the
pixel at the drawing point and redraw the colour over the old grey square. Another thing you
could try is to alter the way the circle is drawn with the set point deining the centre and the
current point the radius. You can have the two modes available on diferent keys.
hat last program had four-fold symmetry. Consider what it would take to produce ive-, six-
or any number fold symmetry. Four-fold is easy because the segments you draw in are
square, and you just used the lip transformation on the segment for each screen quadrant.
However, Pygame has a rotate function that you could apply many times to build up the
screen. he point is that the shape of the segment you want to plot is not rectangular but
triangular. What you would have to do is to draw in a rectangular segment and then mask it
by drawing two triangles on either side of the wanted triangle and illing them with transpar-
ent pixels to get a triangular segment. hen you have to rotate that and ill in the screen. his
is one of those projects that you will not get right the irst time - and serendipity or happy
accident might give you something even more interesting that you were trying to create.
Search WWH ::




Custom Search