再调整对比色算法
This commit is contained in:
parent
1762d6e629
commit
cc737578ba
@ -101,13 +101,26 @@ 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 r = 1 - color.red;
|
||||
const g = 1 - color.green;
|
||||
const b = 1 - color.blue;
|
||||
const r = this.calContrastColor(color.red);
|
||||
const g = this.calContrastColor(color.green);
|
||||
const b = this.calContrastColor(color.blue);
|
||||
this._boxLineColor.setValue([r, g, b]);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user