Files
obsidian-excalidraw-plugin/docs/API/element_style.md

91 lines
2.9 KiB
Markdown
Raw Normal View History

2021-05-08 20:42:11 +02:00
# [◀ Excalidraw Automate How To](../readme.md)
## Element style settings
2021-05-08 20:26:09 +02:00
As you will notice, some styles have setter functions. This is to help you navigate the allowed values for the property. You do not need to use the setter function however, you can use set the value directly as well.
2021-05-08 20:42:11 +02:00
### strokeColor
2021-05-08 20:26:09 +02:00
String. The color of the line. [CSS Legal Color Values](https://www.w3schools.com/cssref/css_colors_legal.asp)
Allowed values are [HTML color names](https://www.w3schools.com/colors/colors_names.asp), hexadecimal RGB strings, or e.g. `#FF0000` for red.
2021-05-08 20:42:11 +02:00
### backgroundColor
2021-05-08 20:26:09 +02:00
String. This is the fill color of an object. [CSS Legal Color Values](https://www.w3schools.com/cssref/css_colors_legal.asp)
Allowed values are [HTML color names](https://www.w3schools.com/colors/colors_names.asp), hexadecimal RGB strings e.g. `#FF0000` for red, or `transparent`.
2021-05-08 20:42:11 +02:00
### angle
2021-05-08 20:26:09 +02:00
Number. Rotation in radian. 90° == `Math.PI/2`.
2021-05-08 20:42:11 +02:00
### fillStyle, setFillStyle()
2021-05-08 20:26:09 +02:00
```typescript
type FillStyle = "hachure" | "cross-hatch" | "solid";
setFillStyle (val:number);
```
fillStyle is a string.
`setFillStyle()` accepts a number:
- 0: "hachure"
- 1: "cross-hatch"
- any other number: "solid"
2021-05-08 20:42:11 +02:00
### strokeWidth
2021-05-08 20:26:09 +02:00
Number, sets the width of the stroke.
2021-05-08 20:42:11 +02:00
### strokeStyle, setStrokeStyle()
2021-05-08 20:26:09 +02:00
```typescript
type StrokeStyle = "solid" | "dashed" | "dotted";
setStrokeStyle (val:number);
```
strokeStyle is a string.
`setStrokeStyle()` accepts a number:
- 0: "solid"
- 1: "dashed"
- any other number: "dotted"
2021-05-08 20:42:11 +02:00
### roughness
2021-05-08 20:26:09 +02:00
Number. Called sloppiness in Excalidraw. Three values are accepted:
- 0: Architect
- 1: Artist
- 2: Cartoonist
2021-05-08 20:42:11 +02:00
### opacity
2021-05-08 20:26:09 +02:00
Number between 0 and 100. The opacity of an object, both stroke and fill.
2021-05-08 20:42:11 +02:00
### strokeSharpness, setStrokeSharpness()
2021-05-08 20:26:09 +02:00
```typescript
type StrokeSharpness = "round" | "sharp";
setStrokeSharpness(val:nmuber);
```
strokeSharpness is a string.
"round" lines are curvey, "sharp" lines break at the turning point.
`setStrokeSharpness()` accepts a number:
- 0: "round"
- any other number: "sharp"
2021-05-08 20:42:11 +02:00
### fontFamily, setFontFamily()
2021-05-08 20:26:09 +02:00
Number. Valid values are 1,2 and 3.
`setFontFamily()` will also accept a number and return the name of the font.
- 1: "Virgil, Segoe UI Emoji"
- 2: "Helvetica, Segoe UI Emoji"
- 3: "Cascadia, Segoe UI Emoji"
2021-05-08 20:42:11 +02:00
### fontSize
2021-05-08 20:26:09 +02:00
Number. Default value is 20 px
2021-05-08 20:42:11 +02:00
### textAlign
2021-05-08 20:26:09 +02:00
String. Alignment of the text horizontally. Valid values are "left", "center", "right".
This is relevant when setting a fix width using the `addText()` function.
2021-05-08 20:42:11 +02:00
### verticalAlign
2021-05-08 20:26:09 +02:00
String. Alignment of the text vertically. Valid values are "top" and "middle".
This is relevant when setting a fix height using the `addText()` function.
2021-05-08 20:42:11 +02:00
### startArrowHead, endArrowHead
2021-05-08 20:26:09 +02:00
String. Valid values are "arrow", "bar", "dot", and "none". Specifies the beginning and ending of an arrow.
This is relavant when using the `addArrow()` and the `connectObjects()` functions.