Style.d.ts 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import { RectLike } from '../core/BoundingRect';
  2. import Displayable from './Displayable';
  3. import { VectorArray } from '../core/vector';
  4. import { Dictionary, PropType, TextVerticalAlign, ImageLike, TextAlign } from '../core/types';
  5. import { LinearGradientObject } from './LinearGradient';
  6. import { RadialGradientObject } from './RadialGradient';
  7. import { PatternObject } from './Pattern';
  8. import { GradientObject } from './Gradient';
  9. export declare class TextStyleOption {
  10. text?: string;
  11. textFill?: string | PatternObject | LinearGradientObject | RadialGradientObject;
  12. textStroke?: string | PatternObject | LinearGradientObject | RadialGradientObject;
  13. textStrokeWidth?: number;
  14. font?: string;
  15. textFont?: string;
  16. fontStyle?: string;
  17. fontWeight?: string;
  18. fontFamily?: string;
  19. fontSize?: number;
  20. textAlign?: TextAlign;
  21. textVerticalAlign?: TextVerticalAlign;
  22. textBaseline?: TextVerticalAlign;
  23. textLineHeight?: number;
  24. textWidth?: number | string;
  25. textHeight?: number;
  26. textTag?: string;
  27. textShadowColor?: string;
  28. textShadowBlur?: number;
  29. textShadowOffsetX?: number;
  30. textShadowOffsetY?: number;
  31. textBackgroundColor?: string | {
  32. image: ImageLike | string;
  33. };
  34. textPadding?: number | number[];
  35. textBorderColor?: string;
  36. textBorderWidth?: number;
  37. textBorderRadius?: number | number[];
  38. textBoxShadowColor?: string;
  39. textBoxShadowBlur?: number;
  40. textBoxShadowOffsetX?: number;
  41. textBoxShadowOffsetY?: number;
  42. }
  43. export declare class StyleOption extends TextStyleOption {
  44. x?: number;
  45. y?: number;
  46. fill?: string | PatternObject | LinearGradientObject | RadialGradientObject;
  47. stroke?: string | PatternObject | LinearGradientObject | RadialGradientObject;
  48. opacity?: number;
  49. fillOpacity?: number;
  50. strokeOpacity?: number;
  51. lineDash?: false | number[];
  52. lineDashOffset?: number;
  53. shadowBlur?: number;
  54. shadowOffsetX?: number;
  55. shadowOffsetY?: number;
  56. shadowColor?: string;
  57. lineWidth?: number;
  58. lineCap?: CanvasLineCap;
  59. lineJoin?: CanvasLineJoin;
  60. miterLimit?: number;
  61. strokeNoScale?: boolean;
  62. text?: string;
  63. textPosition?: string | number[];
  64. textRect?: RectLike;
  65. textOffset?: number[];
  66. textDistance?: number;
  67. transformText?: boolean;
  68. textRotation?: number;
  69. textOrigin?: 'center' | VectorArray;
  70. textPadding?: number | number[];
  71. rich?: Dictionary<TextStyleOption>;
  72. truncate?: {
  73. outerWidth?: number;
  74. outerHeight?: number;
  75. ellipsis?: string;
  76. placeholder?: string;
  77. minChar?: number;
  78. };
  79. blend?: string;
  80. }
  81. declare type StyleKey = keyof StyleOption;
  82. declare type StyleValueType = PropType<StyleOption, StyleKey>;
  83. export default class Style extends StyleOption {
  84. constructor(opts?: StyleOption);
  85. bind(ctx: CanvasRenderingContext2D, el: Displayable, prevEl: Displayable): void;
  86. hasFill(): boolean;
  87. hasStroke(): boolean;
  88. extendFrom(otherStyle: StyleOption, overwrite?: boolean): void;
  89. set(obj: StyleOption | StyleKey, value?: StyleValueType): void;
  90. clone(): Style;
  91. static getGradient(ctx: CanvasRenderingContext2D, obj: GradientObject, rect: RectLike): CanvasGradient;
  92. private static initDefaultProps;
  93. }
  94. export {};