2022-09-22 09:05:20 +02:00
|
|
|
---
|
2022-09-27 18:24:35 +02:00
|
|
|
title: Path.setClass()
|
2022-09-22 09:05:20 +02:00
|
|
|
---
|
|
|
|
|
2022-09-27 18:24:35 +02:00
|
|
|
The `Path.setClass()` method sets the CSS class(es) of the path.
|
|
|
|
|
|
|
|
## Signature
|
|
|
|
|
2022-09-22 09:05:20 +02:00
|
|
|
```js
|
2022-09-27 18:24:35 +02:00
|
|
|
Path path.setClass(string className)
|
2022-09-22 09:05:20 +02:00
|
|
|
```
|
|
|
|
|
2022-09-27 18:24:35 +02:00
|
|
|
<Tip compact>This method is chainable as it returns the `Path` object</Tip>
|
|
|
|
|
|
|
|
## Example
|
|
|
|
|
|
|
|
<Example caption="Example of the Path.setClass() method">
|
|
|
|
```js
|
|
|
|
({ Point, points, Path, paths, part }) => {
|
2022-09-22 09:05:20 +02:00
|
|
|
|
2022-09-27 18:24:35 +02:00
|
|
|
points.from = new Point(5, 10)
|
|
|
|
points.to = new Point(95, 10)
|
2022-09-22 09:05:20 +02:00
|
|
|
|
2022-09-27 18:24:35 +02:00
|
|
|
paths.line = new Path()
|
|
|
|
.move(points.from)
|
|
|
|
.line(points.to)
|
|
|
|
.setClass('note dashed')
|
2022-09-22 09:05:20 +02:00
|
|
|
|
2022-09-27 18:24:35 +02:00
|
|
|
return part
|
|
|
|
}
|
|
|
|
```
|
2022-09-22 09:05:20 +02:00
|
|
|
</Example>
|
|
|
|
|
2022-09-27 18:24:35 +02:00
|
|
|
## Notes
|
|
|
|
|
|
|
|
The main purpose of this method is to save your some typing,
|
|
|
|
as the two following calls yield the same result:
|
|
|
|
|
2022-09-22 09:05:20 +02:00
|
|
|
```js
|
2022-09-27 18:24:35 +02:00
|
|
|
path.attr('class', 'fabric', true)
|
2023-12-08 13:28:42 -05:00
|
|
|
path.setClass('fabric')
|
2022-09-22 09:05:20 +02:00
|
|
|
```
|