import Layer, { ILayerEvent, ILayerState } from './Layer'; import { ISketchUtils } from './Sketch'; export interface ITextProps { /** * 文本内容 */ value: string; /** * 对齐方式 */ align: CanvasTextAlign; /** * 字体大小 */ size: number; /** * 字体 */ font: string; /** * 加粗 */ bold: boolean; /** * 使用斜体 */ italic: boolean; } export interface ITextEvent extends ILayerEvent { value: (value: ITextProps['value']) => void; size: (size: ITextProps['size']) => void; align: (align: ITextProps['align']) => void; font: (font: ITextProps['font']) => void; bold: (bold: ITextProps['bold']) => void; italic: (italic: ITextProps['italic']) => void; } /** * 绘制文本 */ export default class Text extends Layer { props: ITextProps; constructor(state?: Partial, props?: Partial); /** * 设置文本内容 */ value(value: ITextProps['value']): this; /** * 设置字体大小 */ size(value: ITextProps['size']): this; /** * 设置左右对齐方式 */ align(value: ITextProps['align']): this; /** * 设置字体 * * 没有特殊需求不建议随便更改字体 */ font(value: ITextProps['font']): this; /** * 设置加粗 */ bold(value: ITextProps['bold']): this; /** * 设置斜体 */ italic(value: ITextProps['italic']): this; protected _clone(): Text; protected _render(ctx: CanvasRenderingContext2D, utils: ISketchUtils): void; }