GRAPHICS MODULE 14 STUDY BOOK
Graphic commands SCREEN - puts the screen into graphics mode WINDOW - allows scaling of the screen LINE - 3 formats –LINE between 2 points –LINE from current cursor position to new point –LINE - coordinates define diagonal points and connecting lines automatically drawn PSET - draws a single point
When graphing on paper graph equation –over what range –expected values –scale –draw axis –calculate point –draw point
Graph equation on Computer Put computer into graphics mode over what range expected values scale draw axis calculate point draw point SCREEN WINDOW LINE LOOP /EQUATION LINE or PSET
Example SCREEN 12 FOR t = 1 to 10 s = t ^ 3 / * t ^ LINE -(t, s) NEXT
Graphics Commands SCREEN mode - defines resolution (number of pixels) and colours available e.g. SCREEN 12 WINDOW (x,y)-(x1,y1) - scales screen –x,y define upper left corner –x1,y1 define lower right
Drawing Commands PSET [STEP](x,y)[, colour] PSET (50,50), 2 draws a point at coordinate 50,50 in a colour #2 (green) uses absolute coordinates - the expression of a pixel’s location in terms of its x and y coordinates
PSET STEP (20,4) draws a point that is 20 pixels to the right and 4 pixels down for the last point referenced uses relative coordinates - location is expressed in terms of the x and y distances from the last referenced point
LINE Statement LINE [(x1, y1)] - (x2, y2) [, colour] [, B[F]] LINE (0,0) - (320,240), 4 draws a line from 0,0 (upper left) to 320,240 (centre) in red ( assuming no WINDOW) adding the B command draws a box whose diagonal coordinates are 0,0 and 320,240 in red adding a BF command draws a solid box as above in red
LINE - (639,479) draws a line from the current cursor position to point 639,479 (lower right) (again assuming no WINDOW statement)
Colours
SCREEN 12 WINDOW (-2, 130)-(15, -50) LINE (0, -50)-(0, 130), 3 LINE (-2, 0)-(15, 0), 3 PSET (0, 6) FOR t = 1 TO 10 STEP.01 s = t ^ 3 / * t ^ LINE -(t, s) NEXT LOCATE 10, 20 PRINT "graph f(t)" LOCATE 27, 65 PRINT "time,t, sec" graph equation –over what range –expected values –scale –draw axis –calculate point –draw point –loop until range exceeded
Adding text to graphics LOCATE row, column PRINT “text”, variables –text row between 1 and 30 and column between 1 and 80 –separate from graphics scaling –number of rows and columns depends on screen type and mode COLOR number –number defines colour, between 0 and 15 –all following printing will be done in this colour