Next: , Previous: GnomeCanvasText, Up: Top


16 gnome-canvas-util

Canvas utility functions

16.1 Overview

Some useful canvas utility functions.

The <gnome-canvas-points> structure manages an array of points (X and Y coordinates) and is used by <gnome-canvas-line> and <gnome-canvas-polygon> canvas items.

To create a <gnome-canvas-points> structure call gnome-canvas-points-new and when finished using it call gnome-canvas-points-free.

Of note is that the <gnome-canvas-points> structure is actually managed by a reference count, so it won't be freed until this count reaches 0. To increment its reference count call gnome-canvas-points-ref and to decrement it call gnome-canvas-points-unref.

16.2 Usage

— Class: <gnome-canvas-points>

Derives from <gboxed>.

— Function: gnome-canvas-get-miter-points (x1 double) (y1 double) (x2 double) (y2 double) (x3 double) (y3 double) (width double) ⇒  (ret int) (mx1 double) (my1 double) (mx2 double) (my2 double)

Given three points forming an angle, computes the coordinates of the inside and outside points of the mitered corner formed by a line of a given width at that angle.

x1
X coordinate of the first point
y1
Y coordinate of the first point
x2
X coordinate of the second (angle) point
y2
Y coordinate of the second (angle) point
x3
X coordinate of the third point
y3
Y coordinate of the third point
width
Width of the line
mx1
The X coordinate of the first miter point is returned here.
my1
The Y coordinate of the first miter point is returned here.
mx2
The X coordinate of the second miter point is returned here.
my2
The Y coordinate of the second miter point is returned here.
ret
FALSE if the angle is less than 11 degrees (this is the same threshold as X uses. If this occurs, the return points are not modified. Otherwise, returns TRUE.
— Function: gnome-canvas-get-butt-points (x1 double) (y1 double) (x2 double) (y2 double) (width double) (project int) ⇒  (bx1 double) (by1 double) (bx2 double) (by2 double)

Computes the butt points of a line segment.

x1
X coordinate of first point in the line
y1
Y cooordinate of first point in the line
x2
X coordinate of second point (endpoint) of the line
y2
Y coordinate of second point (endpoint) of the line
width
Width of the line
project
Whether the butt points should project out by width/2 distance
bx1
X coordinate of first butt point is returned here
by1
Y coordinate of first butt point is returned here
bx2
X coordinate of second butt point is returned here
by2
Y coordinate of second butt point is returned here
— Function: gnome-canvas-polygon-to-point (num_points int) (double) (double) ⇒  (ret double) (poly double)

Computes the distance between a point and a polygon.

poly
Vertices of the polygon. X coordinates are in the even indices, and Y coordinates are in the odd indices
num-points
Number of points in the polygon
x
X coordinate of the point
y
Y coordinate of the point
ret
The distance from the point to the polygon, or zero if the point is inside the polygon.
— Function: gnome-canvas-item-reset-bounds (self <gnome-canvas-item>)
— Method: reset-bounds

Resets the bounding box of a canvas item to an empty rectangle.

item
A canvas item
— Function: gnome-canvas-update-bbox (item <gnome-canvas-item>) (x1 int) (y1 int) (x2 int) (y2 int)

Sets the bbox to the new value, requesting full repaint.

item
the canvas item needing update
x1
Left coordinate of the new bounding box
y1
Top coordinate of the new bounding box
x2
Right coordinate of the new bounding box
y2
Bottom coordinate of the new bounding box