Stay organized with collections
Save and categorize content based on your preferences.
blockly > utils > Coordinate
utils.Coordinate class
Class for representing coordinates and positions.
Signature:
export declare class Coordinate
Constructors
Constructor |
Modifiers |
Description |
(constructor)(x, y) |
|
Constructs a new instance of the Coordinate class |
Properties
Property |
Modifiers |
Type |
Description |
x |
|
number |
|
y |
|
number |
|
Methods
Method |
Modifiers |
Description |
clone() |
|
Creates a new copy of this coordinate. |
difference(a, b) |
static |
Returns the difference between two coordinates as a new Coordinate. |
distance(a, b) |
static |
Returns the distance between two coordinates. |
equals(a, b) |
static |
Compares coordinates for equality. |
magnitude(a) |
static |
Returns the magnitude of a coordinate. |
scale(s) |
|
Scales this coordinate by the given scale factor. |
sum(a, b) |
static |
Returns the sum of two coordinates as a new Coordinate. |
translate(tx, ty) |
|
Translates this coordinate by the given offsets. respectively. |
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-09-18 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-09-18 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eutils.Coordinate\u003c/code\u003e class represents coordinates and positions using x and y properties.\u003c/p\u003e\n"],["\u003cp\u003eIt provides methods for creating, comparing, and manipulating coordinates, such as cloning, calculating distances, and scaling.\u003c/p\u003e\n"],["\u003cp\u003eStatic methods like \u003ccode\u003edifference\u003c/code\u003e, \u003ccode\u003edistance\u003c/code\u003e, \u003ccode\u003eequals\u003c/code\u003e, \u003ccode\u003emagnitude\u003c/code\u003e, and \u003ccode\u003esum\u003c/code\u003e operate on two coordinates.\u003c/p\u003e\n"],["\u003cp\u003eInstance methods like \u003ccode\u003eclone\u003c/code\u003e, \u003ccode\u003escale\u003c/code\u003e, and \u003ccode\u003etranslate\u003c/code\u003e modify the coordinate object itself.\u003c/p\u003e\n"]]],[],null,["[blockly](./blockly.md) \\\u003e [utils](./blockly.utils_namespace.md) \\\u003e [Coordinate](./blockly.utils_namespace.coordinate_class.md)\n\nutils.Coordinate class\n----------------------\n\nClass for representing coordinates and positions.\n\n**Signature:** \n\n export declare class Coordinate \n\nConstructors\n------------\n\n| Constructor | Modifiers | Description |\n|--------------------------------------------------------------------------------------------------|-----------|-----------------------------------------------------|\n| [(constructor)(x, y)](./blockly.utils_namespace.coordinate_class._constructor__1_constructor.md) | | Constructs a new instance of the `Coordinate` class |\n\nProperties\n----------\n\n| Property | Modifiers | Type | Description |\n|---------------------------------------------------------------|-----------|--------|-------------|\n| [x](./blockly.utils_namespace.coordinate_class.x_property.md) | | number | |\n| [y](./blockly.utils_namespace.coordinate_class.y_property.md) | | number | |\n\nMethods\n-------\n\n| Method | Modifiers | Description |\n|---------------------------------------------------------------------------------------|-----------|---------------------------------------------------------------------|\n| [clone()](./blockly.utils_namespace.coordinate_class.clone_1_method.md) | | Creates a new copy of this coordinate. |\n| [difference(a, b)](./blockly.utils_namespace.coordinate_class.difference_1_method.md) | `static` | Returns the difference between two coordinates as a new Coordinate. |\n| [distance(a, b)](./blockly.utils_namespace.coordinate_class.distance_1_method.md) | `static` | Returns the distance between two coordinates. |\n| [equals(a, b)](./blockly.utils_namespace.coordinate_class.equals_1_method.md) | `static` | Compares coordinates for equality. |\n| [magnitude(a)](./blockly.utils_namespace.coordinate_class.magnitude_1_method.md) | `static` | Returns the magnitude of a coordinate. |\n| [scale(s)](./blockly.utils_namespace.coordinate_class.scale_1_method.md) | | Scales this coordinate by the given scale factor. |\n| [sum(a, b)](./blockly.utils_namespace.coordinate_class.sum_1_method.md) | `static` | Returns the sum of two coordinates as a new Coordinate. |\n| [translate(tx, ty)](./blockly.utils_namespace.coordinate_class.translate_1_method.md) | | Translates this coordinate by the given offsets. respectively. |"]]