! =======================================================================
! PURPOSE: To demonstrate True BASIC's structured drawing capability
! 
! Published in Amazing Computing/Amiga Magazine, September 1992
!
! This program renders a circular pattern of two chess pieces using
! the concept of structured drawing.  The pieces are built up as a
! collection of separate parts, each defined within its own PICTURE
! unit, and connected together in a hierarchical fashion.  To render
! a particular one requires only that you invoke the root PICTURE
! of its image structure.
!
! The pieces are scaled, rotated, and placed in position in the pattern
! using True BASIC's high level structured drawing features.
!
! Also demonstrated in this example is True BASIC's scale-able viewport
! feature.
!
! =======================================================================
LIBRARY "GraphLib*"
SET MODE "LACEHIGH4"

CLEAR
SET CURSOR 5,49
PRINT "Structured Drawing"
SET CURSOR 7,46
PRINT "and Scale-able Viewports"
SET CURSOR 9,51
PRINT "in True BASIC."

OPEN #1: SCREEN 0,.25,.75,1
OPEN #2: SCREEN .1,.45,.55,.9
OPEN #3: SCREEN .225,.725,.25,.75
OPEN #4: SCREEN .4,1,0,.6

FOR W = 1 TO 4
   WINDOW #W
   CALL Render_Image
NEXT W

END

SUB Render_Image
 
   OPTION ANGLE DEGREES 
   SET WINDOW -2, 2, -1.4, 1.4
   CLEAR
   
   CALL Frame
   FOR Angle = 0 TO 360 STEP 90
      DRAW Knight WITH SCALE(.7)*ROTATE(-90+Angle)*SHIFT(COS(Angle),SIN(Angle))    
      DRAW Rook WITH SCALE(.7)*ROTATE(-90+Angle+45)*SHIFT(COS(Angle+45),SIN(Angle+45))
   NEXT Angle
   
   SET COLOR 3
   CALL Ticks(.2,.2)

END SUB


PICTURE Knight 
   DRAW BuildKnight WITH SHIFT(-.3, -.4) 
END PICTURE

PICTURE Rook 
   DRAW BuildRook WITH SHIFT(-.3, -.4) 
END PICTURE

PICTURE BuildKnight 
   DRAW Base 
   DRAW Horse WITH SHIFT(0,.25) 
END PICTURE

PICTURE BuildRook 
   DRAW Base 
   DRAW Body WITH SHIFT(.1,.25) 
   DRAW Castle WITH SHIFT(.05,.6) 
END PICTURE

PICTURE Horse 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        