Option Base 0
'preamble Option Base 0 CLS Const Gxm=MM.HRes-1,Gym=MM.VRes-1 'screen dimensions follow LCDPANEL settings Dim Integer tx,ty,otx,oty,Gx,Gy,n,p 'Gx and Gy are the current native co-ordinatesDo For p=0 To 320 Colour 0 Move p,0:DrawR 0,240 Shape.New(10) For n=1 To 10 Shape.Vertex(Rnd*Gxm,Rnd*Gym) ' some random scribble Next Colour RGB(White) Shape.Draw(n,n,0) ' 0= the last point isn't connected to the first - a complex line Shape.New(4) ' a 50 pixel square Shape.Vertex(0,0) Shape.Vertex(0,50) Shape.Vertex(50,50) Shape.Vertex(50,0) Colour RGB(Red) For n=1 To 20 ' 20 random squares Shape.Draw(Rnd*(Gxm-50),Rnd*(Gym-50),1) ' 1= the last point is connected to the first, enclosing the area (polygon) NextNextLoop
'Clear the shape stack and pointers in readiness for a new shape. Sub Shape.New(Points As Integer) On Error Skip 2 Erase Sh Dim Integer ShPtr Dim Integer Sh(1,Points-1) '0,n is X, 1,n is Y ShPtr=0 End Sub 'Add a new vertex (corner) to the shape stack 'Care must be taken not to add more vertices than were specified in Shape.New Sub Shape.Vertex(x As Integer,y As Integer) Sh(0,ShPtr)=x:Sh(1,ShPtr)=y ShPtr=ShPtr+1 End Sub 'Draw the shape. If opt is non-zero, the shape is closed by drawing between the first and last vertices to produce a polygon 'The shape stack is preserved and so can be re-used. 'X/Y offset is added to the shape vertices allowing the shape to be drawn in multiple locations with the same data. Sub Shape.Draw(xOffset As Integer,yOffset As Integer,Opt As Integer) Local n As Integer Move xOffset+Sh(0,0),yOffset+Sh(1,0) For n=1 To ShPtr-1 Draw xOffset+Sh(0,n),yOffset+Sh(1,n) Next If Opt Then Draw xOffset+Sh(0,0),yOffset+Sh(1,0) End Sub