1
0
Fork 0
freesewing/markdown/dev/reference/api/point/translate/en.md
Joost De Cock b34a2ee2ed feat: Flat import of markdown repo
This is a flat (without history) import of (some of) the content
from our markdown module.

We've imported this without history because the repo contains our
blog posts and showcases posts content prior to porting them to strapi.

Since this contains many images, it would balloon the size of this repo
to import the full history.

Instead, please refer to the history of the (archived) markdown repo
at: https://github.com/freesewing/markdown
2021-08-25 16:09:31 +02:00

45 lines
1,003 B
Markdown

---
title: translate()
---
```js
Point point.translate(float deltaX, float deltaY)
```
Returns a point with
[a translate transform](https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/translate)
applied.
In other words, this will:
- Add `deltaX` to the point's X-coordinate
- Add `deltaY` to the point's Y-coordinate
<Example
part="point_translate"
caption="An example of the Point.translate() method"
/>
```js
let { Point, points, Snippet, snippets, macro } = part.shorthand();
points.A = new Point(10, 10).attr("data-text", "Point A");
points.B = points.A.translate(120, 60)
.attr(
"data-text",
"Point B is point A with a\ntranslate(120, 60)\ntransform applied"
)
.attr("data-text-class", "right")
.attr("data-text-dy", -6)
.attr("data-text-lineheight", 6);
snippets.A = new Snippet("x", points.A);
snippets.B = new Snippet("x", points.B);
macro("ld", {
from: points.A,
to: points.B,
text: "translate(120,60)",
noStartMarker: true
});
```