Package snap.geom
Class Shape
java.lang.Object
snap.geom.Shape
- Direct Known Subclasses:
Polygon
,PolygonPath
,RectBase
,Segment
,SegmentPath
,ShapeBox
,ShapeBuilder
,SplicerShape
A class to represent a generic geometric shape (Line, Rect, Ellipse, etc.).
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Shape
Adds two shapes together.boolean
contains
(double aX, double aY) Returns whether shape contains x/y.boolean
contains
(double aX, double aY, double aLineWidth) Returns whether shape with line width contains point.boolean
Returns whether shape contains point.boolean
Returns whether shape contains shape.boolean
containsSeg
(Segment aSeg) Returns whether this shape contains given segment.Returns the shape in rect.Returns a copy of this shape transformed by given transform.copyForBounds
(double aX, double aY, double aW, double aH) Returns the shape in rect.boolean
crossesSeg
(Segment aSeg) Returns whether any segments of this shape cross given segment.double
Returns the total length of all shape segements.Returns the bounds.protected Rect
Returns the bounds.int
getCrossings
(double aX, double aY) Returns the number of crossings for the ray from given point extending to the right.double
getDistance
(double x, double y) Returns the closest distance from given point to path.Returns a flattented version of this shape (just this shape if already flat).getFlattenedShape
(double aFlatDistance) Returns a flattented version of this shape (just this shape if already flat).double
Returns the shape bounds height.static Shape
getNotSelfIntersectingShape
(Shape aShape) Returns a simple shape for complex shape.abstract PathIter
getPathIter
(Transform aT) Returns a path iterator.Returns an SVG string representation of Shape.double
getWidth()
Returns the shape bounds width.double
getX()
Returns the shape bounds x.double
getY()
Returns the shape bounds y.static Shape
intersectShapes
(Shape aShape1, Shape aShape2) Returns the intersection shape of two shapes.boolean
intersectsSeg
(Segment aSeg) Returns whether this shape intersects given segment (crosses or contains).boolean
intersectsShape
(Shape aShape) Returns whether this shape intersects given shape.boolean
intersectsShape
(Shape aShape, double aLineWidth) Returns whether shape with line width intersects shape.boolean
intersectsXY
(double aX, double aY, double aLineWidth) Returns whether shape with line width intersects point.boolean
isClosed()
Returns whether shape forms a closed polygon/path, either explicitly (last segment is close) or implicitly (last segment ends at last move to).boolean
isFlat()
Returns whether this shape is made up of only line segements.boolean
Returns whether path made up of multiple subpaths (more than one moveto).boolean
Returns whether shape has intersecting segments.boolean
Returns whether path has only a single moveto.protected void
Called when shape changes.static Shape
subtractShapes
(Shape aShape1, Shape aShape2) Subtracts two shapes together.toString()
Standard to string implementation.
-
Field Details
-
_bounds
-
WIND_EVEN_ODD
public static final int WIND_EVEN_ODD- See Also:
-
WIND_NON_ZERO
public static final int WIND_NON_ZERO- See Also:
-
-
Constructor Details
-
Shape
public Shape()
-
-
Method Details
-
getX
public double getX()Returns the shape bounds x. -
getY
public double getY()Returns the shape bounds y. -
getWidth
public double getWidth()Returns the shape bounds width. -
getHeight
public double getHeight()Returns the shape bounds height. -
getBounds
Returns the bounds. -
getBoundsImpl
Returns the bounds. -
getArcLength
public double getArcLength()Returns the total length of all shape segements. -
getPathIter
Returns a path iterator. -
contains
Returns whether shape contains point. -
contains
public boolean contains(double aX, double aY) Returns whether shape contains x/y. -
getCrossings
public int getCrossings(double aX, double aY) Returns the number of crossings for the ray from given point extending to the right. -
contains
Returns whether shape contains shape. -
intersectsShape
Returns whether this shape intersects given shape. -
containsSeg
Returns whether this shape contains given segment. -
intersectsSeg
Returns whether this shape intersects given segment (crosses or contains). -
crossesSeg
Returns whether any segments of this shape cross given segment. -
getDistance
public double getDistance(double x, double y) Returns the closest distance from given point to path. -
contains
public boolean contains(double aX, double aY, double aLineWidth) Returns whether shape with line width contains point. -
intersectsXY
public boolean intersectsXY(double aX, double aY, double aLineWidth) Returns whether shape with line width intersects point. -
intersectsShape
Returns whether shape with line width intersects shape. -
isClosed
public boolean isClosed()Returns whether shape forms a closed polygon/path, either explicitly (last segment is close) or implicitly (last segment ends at last move to). Supports multiple subpaths. -
isFlat
public boolean isFlat()Returns whether this shape is made up of only line segements. -
getFlattenedShape
Returns a flattented version of this shape (just this shape if already flat). -
getFlattenedShape
Returns a flattented version of this shape (just this shape if already flat). -
isSingleCycle
public boolean isSingleCycle()Returns whether path has only a single moveto. -
isMultiCycle
public boolean isMultiCycle()Returns whether path made up of multiple subpaths (more than one moveto). -
isSelfIntersecting
public boolean isSelfIntersecting()Returns whether shape has intersecting segments. -
shapeChanged
protected void shapeChanged()Called when shape changes. -
copyFor
Returns the shape in rect. -
copyForBounds
Returns the shape in rect. -
copyFor
Returns a copy of this shape transformed by given transform. -
getSvgString
Returns an SVG string representation of Shape. -
toString
Standard to string implementation. -
addShapes
Adds two shapes together. -
subtractShapes
Subtracts two shapes together. -
intersectShapes
Returns the intersection shape of two shapes. -
getNotSelfIntersectingShape
Returns a simple shape for complex shape.
-