import NumberEditLayer from './number-edit-layer'; import NumberEditTool from './number-edit-tool'; import { FillTask, FILL_TYPE } from '../common/filltask'; export default class BucketTool extends NumberEditTool { fastfill: boolean; constructor(numberEditLayer) { super(numberEditLayer, 'number-edit-bucket', 'url("/static/cursor/cursor-fill-color.png") 24 24, default'); this.setProp('fastfill', true); } isFastfillEnabled() { return this.getProp('fastfill'); } isFastfilled() { } override onclick(evt: MouseEvent) { if (!this.numberEditLayer) return; if (this.fastfill) return; console.log('BucketTool@onclick'); let task = new FillTask(FILL_TYPE.SOLID); // let task = new FillTask(FillTask.FILL_TYPE_LINEAR_GRADIENT); // let task = new FillTask(FillTask.FILL_TYPE_RADIAL_GRADIENT); task.color = this.numberEditLayer.color; //task.color = Utils.randomColor(); //task.textureImage = this.getProp('textureImage'); //task.textureImage = null; let pp = this.numberEditLayer.translate(evt._contentPoint); task.x = pp.x; task.y = pp.y; this.numberEditLayer.fill(task); } override onmousedown(evt: MouseEvent) { console.log('BucketTool@onmousedown()'); if (!this.numberEditLayer) return; this.fastfill = false; } override onmouseup(evt: MouseEvent) { console.log('BucketTool@onmouseup()'); } override onDragStart(evt: MouseEvent) { if (!this.numberEditLayer) return; console.log('BucketTool@onDragStart()'); if (!this.isFastfillEnabled()) return; this.fastfill = true; let task = new FillTask(FILL_TYPE.SOLID); task.color = this.numberEditLayer.color; let pp = this.numberEditLayer.translate(evt._contentPoint); task.x = pp.x; task.y = pp.y; this.numberEditLayer.fastfillStart(task); } override onDragMove(evt: MouseEvent) { console.log('ondragmove......'); if (!this.numberEditLayer) return; console.log('BucketTool@onDragMove()'); if (!this.isFastfillEnabled()) return; let pp = this.numberEditLayer.translate(evt._contentPoint); this.numberEditLayer.fastfillAddPoint(pp.x, pp.y); } override onDragEnd(evt: MouseEvent) { if (!this.numberEditLayer) return; if (!this.isFastfillEnabled()) return; console.log('BucketTool@onDragEnd()'); this.numberEditLayer.fastfillEnd(); } override onSelect(): void { if (!this.numberEditLayer) return; this.numberEditLayer.showUnorderMask = false; this.numberEditLayer.invalidate(); } }