en:code:core:point
Point
This object represents a point in a 2D space.
Functions
Point
Constructor function.
Syntax
var myObject = new Point();
var myObject = new Point(otherPoint);
var myObject = new Point(x, y);
Arguments
- otherPoint - (Point) other Point to copy
- x - (integer) x coordinate of the Point
- y - (integer) y coordinate of the Point
Exceptions
- (ParameterTypeError) incorrect parameter type
- (ParameterCountError) incorrect parameter count
Example
Create a Point representing the (0;0) point.
var myObject = new Point();
Create a Point representing a copy of otherPoint.
var myObject = new Point(otherPoint);
Create a Point representing the (50;75) point.
var myObject = new Point(50, 75);
Methods
clone
Returns a copy of this Point.
Syntax
myObject.clone();
Returns
- (Point) a copy of this Point
Example
var copyOfMyObject = myObject.clone();
equals
Returns true if this Point and another are referencing the same point.
Syntax
myObject.equals(other);
Arguments
- other - (Point) another Point
Returns
- (bool) true if other is referencing the same point
Example
if(myFirstObject.equals(mySecondObject)) //Do something
toString
Returns a string representing this Point.
Syntax
myObject.toString();
Returns
- (string) a string representing this Point
Example
Console.print(myObject.toString());
Notes
This method is automatically called when trying to convert a Point to a string.
setX
Sets the x coordinate of this Point.
Syntax
myObject.setX(x);
Arguments
- x - (integer) x coordinate
Returns
- (Point) this Point
setY
Sets the y coordinate of this Point.
Syntax
myObject.setY(y);
Arguments
- y - (integer) y coordinate
Returns
- (Point) this Point
x
Returns the x coordinate of this Point.
Syntax
myObject.x(); //if that doesn't work, try without parentheses: myObject.x;
Returns
- (integer) the x coordinate of this Point
y
Returns the y coordinate of this Point.
Syntax
myObject.y(); //if that doesn't work, try without parentheses: myObject.y;
Returns
- (integer) the y coordinate of this Point
Attributes
x
The x coordinate of this Point. (integer)
Example
myObject.x = 50; Console.print(myObject.x);
y
The y coordinate of this Point. (integer)
Example
myObject.y = 50; Console.print(myObject.y);
en/code/core/point.txt · Last modified: 2021/02/13 11:23 by 127.0.0.1