Wx::Polygon - Draw and manipulate polygons for wxPerl


This module provides functions for manipulating polygons in wxPerl.


new( POLYGON = \(Wx::Point,...) | ELLIPSE => \(x_offset,y_offset,width,heigth) ) --> Wx::Polygon>

Instantiates a new Wx::Polygon with an array of Wx::Points for a given POLYGON or an ellipse with given parameters.

add_point(x,y,recalc=1) --> void

Adds a point to the polygon. If scale and rotation have been used, rescales and rerotates the polygon after adding the point. If recalc is set to 0, this will not be done, which is better when a lot of points need added.

recalc() --> void

Rescales and rerotates the polygon. This method should be used when a lot of points need to be added. Recalculation can than be done after adding the points.

set_color(r,g,b) --> void

Sets the fill color to wxSOLID with the given r, g and b values.

mid() --> (midx:integer,midy:integer)

Calculates the middle of the polygon (not point 'z') and returns a list with x and y position.

in(x,y) --> boolean

Calculates if (x,y) falls within the edges of the polygon. Returns true if so. Uses algorithm of Randolph Franklin,

draw( dc:Wx::DC ) --> void

Draws the polygon at given offsets and with given colour(s) to the current DC.

copy() --> Wx::Polygon

Returns a copy of the object.

scale(scale-factor) --> void

Scales the polygon with scale-factor.

rotate(degrees) --> void

Rotates the polygon by degrees degrees (0-360).

offset(x,y) --> void

Sets the offset for drawing. This can be used to transpose the polygon.


Hans Oesterholt-Dijkema <>


(c)2004 Hans Oesterholt-Dijkema. This module can be redistributed under artistic license.