// NamedObjects.cc
// Gloobs example program
//
// demonstrates naming of parts of Gloobs objects, for later manipulation
//
// by Smylers
// 2000 Jan 17: original version
#include <gloobs.h>
int main()
{
using namespace Gloobs;
Canvas Seascape(X11, 260, 120, "Yachts");
// define the colours used in the picture:
int Sea = Seascape.ink(0.2, 0.5, 0.8);
int Hull = Seascape.ink(0.7, 0.6, 0.4);
int Mast = Seascape.ink(0.5, 0.3, 0.2);
int Red = Seascape.ink(0.9, 0.0, 0.0);
Seascape.set_background(Sea);
// declare a Boat Object, and add some primitives to it for the hull and
// mast:
Object Boat;
double HullCoords[] =
{
15, 0,
5, 15,
60, 15,
50, 0
};
Boat.push_back(new Polygon(Hull, Filled, 4, HullCoords));
Boat.push_back(new Line(Mast, 4, 35, 15, 35, 60));
// declare a Triangle Primitive for the sail:
Triangle* Sail = new Triangle(Red, Filled, 0, 25, 35, 60, 35, 25);
// add the named Primitive to the Object:
Boat.push_back(Sail);
// now draw the boat on the canvas:
Seascape.draw_object(Boat, 20, 20);
Seascape.pause();
// define some more colours:
int White = Seascape.ink(0.9, 0.9, 0.9);
int Yellow = Seascape.ink(0.9, 0.9, 0.0);
// change the Pen colour of the Sail Primitive:
Sail->Pen = White;
// now draw the Boat Object again:
Seascape.draw_object(Boat, 100, 20);
// and another one with a yellow sail:
Sail->Pen = Yellow;
Seascape.draw_object(Boat, 180, 20);
Seascape.pause();
return 0;
}