Ball
Extends:
The Ball class is a particle class used to draw round particles with the advantage that they can be labeled and displayed with a gradient, giving a more realistic feel to the particle.
Static Method Summary
Static Public Methods | ||
public static |
getChargeColor(charge: number): string Gets a color depending on the value a charge has. |
|
public static |
getChargeSign(charge: number): string Gets the sign a charge must have depending on the value a charge has. |
Constructor Summary
Public Constructor | ||
public |
constructor(r: number, opts: object) |
Member Summary
Public Members | ||
public |
Flag for enabling a gradient on the ball. |
|
public |
Flag for allowing the ball to be dragged around. |
|
public |
Spot for writing a label on the ball. |
|
public |
Radius of the ball in units. |
|
public |
Flag for allowing the ball to become a topmost object when its beging dragged, Default value is true. |
|
public |
Upper spot for writing a label on the bal.. |
Method Summary
Private Methods | ||
private |
draw() Main draw function for the ball called by the World automatically. |
|
private |
Tests if the mouse is over the ball. |
Inherited Summary
From class WorldElement | ||
public |
Sets the color in HEX format of the element. |
|
public |
Sets the cursor style when the mouse is over the element. |
|
public |
Flag for enabling or diabling this element. |
|
public |
Flag set when the element is being dragged around. |
|
public |
Sets the font of the element. |
|
public |
Sets the current height of the element. |
|
public |
Flag for allowing the element to be dragged around. |
|
public |
Sets the move style of the element. |
|
public |
Flag set when the mouse is over the element. |
|
public |
Sets a callback function for when the element is dragged around. |
|
public |
Sets the position of the element. |
|
public |
Sets the renderer used for the element. |
|
public |
Sets the rotation of the element. |
|
public |
A copy of the z-index value is stored here. |
|
public |
Sets the drawing scale of the element. |
|
public |
Flag for determining if the element will be a top-most element when dragged around. |
|
public |
Flag used to determine if an object is a child of WorldElement. |
|
public |
Sets the current width of the element. |
|
public |
Sets the world where this element is found. |
|
public |
Sets the z-index of the element. |
|
public |
addPosition(x: number, y: number) Adds the provided coordinates to the position. |
|
public |
Sets if the element is draggable. |
|
public |
Function called when the mouse moves to check if the pointer is over the element. |
|
public |
Sets the color in HEX format of the element. |
|
public |
setPosition(x: number, y: number) Sets the position of the element. |
|
public |
Sets the scale of the element. |
|
public |
Sets the z-index of the element. |
|
private |
resize() Function called when the canvas gets resized. |
|
private |
Sets the world object where element will be drawn. |
|
private |
Sets the element as a topmost element. |
Static Public Methods
public static getChargeColor(charge: number): string source
Gets a color depending on the value a charge has. If the charge is positive the color is COLORS.RED. If the charge is negative the color is COLORS.BLUE. If the charge is neutral the color is COLORS.GRAY.
Params:
Name | Type | Attribute | Description |
charge | number | Charge of the particle in coulombs. |
public static getChargeSign(charge: number): string source
Gets the sign a charge must have depending on the value a charge has. If the charge is positive the sign is "+". If the charge is negative the sign is "-". If the charge is neutral the sign is "".
Params:
Name | Type | Attribute | Description |
charge | number | Charge of the particle in coulombs. |
Public Constructors
public constructor(r: number, opts: object) source
Override:
WorldElement#constructorPublic Members
public gradient: boolean source
Flag for enabling a gradient on the ball. The color used for gradient is the one set in Ball.color. Default value is true.
public isDraggable: boolean source
Flag for allowing the ball to be dragged around. Default value is true.
Override:
WorldElement#isDraggablepublic lowerLabel: string source
Spot for writing a label on the ball. If the Ball.upperLabel is blank, then the lower label will be centered on the particle. If not, then it will be the lower label on the ball. Default value is "".
public topmostOnDrag: boolean source
Flag for allowing the ball to become a topmost object when its beging dragged, Default value is true.
Override:
WorldElement#topmostOnDragPrivate Methods
private isMouseOver(): boolean source
Tests if the mouse is over the ball.