13.07.2015 Views

apple-pascal-1.3-manual

apple-pascal-1.3-manual

apple-pascal-1.3-manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

position in the CORNER variable for use in the main program. The completeprocedure isPROCEDURE MAKETRGL;VAR !:1 .. 3;BEGINPENCOLORCNONE>;FOR 1:=1 TO 3 DO BEGINMOVETOCCENTER.X, CENTER.Y>;DIRECTION[J]:=ARBITRARYC0, 359>;TURNTOCDIRECTIONC!l;MOVECRADIUS>;TRGL[!l.X:=TURTLEX;TRGL[!l.Y:=TURTLEYEND;CORNER.X:=TURTLEX;CORNER.Y:=TURTLEYEND;The ROTATE procedure works very much like the MAKETRGL procedure,but instead of using random angles it uses the angles found in theDIRECTION array -after adding ANGLE to each of them and taking theresult MOD 360. It stores the resulting points in the TRGL array, but doesnot change CORNER. The effect is to replace each point in TRGL with anew point created by rotation through ANGLE degrees. The completeROT ATE procedure isPROCEDURE ROTATECANGLE:INTEGER>;VAR 1:1 .. 3;BEGINPENCOLOR;FOR !:=1 TO 3 DO BEGINMOVETOCCENTER.X, CENTER.Y);DIRECTIONCil:=CD!RECT!ONCIJ+ANGLf) MOD 360;TURNTO CDIRECTION[ll>;MOVE ;TRGLCIJ.X:=TURTLEX;TRGLC!l.Y:=TURTLEYENDEND;Note that the MOD 360 operation is necessary because if the program ranfor a long time, the result of DIRECTION[!]+ ANGLE could eventuallyexceed MAXINT and cause a run-time error.An Annotated Graphics ProgramII-303

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!