Содержание
Слайд 2Graphic window opening and closing procedures
Open_Graph_Window( X_Size, Y_Size )
Close_Graph_Window
Graphic window “size” functions
Get_Max_Width
Graphic window opening and closing procedures
Open_Graph_Window( X_Size, Y_Size )
Close_Graph_Window
Graphic window “size” functions
Get_Max_Width
Get_Max_Height -> returns available screen pixel height
Get_Window_Width -> returns current window pixel width
Get_Window_Height -> returns current window pixel height
Keyboard input procedure
Wait_For_Key
Keyboard input functions
Key_Hit -> returns True / False (whether a key was pressed)
Get_Key -> returns the numeric ASCII value of the pressed key
Get_Key_String -> returns a string value of the pressed key
Drawing procedures
Put_Pixel( X, Y, Color )
Draw_Line( X1, Y1, X2, Y2, Color )
Draw_Box( X1, Y1, X2, Y2, Color, Filled/Unfilled )
Draw_Circle( X, Y, Radius, Color, Filled/Unfilled )
Draw_Ellipse( X1, Y1, X2, Y2, Color, Filled/Unfilled )
Draw_Arc( X1, Y1, X2, Y2, StartX, StartY, EndX, EndY, Color )
Clear_Window( Color )
Flood_Fill( X, Y, Color )
Display_Text( X, Y, String Expression, Color )
Display_Number( X, Y, Number Expression, Color )
Mouse input procedures
Wait_for_Mouse_Button( Which_Button )
Get_Mouse_Button( Which_Button, X, Y )
Mouse input functions
Mouse_Button_Pressed( Which_Button ) –> returns True / False
Mouse_Button_Released( Which_Button ) –> returns True / False
Get_Mouse_X –> returns X coordinate of mouse location
Get_Mouse_Y –> returns Y coordinate of mouse location
RAPTORGraph Syntax and Semantics
How to animate an object in RAPTORGraph
Place the following inside of a loop
Draw some an object relative to an X,Y point with the drawing procedures
Delay_For some small time period
Draw the object again in white (i.e. erase it)
Update the X,Y point where you are drawing by some small offset
RAPTORGraph Colors
Black, Blue, Green, Cyan, Red, Magenta, Brown, Light_Gray, Dark_Gray, Light_Blue,
Light_Green, Light_Cyan, Light_Red, Light_Magenta, Yellow, White
(Get_Pixel returns 0 for Black, 1 for Blue, …,16 for White)
Graphics window query function
Get_Pixel( X, Y ) -> returns the number code for the color of the pixel at (X, Y)
Слайд 3Iteration Statement (loop statement) –
An Iteration statement enables a group of
Iteration Statement (loop statement) – An Iteration statement enables a group of
Use I.T.E.M (Initialize, Test, Execute, and Modify) to ensure your loop (and loop control variable) are correct.
A Condition Controlled Loop (basic loop) repeats its statements
until a condition (the decision statement) becomes true.
The validation loop above will continue to execute
until the user enters a number between 1 and 10.
Number is the loop control variable.
A Count Controlled Loop repeats its statements a fixed number of times.
(This executes the loop 100 times because of the decision: Count >= 100).
The count controlled loop above executes exactly 10 times (it displays the numbers 1 through 10 and the squares of those numbers).
Count is the loop control variable.
Initialize (and modify)
the loop control variable
Test the loop
control variable
Initialize the loop control variable (above the loop)
Modify the loop control variable
Test the loop
control variable
Execution step
Execution step
Selection Statement - A selection statement is used to decide whether or not to do something, or to decide which of several things (if any) to do.
If the Boolean Expression is TRUE,
execute the left hand path
otherwise
execute the right hand path
If the value of the variable GPA is greater than 3.0
then execute the statement Put("Dean’s List")
otherwise do nothing
If a student’s GPA is less than 2.0
then execute the statement Put("Academic probabtion")
otherwise execute the statement
Put("Cadet in good standing")
This last example requires several decision statements as there are several decisions (more than two possible paths). The code assigns a nominal “grade” based on a student’s GPA.
The “pattern” of these selection statements is called cascading selections.
RAPTOR Syntax and Semantics – Selection and Iteration Control Structures