Path
Extends: module:AWT.Shape
Source: AWT.js:1370
A Path is a module:AWT.Shape formed by a serie of strokes, represented by
module:AWT.PathStroke objects
Constructor
new Path(strokes: Array.<module:AWT.PathStroke>): PathPath constructor
Parameters
strokes(Array.<module:AWT.PathStroke>) — The array of module:AWT.PathStroke objects defining this Path.
Instance Methods
addStroke(stroke: module:AWT.PathStroke)
Adds a module:AWT.PathStroke to strokes
Parameters
stroke(module:AWT.PathStroke)
calcEnclosingRect(): module:AWT.Rectangle
Calculates the polygon and the rectangle that (approximately) encloses this shape
Returns
getAttributes(): object
Gets a object with the basic attributes needed to rebuild this instance excluding functions,
parent references, constants and also attributes retaining the default value.
The resulting object is commonly usued to serialize elements in JSON format.
Returns
object
setAttributes(data: object): module:AWT.Path
Overrides: module:AWT.Shape#setAttributes
Reads the properties of this Path from a data object
Parameters
data(object) — The data object to be parsed
Returns
moveBy(delta: Point | Dimension): module:AWT.Shape
Inherited from module:AWT.Shape#moveBy
Overrides: module:AWT.Shape#moveBy
Shifts the shape a specified amount in horizontal and vertical directions
Parameters
Returns
moveTo(newPos: module:AWT.Point): module:AWT.Shape
Inherited from module:AWT.Shape#moveTo
Overrides: module:AWT.Shape#moveTo
Moves this shape to a new position
Parameters
newPos(module:AWT.Point) — The new position of the shape
Returns
getBounds(): module:AWT.Rectangle
Inherited from module:AWT.Shape#getBounds
Overrides: module:AWT.Shape#getBounds
Gets the enclosing Rectangle of this Shape.
Returns
equals(p: module:AWT.Shape): boolean
Inherited from module:AWT.Shape#equals
Overrides: module:AWT.Shape#equals
Checks if two shapes are equivalent.
Parameters
p(module:AWT.Shape) — The Shape to compare against
Returns
boolean
scaleBy(_delta: Point | Dimension): module:AWT.Shape
Inherited from module:AWT.Shape#scaleBy
Overrides: module:AWT.Shape#scaleBy
Multiplies the dimension of the Shape by the specified delta amount.
Parameters
Returns
getShape(rect: module:AWT.Rectangle): module:AWT.Shape
Inherited from module:AWT.Shape#getShape
Overrides: module:AWT.Shape#getShape
Gets a clone of this shape moved to the pos component of the rectangle and scaled
by its dim value.
Parameters
rect(module:AWT.Rectangle) — The rectangle to be taken as a base for moving and scaling
this shape.
Returns
contains(_p: module:AWT.Point): boolean
Inherited from module:AWT.Shape#contains
Overrides: module:AWT.Shape#contains
Checks if the provided module:AWT.Point is inside this shape.
Parameters
_p(module:AWT.Point) — The point to check
Returns
boolean
intersects(_r: module:AWT.Rectangle): boolean
Inherited from module:AWT.Shape#intersects
Overrides: module:AWT.Shape#intersects
Checks if the provided Rectangle r intersects with this shape.
Parameters
_r(module:AWT.Rectangle)
Returns
boolean
fill(
ctx: external:CanvasRenderingContext2D,
dirtyRegion?: module:AWT.Rectangle,
): external:CanvasRenderingContext2D
Inherited from module:AWT.Shape#fill
Overrides: module:AWT.Shape#fill
Fills the Shape with the current style in the provided HTML canvas context
Parameters
ctx(external:CanvasRenderingContext2D) — The canvas 2D rendering context where to fill this shape.dirtyRegion(module:AWT.Rectangle, optional) — The context region to be updated. Used as clipping
region when drawing.
Returns
stroke(
ctx: external:CanvasRenderingContext2D,
): external:CanvasRenderingContext2D
Inherited from module:AWT.Shape#stroke
Overrides: module:AWT.Shape#stroke
Draws this shape in the provided HTML canvas 2D rendering context.
Parameters
ctx(external:CanvasRenderingContext2D) — The canvas 2D rendering context where to draw the shape.
Returns
preparePath(
ctx: external:CanvasRenderingContext2D,
): external:CanvasRenderingContext2D
Inherited from module:AWT.Shape#preparePath
Overrides: module:AWT.Shape#preparePath
Prepares an HTML canvas 2D rendering context with a path that can be used to stroke a line,
to fill a surface or to define a clipping region.
Parameters
Returns
clip(
ctx: external:CanvasRenderingContext2D,
fillRule?: string,
): external:CanvasRenderingContext2D
Inherited from module:AWT.Shape#clip
Overrides: module:AWT.Shape#clip
Creates a clipping region on the specified HTML canvas 2D rendering context
Parameters
ctx(external:CanvasRenderingContext2D) — The rendering contextfillRule(string, optional, default: "'nonzero'") — Can be 'nonzero' (default when not set) or 'evenodd'
Returns
isRect(): boolean
Inherited from module:AWT.Shape#isRect
Overrides: module:AWT.Shape#isRect
Shorthand method for determining if a Shape is an Rectangle
Returns
boolean
toString(): string
Inherited from module:AWT.Shape#toString
Overrides: module:AWT.Shape#toString
Overwrites the original 'Object.toString' method with a more descriptive text
Returns
string
Static Methods
buildShape(data: object): module:AWT.Shape
Inherited from module:AWT.Shape
Builds a shape based on the provided data object.
Data should contain a 'type' member, specifying the type of shape requested ('rect', 'ellipse', 'rectangle' or 'path')
Parameters
data(object) — Specific data for this shape
Returns
Instance Fields
type: string
Overrides: module:AWT.Shape#type
Shape type id
strokes: Array.<module:AWT.PathStroke>
The strokes forming this Path.
enclosing: module:AWT.Rectangle
The Rectangle enclosing this Path (when drawing, this Rectangle don't include border width!)
enclosingPoints: Array.<module:AWT.Point>
Set of vertexs of a polygon close to the real path of this shape
pos: module:AWT.Point
Inherited from module:AWT.Shape#pos
Overrides: module:AWT.Shape#pos
The current position of the shape