This page describes all of the usable variables and functions inside of ComponentHandler.js, which handles everything component-related, including some JSON.
Component()A constructor that returns a basic JSON object in order to construct a component. new Component() returns the following:
{
active: true,
type: 0,
color: "#fff",
radius: 2
}
active: boolean: Sets the component state to be rendered or not.type: number: Sets the component type. There are predefined types, so please don’t use them.
1: Point2: Line3: Circle4: Rectangle5: Arc6: Ruler7: Label8: Shape9: PictureAll aspects of the Component part are modifiable by code by using <component type>.prototype = new Component() . Example of defining a component called VectorPoint:
function VectorPoint(x, y) {
Component.call(this);
this.type = 10;
this.x = 0;
this.y = 0;
if (
x != undefined &&
y != undefined
) {
this.x = x;
this.y = y;
}
}
VectorPoint.prototype = new Component();
VectorPoint.prototype.constructor = VectorPoint;
If you are using classes, then consider the following (TypeScript).
class VectorPoint extends Component {
x: number;
y: number;
constructor(x?: number, y?: number) {
super();
this.type = 10;
this.x = 0;
this.y = 0;
if (
x != undefined &&
y != undefined
) {
this.x = x;
this.y = y;
}
}
}
Both of them will return this:
{
active: true,
type: 10,
color: "#fff",
radius: 2,
x: 0,
y: 0
}
setActive(active: boolean): Sets a component’s active parameter.isActive(): Gets the current component’s active state.Point()