Class Geometry
The Geometry class is used to define the "shape" of a Shape. A Geometry can be simple straight lines, rectangles, or ellipses. A Geometry can also be an arbitrarily complex path, consisting of a list of PathFigures.
A Geometry must not be modified once it has been used by a Shape. However, a Geometry may be shared by multiple Shapes.
Constructor Summary Details
Returns | Name | Description |
---|---|---|
Geometry(type)
|
Construct an empty Geometry. More...
The geometry type must be one of the following values:
Geometry.Line, Geometry.Ellipse, Geometry.Rectangle, Geometry.Path.
|
Properties Summary Details
Returns | Name | Description |
---|---|---|
{Rect}
|
bounds
|
This read-only property returns a rectangle that contains all points within the Geometry. More...
The result will always contain the origin (0, 0).
|
{EnumValue}
|
defaultStretch
1.5
|
Gets or sets the Shape.geometryStretch value the Shape should use by default
when the Shape.geometryStretch value is GraphObject.None. More...
The default value is GraphObject.Fill.
Some figure generators return a Geometry with this property set to GraphObject.Uniform,
in order to preserve its aspect ratio when used by a Shape that may have different sizes.
|
{number}
|
endX
|
|
{number}
|
endY
|
|
{List.
|
figures
|
Gets or sets the List of PathFigures
that describes the content of the
path for Geometries of type Path.
|
{Spot}
|
spot1
|
Gets or sets the spot an "Auto" Panel will use for the top-left corner of any panel content
when the Shape.spot1 value is Spot.Default. More...
The default value is Spot.TopLeft, at the top-left point of the bounds of the Shape.
|
{Spot}
|
spot2
|
Gets or sets the spot an "Auto" Panel will use for the bottom-right corner of any panel content
when the Shape.spot2 value is Spot.Default. More...
The default value is Spot.BottomRight, at the bottom-right point of the bounds of the Shape.
|
{number}
|
startX
|
|
{number}
|
startY
|
|
{EnumValue}
|
type
|
Gets or sets the type of the Geometry. More...
The default type is Geometry.Path.
Other permissible values are Geometry.Line, Geometry.Ellipse,
or Geometry.Rectangle.
|
Method Summary Details
Returns | Name | Description |
---|---|---|
{Geometry}
|
add(figure)
1.5
|
Add a PathFigure to the figures list. More...
|
{Rect}
|
computeBoundsWithoutOrigin()
1.1
|
|
{Geometry}
|
copy()
|
Create a copy of this Geometry, with the same values and figures.
|
<static>
{string}
|
Geometry.fillPath(str)
1.1
|
Given a SVG or GoJS path string, returns a congruent path string with each pathfigure filled. More...
For instance, "M0 0 L22 22 L33 0" would become "F M0 0 L22 22 L33 0".
|
{Point}
|
normalize()
1.1
|
Normalizes the Geometry points in place by ensuring the top-left bounds of the geometry lines up with (0, 0),
returning the Point (x, y) amount it was shifted. More...
After this method is called there will be no negative X or Y value for the Geometry's bounds,
and no empty space at the top-left of the Geometry.
|
{Geometry}
|
offset(x, y)
1.1
|
|
<static>
{Geometry}
|
Geometry.parse(str, filled)
|
Produce a Geometry from a string that uses an SVG-like compact path geometry syntax. More...
The syntax accepts all SVG Path Syntax (W3 page),
as well as three GoJS-specific tokens.
Specifically, the following tokens are allowed:
|
{Geometry}
|
rotate(angle, x, y)
1.1
|
Rotates the Geometry in place by a given angle, with optional x and y values to rotate the geometry about. More...
If no x and y value are given, (0, 0) is used as the rotation point.
|
{Geometry}
|
scale(x, y)
1.1
|
Scales the Geometry in place by a given (x, y) scale factor. More...
If you want to flip a Geometry horizontally, call
|
<static>
{string}
|
Geometry.stringify(val)
1.1
|
This static function can be used to write out a Geometry as a string
that can be read by Geometry.parse. More...
The string produced by this method is a superset of the SVG path
string rules that contains some additional GoJS-specific tokens.
See the Introduction page on Geometry Parsing for more details.
|
Constants Summary Details
Returns | Name | Description |
---|---|---|
<constant> {EnumValue} |
Ellipse
|
|
<constant> {EnumValue} |
Line
|
|
<constant> {EnumValue} |
Path
|
For drawing a complex path made of a list of PathFigures;
a value for Geometry.type.
|
<constant> {EnumValue} |
Rectangle
|