diff --git a/graphic-pixi b/graphic-pixi index c66f841..cc73757 160000 --- a/graphic-pixi +++ b/graphic-pixi @@ -1 +1 @@ -Subproject commit c66f841526d22af7dcb8ce768ad96488f13468c3 +Subproject commit cc737578baa0dadef5c2b82b6ada66c117ba3d6b diff --git a/src/jl-graphic/plugins/CommonMousePlugin.ts b/src/jl-graphic/plugins/CommonMousePlugin.ts index 20eec59..76993ff 100644 --- a/src/jl-graphic/plugins/CommonMousePlugin.ts +++ b/src/jl-graphic/plugins/CommonMousePlugin.ts @@ -101,11 +101,27 @@ export class CommonMouseTool extends AppInteractionPlugin { return new CommonMouseTool(app); } + /** + * 计算对比色 + * @param rgb + * @returns + */ + private calContrastColor(rgb: number): number { + if (rgb > 0.45 && rgb < 0.55) { + return 0; + } else { + return 1 - rgb; + } + } + private updateBoxLineColor(cp: ICanvasProperties) { // 根据画布背景调整线色 const color = new Color(cp.backgroundColor); - const cn = color.toNumber() ^ 0xffffff; - this._boxLineColor.setValue(cn); + // 对比色 + const r = this.calContrastColor(color.red); + const g = this.calContrastColor(color.green); + const b = this.calContrastColor(color.blue); + this._boxLineColor.setValue([r, g, b]); } bind(): void { @@ -305,7 +321,7 @@ export class CommonMouseTool extends AppInteractionPlugin { if (!this.drag) return; // 绘制框选矩形框 this.box.clear(); - this.box.lineStyle({ width: 1, color: this._boxLineColor }); + this.box.lineStyle({ width: 2, color: this._boxLineColor }); const dsx = end.x - start.x; const dsy = end.y - start.y; let { x, y } = start;