Stay organized with collections
Save and categorize content based on your preferences.
blockly > utils > Coordinate > translate
utils.Coordinate.translate() method
Translates this coordinate by the given offsets. respectively.
Signature:
translate(tx: number, ty: number): Coordinate;
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.
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.translate()\u003c/code\u003e method modifies a coordinate by adding specified horizontal (tx) and vertical (ty) offsets.\u003c/p\u003e\n"],["\u003cp\u003eThis method accepts two numeric arguments: \u003ccode\u003etx\u003c/code\u003e for horizontal translation and \u003ccode\u003ety\u003c/code\u003e for vertical translation.\u003c/p\u003e\n"],["\u003cp\u003eIt returns the updated \u003ccode\u003eCoordinate\u003c/code\u003e object after applying the translations.\u003c/p\u003e\n"]]],["The `translate()` method within the `Coordinate` class shifts a coordinate's position. It accepts two numerical parameters: `tx` and `ty`. `tx` determines the horizontal shift, while `ty` dictates the vertical shift. The method then returns a new `Coordinate` object reflecting the translated position. This effectively modifies the coordinate by the specified x and y offsets.\n"],null,["[blockly](./blockly.md) \\\u003e [utils](./blockly.utils_namespace.md) \\\u003e [Coordinate](./blockly.utils_namespace.coordinate_class.md) \\\u003e [translate](./blockly.utils_namespace.coordinate_class.translate_1_method.md)\n\nutils.Coordinate.translate() method\n-----------------------------------\n\nTranslates this coordinate by the given offsets. respectively.\n\n**Signature:** \n\n translate(tx: number, ty: number): Coordinate;\n\nParameters\n----------\n\n| Parameter | Type | Description |\n|-----------|--------|------------------------------|\n| tx | number | The value to translate x by. |\n| ty | number | The value to translate y by. |\n\n**Returns:**\n\n[Coordinate](./blockly.utils_namespace.coordinate_class.md)\n\nThis coordinate after translating."]]