1
0
Fork 0
freesewing/sites/dev/docs/reference/api/point/settext/readme.mdx

48 lines
904 B
Text
Raw Normal View History

2022-09-21 17:41:39 +02:00
---
title: Point.setText()
---
The `Point.setText()` method sets text on a Point. Under the hood, this will
call `Point.attr()` as text is set via attributes. Refer to [Adding
text](/howtos/code/adding-text) for more details.
2022-09-21 17:41:39 +02:00
## Signature
2022-09-21 17:41:39 +02:00
```js
Point point.setText(
string text,
2022-09-21 17:41:39 +02:00
string className
)
```
2024-09-29 07:14:59 +02:00
:::tip
This method is chainable as it returns the `Point` object
:::
## Example
2022-09-21 17:41:39 +02:00
<Example caption="Examples of Point.setText(), compare this to [Point.setText()](/reference/api/point/settext)">
2022-09-21 17:41:39 +02:00
```js
({ Point, points, Path, paths, part }) => {
2024-09-29 07:14:59 +02:00
points.anchor = new Point(100, 25)
.setText('FreeSewing')
.setText('rocks')
2024-09-29 07:14:59 +02:00
// Avoid the text getting cropped
paths.hidden = new Path()
.move(points.anchor)
.line(points.anchor.shift(0, 80))
.addClass('hidden')
2022-09-21 17:41:39 +02:00
2024-09-29 07:14:59 +02:00
return part
2022-09-21 17:41:39 +02:00
}
2024-09-29 07:14:59 +02:00
2022-09-21 17:41:39 +02:00
```
</Example>
2022-09-21 17:41:39 +02:00
## Notes
Remember to [use translation keys, not text](/guides/best-practices#use-translation-keys)
2024-09-29 07:14:59 +02:00
```