Constructor
(abstract) new Shape(pos)
Shape constructor
Name | Type | Description |
---|---|---|
pos | module:AWT. | The top-left coordinates of this Shape |
Members
pos :module:AWT.Point
The current position of the shape
type :string
Shape type id
- string
type :string
The type of shape (Rectangle, ellipse, path...)
- string
Methods
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' |
- 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 |
- Type:
- boolean
equals(p) → {boolean}
Checks if two shapes are equivalent.
Name | Type | Description |
---|---|---|
p | module:AWT. | The Shape to compare against |
- 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 |
- The provided rendering context
getBounds() → {module:AWT.Rectangle}
Gets the enclosing Rectangle
of this Shape.
- 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 |
- Type:
- module:AWT.
Shape
intersects(_r) → {boolean}
Checks if the provided Rectangle
r
intersects with this shape.
Name | Type | Description |
---|---|---|
_r | module:AWT. |
- Type:
- boolean
isRect() → {boolean}
Shorthand method for determining if a Shape is an Rectangle
- 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 |
- 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 |
- 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 |
- 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. |
- Type:
- module:AWT.
Shape
setAttributes(data) → {module:AWT.Shape}
Reads the properties of this Shape from a data object
Name | Type | Description |
---|---|---|
data | object | The data object to be parsed |
- Type:
- module:AWT.
Shape
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. |
- The provided rendering context
toString() → {string}
Overwrites the original 'Object.toString' method with a more descriptive text
- Type:
- string
(static) buildShape(data) → {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')
Name | Type | Description |
---|---|---|
data | object | Specific data for this shape |
- Type:
- module:AWT.
Shape