-
Notifications
You must be signed in to change notification settings - Fork 0
View.Rectangle.API
A class which is used for drawable non-rotated rectangles
The constructor for the Rectangle class. Uses the set-function to set the properties of the rectangle.
Name | Type | Argument | Default | Description |
---|---|---|---|---|
x |
number | The x-coordinate for the rectangle's top left corner |
||
y |
number | The y-coordinate for the rectangle's top left corner |
||
width |
number |
<optional> |
0 | The width of the rectangle |
height |
number |
<optional> |
0 | The height of the rectangle |
fillStyle |
string |
<optional> |
"#000" | The rectangle's fill color if added to a view (css color string) |
strokeStyle |
string |
<optional> |
"#000" | The rectangle's color if added to a view (css color string) |
lineWidth |
number |
<optional> |
1 | The rectangle's width if added to a view (in px) |
- Source:
Name | Type | Description |
---|---|---|
x |
number | The top left corner's x-coordinate |
y |
number | The top left corner's y-coordinate |
width |
number | The width of the rectangle |
height |
number | The height of the rectangle |
strokeStyle |
string | The rectangle's color if added to a view (css color string) |
lineWidth |
number | The rectangle's width if added to a view (in px) |
fillStyle |
string | The rectangle's fill color if added to a view (css color string) |
-
add(vector) → {Math.Vector}(vector) → {Math.Vector}
-
Adds another vector to the Vector. Can by used for the same purpose as move, but takes a vector as argument.
Name Type Description vector
Math.Vector A vector to add to the Vector
- Inherited From:
- Source:
The resulting Vector object (itself)
- Type
- Math.Vector
-
Used for animating numeric properties of the owner of the function. Available easing functions are: "linear" "quadIn" "quadOut" "quadInOut" "powerIn" "powerOut" "powerInOut" "sinusInOut"
Name Type Description properties
object An object containing key-value pairs in the following format:
{ "[property name]": "[end value]" }
options
object An object containing key-value pairs for the animation's option:
{ "duraton": "[animation duration (in ms)]", "callback": "[callback function]", "easing": "[easing function to use]" }
- Inherited From:
- Source:
-
- Inherited From:
- Source:
-
Checks whether or not the Rectangle contains another geometric object.
Name Type Description object
Math.Vector | Math.Line | Math.Circle | Math.Rectangle | Math.Polygon A geometric object to check
- Inherited From:
- Source:
True if the Rectangle contains the checked object, false if not
- Type
- boolean
-
copy() → {Math.Rectangle}() → {Math.Rectangle}
-
Copies the Rectangle object
- Inherited From:
- Source:
A copy of the Rectangle object (which can be modified without changing the original object)
- Type
- Math.Rectangle
-
divide(vector) → {Math.Vector}(vector) → {Math.Vector}
-
Divides the Vector with another vector.
Name Type Description vector
Math.Vector A vector to divide the Vector with
- Inherited From:
- Source:
The resulting Vector object (itself)
- Type
- Math.Vector
-
Fetches all current animations of the object.
- Inherited From:
- Source:
An array of all the current animations of the object
- Type
- Object[]
-
Calculates the area of the Rectangle.
- Inherited From:
- Source:
The area of the Rectangle
- Type
- number
-
getBoundingRectangle(rectangle) → {Math.Rectangle}(rectangle) → {Math.Rectangle}
-
Calculates the bounding rectangle of the of the two rectangles
Name Type Description rectangle
Math.Rectangle The rectangle to use for the calculation
- Inherited From:
- Source:
The bounding rectangle for the two rectangles
- Type
- Math.Rectangle
-
Calculates the cross product of the Vector and another vector
Name Type Description vector
Math.Vector The vector to use for the calculation
- Inherited From:
- Source:
The cross product
- Type
- number
-
Calculates the diagonal length of the Rectangle
- Inherited From:
- Source:
The diagonal length of the Rectangle
- Type
- number
-
Calculates the direction of the Vector
- Inherited From:
- Source:
The vector's direction (in radians)
- Type
- number
-
Calculates the direction to another child
Name Type Description child
View.Child The object to calculate the direction to
- Inherited From:
- Source:
The direction in radians
- Type
- number
-
Calculates the direction to another Vector
Name Type Description point
Math.Vector A Vector to calculate the direction to
- Inherited From:
- Source:
The direction to the object
- Type
- number
-
Calculates the shortest distance from the Rectangle object to another geometric object
Name Type Description object
Math.Vector | Math.Line | Math.Circle | Math.Rectangle | Math.Polygon The object to calculate the distance to
- Inherited From:
- Source:
The distance
- Type
- number
-
Calculates the distance to another child (the distance between the object's positions)
Name Type Description child
View.Child The object to calculate the distance to
- Inherited From:
- Source:
The distance in pixels
- Type
- number
-
Calculates the cross product of the Vector and another vector
Name Type Description vector
Math.Vector The vector to use for the calculation
- Inherited From:
- Source:
The dot product
- Type
- number
-
Calculates the length of the Vector
- Inherited From:
- Source:
The vector's length
- Type
- number
-
getOverlap(rectangle) → {Math.Rectangle|boolean}(rectangle) → {Math.Rectangle|boolean}
-
Calculates the overlapping area of the rectangle and another rectangle
Name Type Description rectangle
Math.Rectangle The rectangle to use for the operation
- Inherited From:
- Source:
The overlapping rectangle, or false if there is no overlap
- Type
- Math.Rectangle | boolean
-
Creates and returns and array of all the child's parents (from closest to farthest)
- Inherited From:
- Source:
A list of all the child's parents
- Type
- View.Container[]
-
Fetches the Rectangles points.
- Inherited From:
- Source:
Array of points, in the following order: top left corner, top right corner, bottom right corner, bottom left corner
- Type
- Math.Vector[]
-
Creates a polygon with the same points as the rectangle.
- Inherited From:
- Source:
The created Polygon object
- Type
- Object
-
Calculates the region which the object will fill out when redrawn.
- Source:
The bounding rectangle of the redraw
- Type
- Rectangle
-
Finds the room to which the object is currently added
- Inherited From:
- Source:
The room to which the object is currently added, or false if the object is not added to a room
- Type
- View.Room | Boolean
-
getRoomPosition() → {Math.Vector|Boolean}() → {Math.Vector|Boolean}
-
Fetches the position of the child inside the room
- Inherited From:
- Source:
The objects position in its room, or false if the object is not placed in any room.
- Type
- Math.Vector | Boolean
-
Checks whether or not the Rectangle intersects with another geometric object.
Name Type Description object
Math.Line | Math.Circle | Math.Rectangle | Math.Polygon A geometric object to check
- Inherited From:
- Source:
True if the Polygon intersects with the checked object, false if not
- Type
- boolean
-
Checks if the object is currently being animated.
- Inherited From:
- Source:
Whether or not the object is being animated
- Type
- boolean
-
Checks if the child object is in a state where it will get drawn. For this function to return true, the child object has to be both visible and placed in a visible room.
- Inherited From:
- Source:
Whether or not the child object is in a state where it will get drawn
- Type
- Boolean
-
Checks if the child object is inside a room that is currently visible
- Inherited From:
- Source:
Whether or not the child object is currently in a visible room
- Type
- Boolean
-
Checks if the objects is visible. This function runs before each draw to ensure that it is necessary
- Inherited From:
- Source:
Whether or not the object is visible (based on its size and opacity vars)
- Type
- boolean
-
move(x, y) → {Math.Rectangle}(x, y) → {Math.Rectangle}
-
Moves the Rectangle by adding a value to its x-coordinate and another value to its y-coordinate.
Name Type Description x
number The value to add to the x-coordinate (can be negative)
y
number The value to add to the y-coordinate (can be negative)
- Inherited From:
- Source:
The resulting Rectangle object (itself)
- Type
- Math.Rectangle
-
Sets the position of the object relative to its parent
Name Type Description x
number The horisontal position
y
number The vertical position
- Inherited From:
- Source:
-
moveTo(x, y) → {Math.Rectangle}(x, y) → {Math.Rectangle}
-
Moves the Rectangle to a fixed position by setting its x- and y-coordinates.
Name Type Description x
number The x-coordinate of the position to move the Rectangle to
y
number The y-coordinate of the position to move the Rectangle to
- Inherited From:
- Source:
The resulting Rectangle object (itself)
- Type
- Math.Rectangle
-
multiply(vector) → {Math.Vector}(vector) → {Math.Vector}
-
Multiplies the Vector with another vector.
Name Type Description vector
Math.Vector A vector to multiply the Vector with
- Inherited From:
- Source:
The resulting Vector object (itself)
- Type
- Math.Vector
-
parseOffsetGlobal(offset) → {Math.Vector}
-
Parses an offset global into an actual Math.Vector offset that fits the instance
Name Type Description offset
number Offset global (OFFSET_TOP_LEFT, etc.)
- Source:
The offset vector the offset global corresponds to for the instance
- Type
- Math.Vector
-
Checks if a specific property is current being animated
- Inherited From:
- Source:
Whether or not the property is being animated
- Type
- boolean
-
- Source:
-
rotate(direction) → {Math.Vector}(direction) → {Math.Vector}
-
Rotates the vector around the zero-vector.
Name Type Description direction
number The number of radians to rotate the vector
- Inherited From:
- Source:
The resulting Vector object (itself)
- Type
- Math.Vector
-
scale(scaleH, scaleV) → {Math.Rectangle}(scaleH, scaleV) → {Math.Rectangle}
-
Scales the Rectangle by multiplying the width and height values. Please notice that, opposed to the Polygon and Line objects, the position of the Rectangle will not be changed by scaling it, since the position of the top left corner will not be scaled.
Name Type Description scaleH
number A factor with which to scale the Rectangle horizontally. If scaleH is undefined, both width and height will be scaled after this factor
scaleV
number A factor with which to scale the Rectangle vertically
- Inherited From:
- Source:
The resulting Rectangle object (itself)
- Type
- Math.Rectangle
-
set(x, y, width, height) → {Math.Rectangle}(x, y, width, height) → {Math.Rectangle}
-
Sets the properties of the rectangle.
Name Type Description x
number The x-coordinate for the rectangle's top left corner
y
number The y-coordinate for the rectangle's top left corner
width
number The width of the rectangle
height
number The height of the rectangle
- Inherited From:
- Source:
The resulting Rectangle object (itself)
- Type
- Math.Rectangle
-
setFromDirection(direction, length) → {Math.Vector}(direction, length) → {Math.Vector}
-
Calculates and sets the vector from a direction and a length.
Name Type Description direction
number The direction (in radians)
length
number The length
- Inherited From:
- Source:
The resulting Vector object (itself)
- Type
- Math.Vector
-
setFromVectors(position, size) → {Math.Rectangle}(position, size) → {Math.Rectangle}
-
Sets the properties of the rectangle from two vectors: one representing the position of the top left corner, another representing the width and height of the rectangle.
Name Type Description position
Math.Vector A Vector representing the position of the top left corner to set for the Rectangle
size
Math.Vector A Vector representing the size (width and height) to set for the Rectangle
- Inherited From:
- Source:
The resulting Rectangle object (itself)
- Type
- Math.Rectangle
-
Stops all current animations of the object.
- Inherited From:
- Source:
-
subtract(vector) → {Math.Vector}(vector) → {Math.Vector}
-
Subtracts another vector from the Vector.
Name Type Description vector
Math.Vector A vector to subtract from the Vector
- Inherited From:
- Source:
The resulting Vector object (itself)
- Type
- Math.Vector
Generated with wicked.
- Engine.Camera
- Engine.CustomLoop
- Engine.Loader
- Engine.Room
- Engine
- Input.Keyboard
- Input.Pointer
- Math.Circle
- Math.Line
- Math.Polygon
- Math.Rectangle
- Math.Vector
- Sound.Effect
- Sound.Music
- View.Child
- View.Circle
- View.Collidable
- View.Container
- View.GameObject
- View.Line
- View.Polygon
- View.Rectangle
- View.Sprite
- View.TextBlock
- global