Constructor
new Path(strokes)
Path constructor
Name | Type | Description |
---|---|---|
strokes | Array.<module:AWT.PathStroke> | The array of |
Extends
Members
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
- Array.<module:AWT.Point>
pos :module:AWT.Point
The current position of the shape
- Overrides
strokes :Array.<module:AWT.PathStroke>
The strokes forming this Path.
- Array.<module:AWT.PathStroke>
type :string
Shape type id
- string
- Overrides
Methods
addStroke(stroke)
Adds a module:AWT.PathStroke
to strokes
Name | Type | Description |
---|---|---|
stroke | module:AWT. |
calcEnclosingRect() → {module:AWT.Rectangle}
Calculates the polygon and the rectangle that (approximately) encloses this shape
- Type:
- module:AWT.
Rectangle
clip(ctx, fillRuleopt) → {external:CanvasRenderingContext2D}
Creates a clipping region on the specified HTML canvas 2D rendering context
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
ctx | external:CanvasRenderingContext2D | The rendering context | ||
fillRule | string | <optional> | 'nonzero' | Can be 'nonzero' (default when not set) or 'evenodd' |
- Overrides
- The provided rendering context
contains(_p) → {boolean}
Checks if the provided module:AWT.Point
is inside this shape.
Name | Type | Description |
---|---|---|
_p | module:AWT. | The point to check |
- Overrides
- Type:
- boolean
equals(p) → {boolean}
Checks if two shapes are equivalent.
Name | Type | Description |
---|---|---|
p | module:AWT. | The Shape to compare against |
- Overrides
- Type:
- boolean
fill(ctx, dirtyRegionopt) → {external:CanvasRenderingContext2D}
Fills the Shape with the current style in the provided HTML canvas context
Name | Type | Attributes | Description |
---|---|---|---|
ctx | external:CanvasRenderingContext2D | The canvas 2D rendering context where to fill this shape. | |
dirtyRegion | module:AWT. | <optional> | The context region to be updated. Used as clipping |
- Overrides
- The provided rendering context
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.
- The resulting object, with minimal attrributes
- Type:
- object
getBounds() → {module:AWT.Rectangle}
Gets the enclosing Rectangle
of this Shape.
- Overrides
- Type:
- module:AWT.
Rectangle
getShape(rect) → {module:AWT.Shape}
Gets a clone of this shape moved to the pos
component of the rectangle and scaled
by its dim
value.
Name | Type | Description |
---|---|---|
rect | module:AWT. | The rectangle to be taken as a base for moving and scaling |
- Overrides
- Type:
- module:AWT.
Shape
intersects(_r) → {boolean}
Checks if the provided Rectangle
r
intersects with this shape.
Name | Type | Description |
---|---|---|
_r | module:AWT. |
- Overrides
- Type:
- boolean
isRect() → {boolean}
Shorthand method for determining if a Shape is an Rectangle
- Overrides
- Type:
- boolean
moveBy(delta) → {module:AWT.Shape}
Shifts the shape a specified amount in horizontal and vertical directions
Name | Type | Description |
---|---|---|
delta | Point | | The amount to shift the Shape |
- Overrides
- Type:
- module:AWT.
Shape
moveTo(newPos) → {module:AWT.Shape}
Moves this shape to a new position
Name | Type | Description |
---|---|---|
newPos | module:AWT. | The new position of the shape |
- Overrides
- Type:
- module:AWT.
Shape
preparePath(ctx) → {external:CanvasRenderingContext2D}
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.
Name | Type | Description |
---|---|---|
ctx | external:CanvasRenderingContext2D |
- Overrides
- The provided rendering context
scaleBy(_delta) → {module:AWT.Shape}
Multiplies the dimension of the Shape by the specified delta
amount.
Name | Type | Description |
---|---|---|
_delta | Point | | Object containing the X and Y ratio to be scaled. |
- Overrides
- Type:
- module:AWT.
Shape
setAttributes(data) → {module:AWT.Path}
Reads the properties of this Path from a data object
Name | Type | Description |
---|---|---|
data | object | The data object to be parsed |
- Overrides
- Type:
- module:AWT.
Path
stroke(ctx) → {external:CanvasRenderingContext2D}
Draws this shape in the provided HTML canvas 2D rendering context.
Name | Type | Description |
---|---|---|
ctx | external:CanvasRenderingContext2D | The canvas 2D rendering context where to draw the shape. |
- Overrides
- The provided rendering context
toString() → {string}
Overwrites the original 'Object.toString' method with a more descriptive text
- Overrides
- Type:
- string