Container
Extends: module:AWT.Rectangle
Source: AWT.js:1978
Logic object that takes care of an "invalidated" rectangle that will be repainted
at the next update of a 2D object, usually an HTML Canvas.
Container has the same constructor options as Rectangle
Constructor
new Container(
pos: Point | Rectangle | number | Array.<number>,
dim?: Dimension | number,
w?: number,
h?: number,
): ContainerContainer constructor
Parameters
pos(Point | Rectangle | number | Array.<number>)dim(Dimension | number, optional)w(number, optional)h(number, optional)
Instance Methods
invalidate(rect: module:AWT.Rectangle)
Adds the provided rectangle to the invalidated area.
Parameters
rect(module:AWT.Rectangle)
update()
Updates the invalidated area
updateContent(_dirtyRegion: module:AWT.Shape)
Containers should implement this method to update its graphic contents. It should
be called from module:AWT.Container#update
Parameters
_dirtyRegion(module:AWT.Shape) — Specifies the area to be updated. Whennull, it's the whole
Container.
getBounds(): module:AWT.Rectangle
Inherited from module:AWT.Rectangle#getBounds
Overrides: module:AWT.Rectangle#getBounds
Gets the enclosing Rectangle of this Shape.
Returns
setBounds(rect: module:AWT.Rectangle): module:AWT.Rectangle
Inherited from module:AWT.Rectangle#setBounds
Overrides: module:AWT.Rectangle#setBounds
Sets this Rectangle the position and dimension of another one
Parameters
rect(module:AWT.Rectangle)
Returns
equals(r: module:AWT.Shape): boolean
Inherited from module:AWT.Rectangle#equals
Overrides: module:AWT.Rectangle#equals
Checks if two shapes are equivalent.
Parameters
r(module:AWT.Shape) — The Shape to compare against
Returns
boolean
clone(): module:AWT.Rectangle
Inherited from module:AWT.Rectangle#clone
Overrides: module:AWT.Rectangle#clone
Clones this Rectangle
Returns
scaleBy(delta: Point | Dimension): module:AWT.Rectangle
Inherited from module:AWT.Rectangle#scaleBy
Overrides: module:AWT.Rectangle#scaleBy
Multiplies the dimension of the Shape by the specified delta amount.
Parameters
Returns
grow(dx: number, dy: number): module:AWT.Rectangle
Inherited from module:AWT.Rectangle#grow
Overrides: module:AWT.Rectangle#grow
Expands the boundaries of this shape. This affects the current position and dimension.
Parameters
dx(number) — The amount to grow (or decrease) in horizontal directiondy(number) — The amount to grow (or decrease) in vertical direction
Returns
getOppositeVertex(): module:AWT.Point
Inherited from module:AWT.Rectangle#getOppositeVertex
Overrides: module:AWT.Rectangle#getOppositeVertex
Gets the module:AWT.Point corresponding to the lower-right vertex of the Rectangle.
Returns
add(shape: module:AWT.Shape): module:AWT.Rectangle
Inherited from module:AWT.Rectangle#add
Overrides: module:AWT.Rectangle#add
Adds the boundaries of another shape to the current one
Parameters
shape(module:AWT.Shape) — The module:AWT.Shape to be added
Returns
getCoords(): string
Inherited from module:AWT.Rectangle#getCoords
Overrides: module:AWT.Rectangle#getCoords
Gets a string with the co-ordinates of the upper-left and lower-right vertexs of this rectangle,
(with values rounded to int)
Returns
string
getAttributes(): object
Inherited from module:AWT.Rectangle#getAttributes
Overrides: module:AWT.Rectangle#getAttributes
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.Rectangle
Inherited from module:AWT.Rectangle#setAttributes
Overrides: module:AWT.Rectangle#setAttributes
Reads the properties of this Rectangle 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.Rectangle#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.Rectangle#moveTo
Moves this shape to a new position
Parameters
newPos(module:AWT.Point) — The new position of the shape
Returns
getShape(rect: module:AWT.Rectangle): module:AWT.Shape
Inherited from module:AWT.Shape#getShape
Overrides: module:AWT.Rectangle#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.Rectangle#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.Rectangle#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.Rectangle#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.Rectangle#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.Rectangle#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.Rectangle#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.Rectangle#isRect
Shorthand method for determining if a Shape is an Rectangle
Returns
boolean
toString(): string
Inherited from module:AWT.Shape#toString
Overrides: module:AWT.Rectangle#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
invalidatedRect: module:AWT.Rectangle
The currently "invalidated" area
type: string
Inherited from module:AWT.Rectangle#type
Overrides: module:AWT.Rectangle#type
Shape type id
dim: module:AWT.Dimension
Inherited from module:AWT.Rectangle#dim
Overrides: module:AWT.Rectangle#dim
The Dimension of the Rectangle
pos: module:AWT.Point
Inherited from module:AWT.Shape#pos
Overrides: module:AWT.Rectangle#pos
The current position of the shape