Download presentation
Presentation is loading. Please wait.
1
Review Finish program Graphics Programming
Computer Science Review Finish program Graphics Programming
2
Determine the Range of Values the following code generates
Random(9) + 1 Random(12) – 4 Random(25) + 6 2*random(7) + 10 2*random(12) -1 3*random(6) + 4
3
Write the code to generate the following ranges
10 to 22 even 7 to 17 odd 12 to 40 by 4’s Flipping a coin Rolling a pair of 6-sided dice.
4
Program options. Random
Flip a coin 100 times and count how many heads, tails Show how many heads and tails occurred and which occurred most often Roll a pair of dice 100 times and tell which occurred most often, a 3 or an 11. Math tutor User enters how many practice problems Program shows practice addition problems, gets the users guesses and tells the user how many they guessed correctly.
5
Number from 0-... Or some color constants (RED, BLUE, GREEN, …)
1920 1080 (0,0) (1920, 1080) Graphics in Pascal Screen size: 1920x 1080 Might be larger with this version of Pascal. Upside down Cartesian plane Change the screen to graphics mode Use the program graph1.pas from the website. Save it to your Computer Science 1 Folder before running Number from Or some color constants (RED, BLUE, GREEN, …)
6
Open this program, save it to your folder and modify it.
Program Lesson8_Program1; Uses Crt,Graph; Var GraphicsDriver, GraphicsMode, ErrCode: smallint; Begin Writeln('Initialising Graphics, please wait...'); GraphicsDriver := Detect; InitGraph(GraphicsDriver, GraphicsMode,''); ErrCode := GraphResult; If GraphResult <> grOK then ClrScr; Writeln('Graphics error occured: ', GraphErrorMsg(ErrCode)); Halt(1); End; //Enter graphics commands here readln; Closegraph(); End. This is graphy1.pas. Open this program, save it to your folder and modify it. This code must go at the beginning of a program that uses the graphics commands
7
Some Pascal Graphics Commands
Some Commands SetColor(Integervariable); Circle(x, y, radius); ClearViewPort; //Like clearscreen Outtext(x, y, ‘String you will show on the screen’); Line(x1, y1, x2, y2); Lineto(x,y); Putpixel(x, y, ColorValue); Rectangle(x1, y1, x2, y2); Ellipse(x, y, Start Degrees, End Degrees, Horizontal Radius, Vertical Radius); Colorvariable:=getpixel(x, y);
8
What does this do?
9
Today First graphics program Inside circle program:
Face Stick figure House Inside circle program: Input: The (x,y) coordinate and center of a circle. Also the (x2,y2) coordinates of another point Output: Whether or not the point is inside the circle. (Hint: Use the distance formula) Push: In addition, show this graphically Intersecting circles program: Input: x, y and radius for two circles. Output whether or not the circles intersect. Push: Add graphics
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.