turing graphics

11
Turing Graphics Turing Graphics TIK20 TIK20 May 1, 2007 May 1, 2007 Ms. Nelson Ms. Nelson

Upload: romney

Post on 05-Jan-2016

38 views

Category:

Documents


1 download

DESCRIPTION

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. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Turing Graphics

Turing GraphicsTuring Graphics

TIK20TIK20

May 1, 2007May 1, 2007

Ms. NelsonMs. Nelson

Page 2: Turing Graphics

What Can I Do?What Can I Do?

Set up the screen for graphicsSet up the screen for graphics Draw dots and linesDraw dots and lines

DotDot Line; DashedLine; ThickLineLine; DashedLine; ThickLine

Draw empty and filled shapesDraw empty and filled shapes Box; Oval; Arc; Polygon; MapleLeaf; StarBox; Oval; Arc; Polygon; MapleLeaf; Star

““Flood” an areaFlood” an area Clear the screenClear the screen

Page 3: Turing Graphics

Setting up the ScreenSetting up the Screen

setscreen(“graphics:640,480, nocursor”)setscreen(“graphics:640,480, nocursor”)

This tells Turing:This tells Turing: Set up the screen for graphics, not textSet up the screen for graphics, not text Make the screen a standard 640 by 480 sizeMake the screen a standard 640 by 480 size Don’t show the cursor (which you normally see Don’t show the cursor (which you normally see

when you “get” and “put”)when you “get” and “put”)

Once you are done drawing…Once you are done drawing…Draw.ClsDraw.Cls

Page 4: Turing Graphics

Drawing Dots and LinesDrawing Dots and Lines

Dots have Dots have locationlocation and and colourcolourdrawdot (50,50,0)drawdot (50,50,0) Draws a black dot at location (50, 50)Draws a black dot at location (50, 50)

Lines have beginnings, ends, and colourLines have beginnings, ends, and colourdrawline (200,300,200,200,0)drawline (200,300,200,200,0) Draws a black line from (200,300) to Draws a black line from (200,300) to

(600,200)(600,200)

Page 5: Turing Graphics

(0,0)

(640,480)

(50,50)

Cartesian PlaneCartesian Plane

(640,0)

(0,480)

Page 6: Turing Graphics

Colours? Cool!Colours? Cool!

00 blackblack 11 blueblue

22 greengreen 33 cyancyan

44 redred 55 magentamagenta

66 brownbrown 77 whitewhite

88 greygrey 99 brightbluebrightblue

1010 brightgreenbrightgreen 1111 brightcyanbrightcyan

1212 brightredbrightred 1313 brightmagentabrightmagenta

1414 yellowyellow 1515 brightwhitebrightwhite

Page 7: Turing Graphics

Squares and CirclesSquares and Circles

Boxes also have ends and beginningsBoxes also have ends and beginnings

drawbox (40,40,100,100,blue) drawbox (40,40,100,100,blue) BUT… note that (40,40) and (100,100) are BUT… note that (40,40) and (100,100) are

the two corners!the two corners!

Other shapes have a Other shapes have a centercenter and and radiusradius

drawoval (40,40,100,100,blue) drawoval (40,40,100,100,blue) (40,40) is the centre; 100 is the radius(40,40) is the centre; 100 is the radius

Page 8: Turing Graphics

Just for Fun!Just for Fun!

drawstar (0,0,100,100,yellow) drawstar (0,0,100,100,yellow)

drawmapleleaf (0,0,100,100,red)drawmapleleaf (0,0,100,100,red)

Page 9: Turing Graphics

Try thisTry this

setscreen("graphics:640,480,nocursor")setscreen("graphics:640,480,nocursor")

var j : intvar j : int

for i : 1 .. maxcolourfor i : 1 .. maxcolour

j:=i*10j:=i*10

drawfilloval(i*10,i*10,10,10,i)drawfilloval(i*10,i*10,10,10,i)

end forend for

Page 10: Turing Graphics
Page 11: Turing Graphics

ExercisesExercises

1.1. Draw a ball (drawfilloval)Draw a ball (drawfilloval)

2.2. Make the ball moveMake the ball move Draw balls at different locationsDraw balls at different locations

3.3. Oops – the old balls stay!Oops – the old balls stay! Fix that – draw over in whiteFix that – draw over in white

4.4. Make the ball bounce up when it hits Make the ball bounce up when it hits the bottom of the screenthe bottom of the screen