文本
Property | Description | Type | Required | Default |
---|---|---|---|---|
width | 宽度 | number | true | 0 |
height | 高度 | number | true | 0 |
fill | 文字颜色 | string | false | - |
text | text content | string | true | '' |
fontFamily | font family | string | false | system-ui |
fontWeight | font weight | string | false | normal |
fontSize | font size | number | false | 12 |
underline | TODO | boolean | false | false |
overline | TODO | boolean | false | false |
linethrough | TODO | boolean | false | false |
fontStyle | font style | normal | italic | oblique | false | normal |
lineHeight | line height for the text | number | false | 14 |
charSpacing | character spacing for text | number | false | 0 |
direction | text direction | ltr | rtl | false | ltr |
lineClamp | maximum number of lines to display, if overflow and value is Greater than zero, ellipsis will be displayed | number | false | 0 |
textAlign | text align | center | end | left | right | start | false | left |
textBaseline | text baseline | alphabetic | bottom | hanging | ideographic | middle | top | false | top |
示例
Source Code
js
const rubbing = new Rubbing({
selector: '#canvas',
background: '#fff',
width: 300,
height: 100,
})
await rubbing.init()
rubbing.loadFrom({
objects: [
{
type: 'text',
text: '🎉 Rubbing!',
left: 0,
top: 50,
fontSize: 16,
fill: '#7c3aed',
width: 300,
textAlign: 'center',
},
],
})