SolidPaint 对象
纯色填充对象, 可设置给 fill 或 stroke 属性。
关键属性
type: string
填充类型为 solid
。
color: Color
颜色。
基础属性
blendMode?: BlendMode
混合模式,默认为 normal。
visible?: boolean
是否可见,默认为 true。
opacity?: number
不透明度,默认为 1,暂时仅针对 color 为 颜色对象 有效。
子描边属性
style?: IStrokeStyle
当为元素设置多个描边时,可设置子描边样式 style
,用于覆盖 主描边样式。
可形成蚂蚁线、模拟内中外三层描边等各种效果。
纯色、 线性渐变、径向渐变、角度渐变、图案 等类型均支持子描边样式。
ts
interface IStrokeStyle {
strokeWidth?: number // 描边的宽度
strokeWidthFixed?: boolean // 是否固定线宽,不随画布视图放大
strokeCap?: 'none' | 'round' | 'square' // 无 | 圆形 | 方形 (描边的端点形状)
strokeJoin?: 'miter' | 'bevel' | 'round' // 直角 | 平角 | 圆角 (描边的拐角处理)
dashPattern?: number[] // 虚线描边的数值
dashOffset?: number // 虚线描边的起点偏移值
}
// 蚂蚁线效果
rect.stroke = [
{type: 'solid', color: 'white'}, // 第二个描边为虚线
{type: 'solid', color: 'black', style: { dashPattern: [3, 3] }}
]
// 模拟内中外三层描边效果
rect.stroke = [
{type: 'solid', color: 'white'}, // 多个描边宽度
{type: 'solid', color: 'black', style: { strokeWidth: 5 }},
{type: 'solid', color: 'blue', style: { strokeWidth: 10 }}
]