Class GPolygon

GObject
  extended by GFillableObject
      extended by GPolygon

The GPolygon class is a graphical object whose appearance consists of a polygon. The constructor creates an empty GPolygon to which you then add vertices using some combination of the add_vertex, add_edge, and add_polar_edge methods.

The vertices of the GPolygon are expressed relative to a reference point, which indicates the location of the polygon as a whole. Conceptually, it is easiest to think of the reference point as a push pin sticking into the polygon. When you add the GPolygon to the window, the coordinates indicate where the push pin goes.


Constructor Summary
GPolygon()
Constructs a new empty polygon at the origin.
 
Method Summary
add_edge(dx, dy)
Adds an edge to the polygon whose components are given by the displacements dx and dy from the last vertex.
add_polar_edge(r, theta)
Adds an edge to the polygon specified in polar coordinates.
add_vertex(x, y)
Adds a vertex at (x, y) relative to the polygon origin.
 
Inherited Method Summary
contains(x, y)
Checks to see whether a point is inside the object.
get_bounds()
Returns the bounding box for this object.
get_color()
Returns the color used to display this object.
get_fill_color()
Returns the color used to display the filled region of this object.
get_height()
Returns the height of this object, which is defined to be the height of the bounding box.
get_location()
Returns the location of this object as a GPoint.
get_size()
Returns the size of the bounding box for this object.
get_width()
Returns the width of this object, which is defined to be the width of the bounding box.
get_x()
Returns the x-coordinate of the object.
get_y()
Returns the y-coordinate of the object.
is_visible()
Checks to see whether this object is visible.
is_filled()
Returns whether this object is filled.
move(dx, dy)
Moves the object on the screen using the displacements dx and dy.
move_polar(r, theta)
Moves the object using displacements given in polar coordinates.
scale(sf)
Scales the object on the screen by the scale factor sf, which applies in both dimensions.
send_backward()
Moves this object one step toward the back in the z dimension.
send_forward()
Moves this object one step toward the front in the z dimension.
send_to_back()
Moves this object to the back of the display in the z dimension.
send_to_front()
Moves this object to the front of the display in the z dimension.
set_color(color)
Sets the color used to display this object.
set_fill_color(color)
Sets the color used to display the filled region of this object.
set_filled(flag)
Sets whether this object is filled.
set_location(x, y)
Sets the location of this object to the point (x, y).
set_visible(flag)
Sets whether this object is visible.
 

Constructor Detail

GPolygon()

Constructs a new empty polygon at the origin.
Usage: gpoly = GPolygon() 
 
 


Method Detail
Usage: gpoly.add_arc(arc_width, arc_height, start, sweep) 
Parameters: 
arc_width  The width of the oval from which the arc is taken
arc_height  The height of the oval from which the arc is taken
start  The angle at which the arc begins
sweep  The extent of the arc
 


add_edge(dx, dy)

Adds an edge to the polygon whose components are given by the displacements dx and dy from the last vertex.
Usage: gpoly.add_edge(dx, dy) 
Parameters: 
dx  The x displacement through which the edge moves
dy  The y displacement through which the edge moves
 


add_polar_edge(r, theta)

Adds an edge to the polygon specified in polar coordinates. The length of the edge is given by r, and the edge extends in direction theta, measured in degrees counterclockwise from the +x axis.
Usage: gpoly.add_polar_edge(r, theta) 
Parameters: 
 The length of the edge
theta  The angle at which the edge extends measured in degrees
 


add_vertex(x, y)

Adds a vertex at (x, y) relative to the polygon origin.
Usage: gpoly.add_vertex(x, y) 
Parameters: 
 The x-coordinate of the vertex relative to the polygon origin
 The y-coordinate of the vertex relative to the polygon origin
 


get_bounds()

Returns the bounding box of this object, which is defined to be the smallest rectangle that covers everything drawn by the figure.
Usage: bounds = gpoly.get_bounds() 
Returns: The bounding box for this object