Class: Coordinate
Defined in: packages/blockly/core/utils/coordinate.ts:19
Class for representing coordinates and positions.
Properties index
| Property | Description |
|---|---|
| x | Left. |
| y | Top. |
Methods index
| Method | Description |
|---|---|
| clone | Creates a new copy of this coordinate. |
| scale | Scales this coordinate by the given scale factor. |
| translate | Translates this coordinate by the given offsets. respectively. |
| equals | Compares coordinates for equality. |
| distance | Returns the distance between two coordinates. |
| magnitude | Returns the magnitude of a coordinate. |
| difference | Returns the difference between two coordinates as a new Coordinate. |
| sum | Returns the sum of two coordinates as a new Coordinate. |
Constructors
Constructor
new Coordinate(x, y): Coordinate;
Defined in: packages/blockly/core/utils/coordinate.ts:24
Parameters
| Parameter | Type | Description |
|---|---|---|
x | number | Left. |
y | number | Top. |
Returns
Coordinate
Properties
x
x: number;
Defined in: packages/blockly/core/utils/coordinate.ts:25
Left.
y
y: number;
Defined in: packages/blockly/core/utils/coordinate.ts:26
Top.
Methods
clone()
clone(): Coordinate;
Defined in: packages/blockly/core/utils/coordinate.ts:34
Creates a new copy of this coordinate.
Returns
Coordinate
A copy of this coordinate.
scale()
scale(s): Coordinate;
Defined in: packages/blockly/core/utils/coordinate.ts:44
Scales this coordinate by the given scale factor.
Parameters
| Parameter | Type | Description |
|---|---|---|
s | number | The scale factor to use for both x and y dimensions. |
Returns
Coordinate
This coordinate after scaling.
translate()
translate(tx, ty): Coordinate;
Defined in: packages/blockly/core/utils/coordinate.ts:58
Translates this coordinate by the given offsets. respectively.
Parameters
| Parameter | Type | Description |
|---|---|---|
tx | number | The value to translate x by. |
ty | number | The value to translate y by. |
Returns
Coordinate
This coordinate after translating.
equals()
static equals(a?, b?): boolean;
Defined in: packages/blockly/core/utils/coordinate.ts:71
Compares coordinates for equality.
Parameters
| Parameter | Type | Description |
|---|---|---|
a? | Coordinate | null | A Coordinate. |
b? | Coordinate | null | A Coordinate. |
Returns
boolean
True iff the coordinates are equal, or if both are null.
distance()
static distance(a, b): number;
Defined in: packages/blockly/core/utils/coordinate.ts:88
Returns the distance between two coordinates.
Parameters
| Parameter | Type | Description |
|---|---|---|
a | Coordinate | A Coordinate. |
b | Coordinate | A Coordinate. |
Returns
number
The distance between a and b.
magnitude()
static magnitude(a): number;
Defined in: packages/blockly/core/utils/coordinate.ts:100
Returns the magnitude of a coordinate.
Parameters
| Parameter | Type | Description |
|---|---|---|
a | Coordinate | A Coordinate. |
Returns
number
The distance between the origin and a.
difference()
static difference(a, b): Coordinate;
Defined in: packages/blockly/core/utils/coordinate.ts:112
Returns the difference between two coordinates as a new Coordinate.
Parameters
| Parameter | Type | Description |
|---|---|---|
a | Coordinate | DOMPoint | An x/y coordinate. |
b | Coordinate | DOMPoint | An x/y coordinate. |
Returns
Coordinate
A Coordinate representing the difference between a and b.
sum()
static sum(a, b): Coordinate;
Defined in: packages/blockly/core/utils/coordinate.ts:126
Returns the sum of two coordinates as a new Coordinate.
Parameters
| Parameter | Type | Description |
|---|---|---|
a | Coordinate | DOMPoint | An x/y coordinate. |
b | Coordinate | DOMPoint | An x/y coordinate. |
Returns
Coordinate
A Coordinate representing the sum of the two coordinates.