Programming and Graphics

(Kiana) #1

204 Introduction to C++ Programming and Graphics


#include "VOGLE/voglec++.h"
using namespace std;

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

ortho2 (0.0,2.0, 0.0,6.0); // world coordinates for x and y

color(RED); // print the word
move2(0.1, 3.0);
font("/tmp/hfonts/greek");
textsize(0.3,0.9);
drawstr("Elaiolado");

move2(0.1,3.0); // underline the word
draw2(1.6,3.0);

//--- Press key to finish:

getkey();
vexit();
return 0;
}

In this code, the “move to”(move2) and “draw to” (draw2)Voglefunctions
have been used to move the pen lifted or pressed down. The generated graphics
window is shown in Figure 7.2.2(a).


Shapes


The following code contained in the fileshapes.cc, adapted from an exam-
ple given in theVogledistribution, illustrates the use of furtherVogledraw-
ing functions:


/*--------------------------------------------
DRAW A VARIETY OF SHAPES USING VOGLE FUNCTIONS
---------------------------------------------*/

#include "VOGLE/voglec++.h"
using namespace std;
Free download pdf