Inherits from JavaScript Object
Location aphid.core


The NamespaceCore contains classes for core data types.

“Value Type” Classes

The classes below are “value type” classes in OpenAphid

A “value type” class acts the same as other JavaScript classes in most scenarios. The only difference is when passing an instance of a “value type” class to OpenAphid native objects.

Native objects only read the value represented by a “value type” class, without keeping a reference to the JavaScript object. This behavior makes these classes look like value types in other languages, but they are still normal classes.

Les’s use several examples to illustrate the characteristic of “value type” classes.

Example 1

Attributes of native objects always return a new instance of “value type” classes.

var node = new aphid.g2d.Node();
var p = new aphid.core.Point(100, 100);
node.position = p;

var checkSame = (node.position == p);

checkSame is false as node.position returns a new instance of Point.

It’s always wrong to test equality of two “value type” objects by using the == operator. Please use the corresponding .equals() function of each class, like Point.equals for comparing two points.

Example 2

Attributes of native objects don’t keep custom attributes for “value type” classes.

var node = new aphid.g2d.Node();
var p = new aphid.core.Point(100, 100);
p.customValue = 100;
node.position = p;

var value  = node.position.customValue;

value is undefined as node.position only reads the x and y values of the point without keeping a reference to it.

Notes: “Value type” classes behave like value types when they are used on OpenAphid native objects. They are still ordinary JavaScript classes in other scenarios. Please don’t take them as primitive types like string or number in JavaScript.

Overview of Tasks


  • Type
  • AffineTransformation Constructor
  • Color Constructor
  • Point Constructor
  • Rect Constructor
  • Size Constructor
  • Vector2 Constructor
  • Vector3 Constructor
  • Writability
  • readonly
  • readonly
  • readonly
  • readonly
  • readonly
  • readonly
  • readonly



readonly AffineTransformation Constructor


Non-null readonly Color Constructor


Non-null readonly Point Constructor


Non-null readonly Rect Constructor


Non-null readonly Size Constructor


Non-null readonly Vector2 Constructor


Non-null readonly Vector3 Constructor