Algorithmic Solutions > LEDA > LEDA Guide > Windows and Panels > Drawing Operations > Example

Example Drawing Operations

The following program is a slight modification of the Example Program for Computing Extremal Circles.

The program generates a window W, generates a list L of random points and computes all enclosing circles for L. Then it draws the points in L and the circles. The program is terminated with the right mouse button.

On the right there is a screenshot of the program. Clicking on the picture shows the window in original size.

Picture of Convex Hull
#include <LEDA/core/list.h>
#include <LEDA/geo/point.h>
#include <LEDA/geo/circle.h>
#include <LEDA/geo/random_point.h>
#include <LEDA/graphics/window.h>
#include <LEDA/geo/geo_alg.h>

using namespace leda;

int main()
{
  window W;
  W.init(-110,110,-110);
  W.open(); W.display();
 
  for (;;) {
    W.clear();

    list<point> L;random_points_in_square(10,50,L);  
    list<circle> LC;ALL_ENCLOSING_CIRCLES(L,LC);
 
    W.set_node_width(3);W.set_line_width(2);

    point p;
    forall(p,L) W.draw_filled_node(p.to_point());
    circle C;
    forall(C,LC) W.draw_circle(C.to_circle(),red);
  
    if (W.read_mouse()==MOUSE_BUTTON(3)) break;
  }

  return 0;
}		      

See also:

Drawing Operations

Example Program for Computing Extremal Circles

Windows and Panels

Linear Lists

Basic Data Types for 2D Geometry

Mouse Input


Input and Output Operators

Geometry Algorithms


Manual Pages:

Manual Page Windows




Please send any suggestions, comments or questions to leda@algorithmic-solutions.com
© Copyright 2001-2003, Algorithmic Solutions Software GmbH