TextBox
它是Gesti内重要的组件之一,它的作用是将文字显示在画布内。
Example
Properties(属性)
| 属性名称 | 返回类型 | 描述 |
|---|
| fontSize | number | 字体大小 |
| color | string | 文字颜色 |
| shadowColor | string | 阴影颜色 |
| fontFamily | string | 字体系列 |
| shadow | Shadow | 阴影设置 |
| textStyles | TextOptions | 文字样式数据 |
| weight | FontWeight | 字重 |
Methods(方法)
| 方法名称 | 参数 | 返回类型 | 描述 |
|---|
| constructor | text: string, options?: TextOptions | - | 构造函数,初始化文本和选项 |
| setWeight | weight: FontWeight | void | 设置字重 |
| setFontStyle | style: FontStyleType | void | 设置字体样式为斜体 |
| setTextStyle | args: TextOptions | void | 设置文字样式 |
| setText | text: string | void | 设置文字内容,将完全替换原有内容 |
| setFontFamily | family: string | void | 设置字体系列 |
| setSpacing | value: number | void | 设置文字间距 |
| setColor | color: string | void | 设置文字颜色 |
| setFontSize | fontSize: number | void | 设置字体大小 |
| setDecoration | decoration: BoxDecorationOption | void | 设置文字装饰 |
| setShadow | shadow: Shadow | void | 设置文字阴影 |
updateText | text: string, options?: TextOptions | Promise<void> | 更新文本内容(已废弃) |
TextOption
| 属性名称 | 类型 | 描述 |
|---|
| fontFamily | string | 字体风格,可以浏览器搜索 canvas自定义字体 |
| weight | FontWeight | 字重 |
| fontStyle | FontStyleType | 字体样式 |
| fontSize | number | 字体大小 |
| spacing | number | 文字间距 |
| color | string | 文字颜色 |
| underLine | boolean | 是否显示下划线 |
| lineThrough | boolean | 是否显示删除线 |
| overLine | boolean | 是否显示上划线 |
| lineWidth | number | 划线宽度 |
| lineColor | string | 下划线颜色 |
| lineHeight | number | 文字行高 |
| resetFontSizeWithRect | boolean | 如果为true,文字大小会随着选框的高而变化 |
| maxFontSize | number | 传入一个整数类型,用于限制字体大小最大值,默认不会限制 |
| backgroundColor | string | 文字背景颜色 |
| maxWidth | number | 最大宽度 |
| stroke | boolean | 描边 |
| fill | boolean | 填充 |
| strokeColor | string | 描边颜色 |
| fillGradient | LineGradientDecorationOption | 填充渐变 |
| strokeGradient | LineGradientDecorationOption | 描边渐变 |
| strokeLineWidth | number | 描边线条宽度 |
| strokeShadow | boolean | 描边阴影 |
| fillShadow | boolean | 填充阴影 |