Programming and Graphics

(Kiana) #1

7.2 Getting started withVogle 205


(a)(b)

Figure 7.2.2. (a)AVoglewindow printing and underlining a Greek word in world
coordinates. (b)AVoglewindow with several shapes created by changing
the viewport.

int main()
{
prefposition (600,200); // window position
prefsize (300, 300); // window size
vinit("X11"); // initialize on the screen
color (BLACK);
clear();

ortho2 (-1.0,1.0, -1.0,1.0);

//--- Prepare to write:

font("/tmp/hfonts/futura.m");
textsize(0.2,0.2);

//--- Define a viewport in the top left corner and draw a rectangle:

viewport(-1.0, 0.0, 0.0, 1.0);

move2(-0.9, -0.5); /* write out a heading */
color(MAGENTA);
drawstr("rectangle");
rect(-0.2, -0.2, 0.3, 0.2);
Free download pdf