API reference - Class DPath

Notation used in Ruby API documentation

Description: A path class

A path consists of an sequence of line segments forming the 'spine' of the path and a width. In addition, the starting point can be drawn back by a certain extent (the 'begin extension') and the end point can be pulled forward somewhat (by the 'end extension').

A path may have round ends for special purposes. In particular, a round-ended path with a single point can represent a circle. Round-ended paths should have being and end extensions equal to half the width. Non-round-ended paths with a single point are allowed but the definition of the resulting shape in not well defined and may differ in other tools.

See The Database API for more details about the database objects.

Public constructors

new DPathnewDefault constructor: creates an empty (invalid) path with width 0
new DPathnew(DPoint[] pts,
double width)
Constructor given the points of the path's spine and the width
new DPathnew(DPoint[] pts,
double width,
double bgn_ext,
double end_ext)
Constructor given the points of the path's spine, the width and the extensions
new DPathnew(DPoint[] pts,
double width,
double bgn_ext,
double end_ext,
bool round)
Constructor given the points of the path's spine, the width, the extensions and the round end flag

Public methods

[const]bool!=(const DPath p)Inequality test
[const]DPath*(double f)Scaling by some factor
[const]bool<(const DPath p)Less operator
[const]bool==(const DPath p)Equality test
[const]doubleareaReturns the approximate area of the path
[const]voidassign(const DPath other)Assign the contents of another object to self
[const]DBoxbboxReturns the bounding box of the path
[const]doublebgn_extGet the begin extension
voidbgn_ext=(double ext)Set the begin extension
voidcreateEnsures the C++ object is created
voiddestroyExplicitly destroy the object
[const]booldestroyed?Returns a value indicating whether the object was already destroyed
[const]DPathdupCreates a copy of self
[const,iter]DPointeach_pointGet the points that make up the path's spine
[const]doubleend_extGet the end extension
voidend_ext=(double ext)Set the end extension
[const]boolis_const_object?Returns a value indicating whether the reference is a const reference
[const]boolis_round?Returns true, if the path has round ends
[const]doublelengthReturns the length of the path
DPathmove(const DPoint p)Moves the path.
DPathmove(double dx,
double dy)
Moves the path.
[const]DPathmoved(const DPoint p)Returns the moved path (does not change self)
[const]DPathmoved(double dx,
double dy)
Returns the moved path (does not change self)
[const]unsigned intnum_pointsGet the number of points
voidpoints=(DPoint[] p)Set the points of the path
[const]DPolygonpolygonConvert the path to a polygon
voidround=(bool round_ends_flag)Set the 'round ends' flag
[const]DSimplePolygonsimple_polygonConvert the path to a simple polygon
[const]stringto_sConvert to a string
[const]DPathtransformed(const DTrans t)Transform the path.
[const]DPathtransformed(const DCplxTrans t)Transform the path.
[const]doublewidthGet the width
voidwidth=(double w)Set the width

Public static methods and constants

DPathfrom_ipath(const Path int_path)Construct a floating-point coordinate path from an integer coordinate one
new DPathfrom_s(string s)Creates an object from a string

Deprecated methods (protected, public, static, non-static and constructors)

[static]new DPathnew_pw(DPoint[] pts,
double width)
Use of this method is deprecated. Use new instead
[static]new DPathnew_pwx(DPoint[] pts,
double width,
double bgn_ext,
double end_ext)
Use of this method is deprecated. Use new instead
[static]new DPathnew_pwxr(DPoint[] pts,
double width,
double bgn_ext,
double end_ext,
bool round)
Use of this method is deprecated. Use new instead
[const]unsigned intpointsUse of this method is deprecated. Use num_points instead
[const]DPathtransformed_cplx(const DCplxTrans t)Use of this method is deprecated. Use transformed instead

Detailed description

[const] bool !=(const DPath p)

Description: Inequality test

p:The object to compare against

[const] DPath *(double f)

Description: Scaling by some factor

Returns the scaled object. All coordinates are multiplied with the given factor and if necessary rounded.

[const] bool <(const DPath p)

Description: Less operator

p:The object to compare against

This operator is provided to establish some, not necessarily a certain sorting order

[const] bool ==(const DPath p)

Description: Equality test

p:The object to compare against

[const] double area

Description: Returns the approximate area of the path

This method returns the approximate value of the area. It is computed from the length times the width. end extensions are taken into account correctly, but not effects of the corner interpolation. This method was added in version 0.22.

[const] void assign(const DPath other)

Description: Assign the contents of another object to self

This method assigns the contents of another object to self. This is a deep copy that does not only copy the reference but the actual content.

[const] DBox bbox

Description: Returns the bounding box of the path

[const] double bgn_ext

Description: Get the begin extension

void bgn_ext=(double ext)

Description: Set the begin extension

void create

Description: Ensures the C++ object is created

Use this method to ensure the C++ object is created, for example to ensure that resources are allocated. Usually C++ objects are created on demand and not necessarily when the script object is created.

void destroy

Description: Explicitly destroy the object

Explicitly destroy the object on C++ side if it was owned by the Ruby interpreter. Subsequent access to this object will throw an exception. If the object is not owned by Ruby, this method will do nothing.

[const] bool destroyed?

Description: Returns a value indicating whether the object was already destroyed

This method returns true, if the object was destroyed, either explicitly or by the C++ side. The latter may happen, if the object is owned by a C++ object which got destroyed itself.

