110 likes | 261 Views
Turing Graphics. TIK20 May 1, 2007 Ms. Nelson. What Can I Do?. Set up the screen for graphics Draw dots and lines Dot Line; DashedLine; ThickLine Draw empty and filled shapes Box; Oval; Arc; Polygon; MapleLeaf; Star “Flood” an area Clear the screen. Setting up the Screen.
E N D
Turing Graphics TIK20 May 1, 2007 Ms. Nelson
What Can I Do? • Set up the screen for graphics • Draw dots and lines • Dot • Line; DashedLine; ThickLine • Draw empty and filled shapes • Box; Oval; Arc; Polygon; MapleLeaf; Star • “Flood” an area • Clear the screen
Setting up the Screen setscreen(“graphics:640,480, nocursor”) • This tells Turing: • Set up the screen for graphics, not text • Make the screen a standard 640 by 480 size • Don’t show the cursor (which you normally see when you “get” and “put”) • Once you are done drawing… Draw.Cls
Drawing Dots and Lines • Dots have location and colour drawdot (50,50,0) • Draws a black dot at location (50, 50) Lines have beginnings, ends, and colour drawline (200,300,200,200,0) • Draws a black line from (200,300) to (600,200)
Cartesian Plane (640,480) (0,480) (50,50) (0,0) (640,0)
Squares and Circles • Boxes also have ends and beginnings drawbox (40,40,100,100,blue) • BUT… note that (40,40) and (100,100) are the two corners! • Other shapes have a center and radius drawoval (40,40,100,100,blue) • (40,40) is the centre; 100 is the radius
Just for Fun! drawstar (0,0,100,100,yellow) drawmapleleaf (0,0,100,100,red)
Try this setscreen("graphics:640,480,nocursor") var j : int for i : 1 .. maxcolour j:=i*10 drawfilloval(i*10,i*10,10,10,i) end for
Exercises • Draw a ball (drawfilloval) • Make the ball move • Draw balls at different locations • Oops – the old balls stay! • Fix that – draw over in white • Make the ball bounce up when it hits the bottom of the screen