Blockly.utils. Coordinate
Class for representing coordinates and positions.
Constructor
Coordinate
new Coordinate(x, y)
Parameter |
|
---|---|
x |
Left. |
y |
Top. |
Properties
x
number
X-value
y
number
Y-value
Methods
difference
difference(a, b) returns Blockly.utils.Coordinate
Returns the difference between two coordinates as a new Coordinate.
Parameter |
|
---|---|
a |
(non-null Blockly.utils.Coordinate or non-null SVGPoint) An x/y coordinate. |
b |
(non-null Blockly.utils.Coordinate or non-null SVGPoint) An x/y coordinate. |
- Returns
-
non-null Blockly.utils.Coordinate
A Coordinate representing the difference betweena
andb
.
distance
distance(a, b) returns number
Returns the distance between two coordinates.
Parameter |
|
---|---|
a |
A Coordinate. Value must not be null. |
b |
A Coordinate. Value must not be null. |
- Returns
-
number
The distance betweena
andb
.
equals
equals(a, b) returns boolean
Compares coordinates for equality.
Parameter |
|
---|---|
a |
A Coordinate. Value may be null. |
b |
A Coordinate. Value may be null. |
- Returns
-
boolean
True iff the coordinates are equal, or if both are null.
magnitude
magnitude(a) returns number
Returns the magnitude of a coordinate.
Parameter |
|
---|---|
a |
A Coordinate. Value must not be null. |
- Returns
-
number
The distance between the origin anda
.
sum
sum(a, b) returns Blockly.utils.Coordinate
Returns the sum of two coordinates as a new Coordinate.
Parameter |
|
---|---|
a |
(non-null Blockly.utils.Coordinate or non-null SVGPoint) An x/y coordinate. |
b |
(non-null Blockly.utils.Coordinate or non-null SVGPoint) An x/y coordinate. |
- Returns
-
non-null Blockly.utils.Coordinate
A Coordinate representing the sum of the two coordinates.
clone
clone() returns Blockly.utils.Coordinate
Creates a new copy of this coordinate.
- Returns
-
non-null Blockly.utils.Coordinate
A copy of this coordinate.
scale
scale(s) returns Blockly.utils.Coordinate
Scales this coordinate by the given scale factor.
Parameter |
|
---|---|
s |
number The scale factor to use for both x and y dimensions. |
- Returns
-
non-null Blockly.utils.Coordinate
This coordinate after scaling.
translate
translate(tx, ty) returns Blockly.utils.Coordinate
Translates this coordinate by the given offsets. respectively.
Parameter |
|
---|---|
tx |
number The value to translate x by. |
ty |
number The value to translate y by. |
- Returns
-
non-null Blockly.utils.Coordinate
This coordinate after translating.