[const] DPath dup

Description: Creates a copy of self

[const,iter] DPoint each_point

Description: Get the points that make up the path's spine

[const] double end_ext

Description: Get the end extension

void end_ext=(double ext)

Description: Set the end extension

[static] DPath from_ipath(const Path int_path)

Description: Construct a floating-point coordinate path from an integer coordinate one

This method has been added in version 0.15.

[static] new DPath from_s(string s)

Description: Creates an object from a string

Creates the object from a string representation (as returned by to_s)

This method has been added in version 0.23.

[const] bool is_const_object?

Description: Returns a value indicating whether the reference is a const reference

This method returns true, if self is a const reference. In that case, only const methods may be called on self.

[const] bool is_round?

Description: Returns true, if the path has round ends

[const] double length

Description: Returns the length of the path

the length of the path is determined by summing the lengths of the segments and adding begin and end extensions. For round-ended paths the length of the paths between the tips of the ends.

This method was added in version 0.23.

DPath move(const DPoint p)

Description: Moves the path.

p:The distance to move the path.
Returns:The moved path.

Moves the path by the given offset and returns the moved path. The path is overwritten.

DPath move(double dx,double dy)

Description: Moves the path.

dx:The x distance to move the path.
dy:The y distance to move the path.
Returns:The moved path.

Moves the path by the given offset and returns the moved path. The path is overwritten.

This version has been added in version 0.23.

[const] DPath moved(const DPoint p)

Description: Returns the moved path (does not change self)

p:The distance to move the path.
Returns:The moved path.

Moves the path by the given offset and returns the moved path. The path is not modified.

[const] DPath moved(double dx,double dy)

Description: Returns the moved path (does not change self)

dx:The x distance to move the path.
dy:The y distance to move the path.
Returns:The moved path.

Moves the path by the given offset and returns the moved path. The path is not modified.

This version has been added in version 0.23.

[static] new DPath new

Description: Default constructor: creates an empty (invalid) path with width 0

[static] new DPath new(DPoint[] pts,double width)

Description: Constructor given the points of the path's spine and the width

pts:The points forming the spine of the path
width:The width of the path

[static] new DPath new(DPoint[] pts,double width,double bgn_ext,double end_ext)

Description: Constructor given the points of the path's spine, the width and the extensions

pts:The points forming the spine of the path
width:The width of the path
bgn_ext:The begin extension of the path
end_ext:The end extension of the path

[static] new DPath new(DPoint[] pts,double width,double bgn_ext,double end_ext,bool round)

Description: Constructor given the points of the path's spine, the width, the extensions and the round end flag

pts:The points forming the spine of the path
width:The width of the path
bgn_ext:The begin extension of the path
end_ext:The end extension of the path
round:If this flag is true, the path will get rounded ends

[static] new DPath new_pw(DPoint[] pts,double width)

Description: Constructor given the points of the path's spine and the width

pts:The points forming the spine of the path
width:The width of the path

This method is deprecated. Use method 'new' instead

[static] new DPath new_pwx(DPoint[] pts,double width,double bgn_ext,double end_ext)

Description: Constructor given the points of the path's spine, the width and the extensions

pts:The points forming the spine of the path
width:The width of the path
bgn_ext:The begin extension of the path
end_ext:The end extension of the path

This method is deprecated. Use method 'new' instead

[static] new DPath new_pwxr(DPoint[] pts,double width,double bgn_ext,double end_ext,bool round)

Description: Constructor given the points of the path's spine, the width, the extensions and the round end flag

pts:The points forming the spine of the path
width:The width of the path
bgn_ext:The begin extension of the path
end_ext:The end extension of the path
round:If this flag is true, the path will get rounded ends

This method is deprecated. Use method 'new' instead

[const] unsigned int num_points

Description: Get the number of points

[const] unsigned int points

Description: Get the number of points

This method is deprecated. Use method 'num_points' instead

void points=(DPoint[] p)

Description: Set the points of the path

p:An array of points to assign to the path's spine

[const] DPolygon polygon

Description: Convert the path to a polygon

The returned polygon is not guaranteed to be non-self overlapping. This may happen if the path overlaps itself or contains very short segments.

void round=(bool round_ends_flag)

Description: Set the 'round ends' flag

A path with round ends show half circles at the ends, instead of square or rectangular ends. Paths with this flag set should use a begin and end extension of half the width (see bgn_ext and end_ext). The interpretation of such paths in other tools may differ otherwise.

[const] DSimplePolygon simple_polygon

Description: Convert the path to a simple polygon

The returned polygon is not guaranteed to be non-selfoverlapping. This may happen if the path overlaps itself or contains very short segments.

[const] string to_s

Description: Convert to a string

[const] DPath transformed(const DTrans t)

Description: Transform the path.

t:The transformation to apply.
Returns:The transformed path.

Transforms the path with the given transformation. Does not modify the path but returns the transformed path.

[const] DPath transformed(const DCplxTrans t)

Description: Transform the path.

t:The transformation to apply.
Returns:The transformed path.

Transforms the path with the given complex transformation. Does not modify the path but returns the transformed path.

[const] DPath transformed_cplx(const DCplxTrans t)

Description: Transform the path.

t:The transformation to apply.
Returns:The transformed path.

This method is deprecated. Use method 'transformed' instead

[const] double width

Description: Get the width

void width=(double w)

Description: Set the width