| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- import { SBrushType } from "./enums/SBrushType";
- import { SColor, SGradient } from "./";
- /**
- * 画刷
- *
- * @author 庞利祥(sybotan@126.com)
- */
- export class SBrush {
- /** 画笔类型 */
- type: SBrushType = SBrushType.Color;
- /** 画刷颜色 */
- private _color = SColor.Black;
- get color(): SColor {
- return this._color;
- } // Get color
- set color(value: SColor) {
- this.type = SBrushType.Color;
- this._color = value;
- } // Set color
- /** 画刷渐变 */
- private _gradient: SGradient | null = null;
- get gradient(): SGradient | null {
- return this._gradient;
- } // Get gradient
- set gradient(value: SGradient | null) {
- this._gradient = value;
- this.type = SBrushType.Gradient;
- } // Set gradient
- /**
- * 构造函数
- */
- constructor();
- /**
- * 构造函数
- *
- * @param brush 画刷
- */
- constructor(brush: SBrush);
- /**
- * 构造函数
- *
- * @param color 颜色
- */
- constructor(color: SColor);
- /**
- * 构造函数
- *
- * @param gradient 过渡
- */
- constructor(gradient: SGradient);
- /**
- * 构造函数(重载实现)
- *
- * @param brush 画笔
- */
- constructor(brush?: SColor | SGradient | SBrush) {
- if (brush == undefined) {
- return;
- }
- // 如果是渐变类型
- if (brush instanceof SGradient) {
- this.gradient = brush;
- } else if (brush instanceof SBrush) {
- this.type = brush.type;
- this.color = new SColor(brush.color);
- } else {
- this.color = new SColor(brush);
- }
- } // Constructor()
- } // Class SBrush
|