Programming and Graphics

(Kiana) #1

7.2 Getting started withVogle 201


The code features the following implementations:



  • The graphics window position and size are first defined in screen pixel
    units.

  • TheVogledevice is initialized as “X11” to draw on the screen.

  • The background color is set to RED, and the window is cleared. The
    menu of available colors is given in Appendix B.

  • TheVoglefunctiongetkeymonitors the keyboard; When the window
    is selected and a key is pressed, the session terminates.


Hello


The following code contained in the filehello.cc generates a graphics
window and prints the greeting “Hello”, as shown in Figure 7.2.1(b):


/*-------------
VOGLE to greet
--------------*/

#include<iostream>
#include "VOGLE/voglec++.h"

using namespace std;

int main()
{

//--- Graphics window position and size in pixel units:

prefposition (600,200); // window position
prefsize (300, 300); // window size

//--- Initialize graphics device to be the screen:

vinit("X11");
color (YELLOW);
clear();

//--- Move to a position defined by default coordinates
//--- ranging from -1 to 1 in the x and y direction

move2 (-0.4, 0.0);

//--- Prepare to write:
Free download pdf