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

46 lines
934 B
Text
Raw Normal View History

2022-09-21 17:41:39 +02:00
---
title: Point.addText()
---
The `Point.addText()` method adds text on a Point. Under the hood, this will
call `Point.attr()` as text is added by setting 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.addText(
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.addText(), compare this to [Point.setText](/reference/api/point/settext)">
2022-09-21 17:41:39 +02:00
```js
({ Point, points, Path, paths, part }) => {
2022-09-21 17:41:39 +02:00
points.anchor = new Point(100, 25)
.addText('FreeSewing')
.addText('rocks')
// Avoid the text getting cropped
paths.hidden = new Path()
.move(points.anchor)
.line(points.anchor.shift(0, 80))
.addClass('hidden')
2024-09-29 07:14:59 +02:00
return part
}
2022-09-21 17:41:39 +02:00
```
</Example>
## Notes
2022-09-21 17:41:39 +02:00
Remember to [use translation keys, not text](/guides/best-practices#use-translation-keys)