Skip to content
Jesper Sørensen edited this page Sep 7, 2014 · 1 revision

Class: Circle

Circle

A class which is used for handling circles

new Circle(x, y, radius, fillStyle, strokeStyle, lineWidth)

Constructor for Circle class, uses the set function, to set the properties of the circle.

Parameters:
Name Type Argument Default Description
x number

The x-coordinate for the center of the circle

y number

The y-coordinate for the center of the circle

radius number

The radius for the circle

fillStyle string <optional>
"#000"

The circle's fill color if added to a view (css color string)

strokeStyle string <optional>
"#000"

The circle's color if added to a view (css color string)

lineWidth number <optional>
1

The circle's width if added to a view (in px)

Properties:
Name Type Description
x number

The circle's horizontal position

y number

The circle's vertical position

radius number

The circle's radius

strokeStyle string

The circle's color if added to a view (css color string)

lineWidth number

The circle's width if added to a view (in px)

fillStyle string

The circle's fill color if added to a view (css color string)

Source:

Extends

Methods

animate(properties, options)(properties, options)

Used for animating numeric properties of the owner of the function. Available easing functions are: "linear" "quadIn" "quadOut" "quadInOut" "powerIn" "powerOut" "powerInOut" "sinusInOut"

Parameters:
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:

ChildInitWithoutRedrawRegions()()

Inherited From:
Source:

CircleInitWithoutRedrawRegions()

Source:

contains(object) → {boolean}(object) → {boolean}

Checks whether or not the Circle contains another geometric object.

Parameters:
Name Type Description
object Math.Vector | Math.Line | Math.Circle | Math.Rectangle | Math.Polygon

A geometric object to check

Inherited From:
Source:
Returns:

True if the Rectangle contains the checked object, false if not

Type
boolean

copy() → {Math.Circle}() → {Math.Circle}

Copies the Circle object.

Inherited From:
Source:
Returns:

A copy of the Circle object (which can be modified without changing the original object)

Type
Math.Circle

getAnimations() → {Object[]}() → {Object[]}

Fetches all current animations of the object.

Inherited From:
Source:
Returns:

An array of all the current animations of the object

Type
Object[]

getArea() → {number}() → {number}

Calculates the area of the Circle.

Inherited From:
Source:
Returns:

The area of the Circle

Type
number

getDirectionTo(child) → {number}(child) → {number}

Calculates the direction to another child

Parameters:
Name Type Description
child View.Child

The object to calculate the direction to

Inherited From:
Source:
Returns:

The direction in radians

Type
number

getDistance(object) → {number}(object) → {number}

Calculates the shortest distance from the Circle object to another geometric object

Parameters:
Name Type Description
object Math.Vector | Math.Line | Math.Circle | Math.Rectangle | Math.Polygon

The object to calculate the distance to

Inherited From:
Source:
Returns:

The distance

Type
number

getDistanceTo(child) → {number}(child) → {number}

Calculates the distance to another child (the distance between the object's positions)

Parameters:
Name Type Description
child View.Child

The object to calculate the distance to

Inherited From:
Source:
Returns:

The distance in pixels

Type
number

getParents() → {View.Container[]}() → {View.Container[]}

Creates and returns and array of all the child's parents (from closest to farthest)

Inherited From:
Source:
Returns:

A list of all the child's parents

Type
View.Container[]

getPerimeter() → {number}() → {number}

Calculates the perimeter of the circle

Inherited From:
Source:
Returns:

The perimeter of the Circle

Type
number

<private> getRedrawRegion() → {Math.Rectangle}

Calculates the region which the object will fill out when redrawn.

Source:
Returns:

The bounding rectangle of the redraw

Type
Math.Rectangle

getRoom() → {View.Room|Boolean}() → {View.Room|Boolean}

Finds the room to which the object is currently added

Inherited From:
Source:
Returns:

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:
Returns:

The objects position in its room, or false if the object is not placed in any room.

Type
Math.Vector | Boolean

intersects(object) → {boolean}(object) → {boolean}

Checks whether or not the Circle intersects with another geometric object.

Parameters:
Name Type Description
object Math.Line | Math.Circle | Math.Rectangle | Math.Polygon

A geometric object to check. Supported objects are

Inherited From:
Source:
Returns:

True if the Circle intersects with the checked object, false if not

Type
boolean

isAnimated() → {boolean}() → {boolean}

Checks if the object is currently being animated.

Inherited From:
Source:
Returns:

Whether or not the object is being animated

Type
boolean

isDrawn() → {Boolean}() → {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:
Returns:

Whether or not the child object is in a state where it will get drawn

Type
Boolean

isInVisibleRoom() → {Boolean}() → {Boolean}

Checks if the child object is inside a room that is currently visible

Inherited From:
Source:
Returns:

Whether or not the child object is currently in a visible room

Type
Boolean

isVisible() → {boolean}() → {boolean}

Checks if the objects is visible. This function runs before each draw to ensure that it is necessary

Inherited From:
Source:
Returns:

Whether or not the object is visible (based on its size and opacity vars)

Type
boolean

move(x, y) → {Math.Circle}(x, y) → {Math.Circle}

Moves the Circle by adding a value to its x-coordinate and another value to its y-coordinate.

Parameters:
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:
Returns:

The resulting Circle object (itself)

Type
Math.Circle

moveTo(x, y)(x, y)

Sets the position of the object relative to its parent

Parameters:
Name Type Description
x number

The horisontal position

y number

The vertical position

Inherited From:
Source:

moveTo(x, y) → {Math.Circle}(x, y) → {Math.Circle}

Moves the Circle to a fixed position by setting its x- and y-coordinates.

Parameters:
Name Type Description
x number

The x-coordinate of the position to move the Circle to

y number

The y-coordinate of the position to move the Circle to

Inherited From:
Source:
Returns:

The resulting Circle object (itself)

Type
Math.Circle

parseOffsetGlobal(offset) → {Math.Vector}(offset) → {Math.Vector}

Parses an offset global into an actual Math.Vector offset (this function is only here for convenience and should be replaced by any class that inherits the child class)

Parameters:
Name Type Description
offset number

Offset global (OFFSET_TOP_LEFT, etc.)

Inherited From:
Source:
Returns:

A parsed version of the offset global

Type
Math.Vector

propertyIsAnimated() → {boolean}() → {boolean}

Checks if a specific property is current being animated

Inherited From:
Source:
Returns:

Whether or not the property is being animated

Type
boolean

scale(factor) → {Math.Circle}(factor) → {Math.Circle}

Scales the Circle object by multiplying it radius with a factor. Please notice that, opposite to the Polygon and Line objects, the position of the Circle will not be changed by scaling it, since the center of the circle will not be scaled. Also: since ellipses are not supported yet, circles cannot be scaled with various factors horizontally and vertically, like the other geometric objects.

Parameters:
Name Type Description
factor number

A factor with which to scale the Circle

Inherited From:
Source:
Returns:

The resulting Circle object (itself)

Type
Math.Circle

set(x, y, radius) → {Math.Circle}(x, y, radius) → {Math.Circle}

Sets the properties of the circle.

Parameters:
Name Type Description
x number

The x-coordinate for the center of the circle

y number

The y-coordinate for the center of the circle

radius number

The radius for the circle

Inherited From:
Source:
Returns:

The resulting Circle object (itself)

Type
Math.Circle

stopAnimations()()

Stops all current animations of the object.

Inherited From:
Source:

Generated with wicked.
Clone this wiki locally