Assignment 1 Due Sept 11, 5PM.
Develop a basic 2D graphics package but with only the ability to draw horizontal and vertical lines.
init_graphics() set_window(xmin,xmax,ymin,ymax) set_viewport(umin,umax,vmin,vmax) move(x,y) connect(x,y) line(x1,y1,x2,y2) text(string) end_frame() end_graphics()
Clipping of lines is not required. You are free to use other names for these routines as you wish.
Write a short driver program that exercises the package - i.e. that calls the routines to do the following in two separate frames:
1. Draw a box inside the window with the word "Hello" at the center. The Window should have world coordinates extending from xmin,ymin = (-1.0,-1.0) to xmax,ymax = (9.0,9.0). The box should have bottom left corner at (0.0,0.0) and top right corner at (8.0,8.0) The text should begin at point (4.0,4.0). The box will then be symmetrically placed in the screen and consume 80% of the screen in width and height. The text should start at the exact center of the screen.
2. Draw a box inside a second window with the word "Hello" at the center. Everything should be as in the first frame except that now you choose a viewport which has a bottom left corner at (0.5,0.5) and a top right corner at (1.0,1.0). This will push the box up and to the left. It will fit into the top right quarter (quadrant) of the screen, filling 80% of that quadrant in width and height. The text should now start at the center of that quadrant.
Since clipping is not required, it is essential to arrange to draw only lines that you are certain fit inside the window.
Use a raster array to implement the package for a line printer or xterm text window as discussed in the notes.