2022-09-21 17:41:39 +02:00
|
|
|
---
|
|
|
|
title: Point.addText()
|
|
|
|
---
|
|
|
|
|
2022-09-27 19:15:57 +02:00
|
|
|
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
|
|
|
|
2022-09-27 19:15:57 +02:00
|
|
|
## Signature
|
2022-09-21 17:41:39 +02:00
|
|
|
|
|
|
|
```js
|
|
|
|
Point point.addText(
|
2022-12-30 07:47:29 -08:00
|
|
|
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
|
|
|
|
:::
|
2022-09-29 17:43:32 +02:00
|
|
|
|
2022-09-27 19:15:57 +02:00
|
|
|
## Example
|
2022-09-21 17:41:39 +02:00
|
|
|
|
2022-09-27 19:15:57 +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
|
2022-09-27 19:15:57 +02:00
|
|
|
({ Point, points, Path, paths, part }) => {
|
2022-09-21 17:41:39 +02:00
|
|
|
points.anchor = new Point(100, 25)
|
2022-09-27 19:15:57 +02:00
|
|
|
.addText('FreeSewing')
|
|
|
|
.addText('rocks')
|
|
|
|
|
2025-05-19 08:04:05 +02:00
|
|
|
// Avoid the text getting cropped
|
|
|
|
paths.hidden = new Path()
|
|
|
|
.move(points.anchor)
|
|
|
|
.line(points.anchor.shift(0, 80))
|
|
|
|
.addClass('hidden')
|
2022-09-27 19:15:57 +02:00
|
|
|
|
2024-09-29 07:14:59 +02:00
|
|
|
|
2025-05-19 08:04:05 +02:00
|
|
|
return part
|
|
|
|
}
|
2022-09-21 17:41:39 +02:00
|
|
|
```
|
2022-09-27 19:15:57 +02:00
|
|
|
</Example>
|
|
|
|
|
|
|
|
## Notes
|
2022-09-21 17:41:39 +02:00
|
|
|
|
2024-09-28 13:13:48 +02:00
|
|
|
Remember to [use translation keys, not text](/guides/best-practices#use-translation-keys)
|