Allow color as function for select types

This commit is contained in:
Philip Matsson
2024-07-29 14:41:09 +02:00
committed by Matthieu Baumann
parent 00c9d6ffc5
commit 5410544404
3 changed files with 11 additions and 7 deletions

View File

@@ -57,8 +57,9 @@ export class CircleSelect extends FSM {
let ctx = view.catalogCtx;
// draw the selection
ctx.fillStyle = options.color + '7f';
ctx.strokeStyle = options.color;
let colorValue = (typeof options.color === 'function') ? options.color(this.startCoo, this.coo) : options.color;
ctx.fillStyle = colorValue;
ctx.strokeStyle = colorValue;
ctx.lineWidth = options.lineWidth;
var r2 = (this.coo.x - this.startCoo.x) * (this.coo.x - this.startCoo.x) + (this.coo.y - this.startCoo.y) * (this.coo.y - this.startCoo.y);

View File

@@ -124,8 +124,9 @@ export class PolySelect extends FSM {
// draw the selection
ctx.save();
ctx.fillStyle = options.color + '7f';
ctx.strokeStyle = options.color;
let colorValue = (typeof options.color === 'function') ? options.color() : options.color;
ctx.fillStyle = colorValue;
ctx.strokeStyle = colorValue;
ctx.lineWidth = options.lineWidth;
ctx.beginPath();

View File

@@ -58,8 +58,10 @@ export class RectSelect extends FSM {
let ctx = view.catalogCtx;
// draw the selection
ctx.fillStyle = options.color + '7f';
ctx.strokeStyle = options.color;
let colorValue = (typeof options.color === 'function') ? options.color(this.startCoo, this.coo) : options.color;
ctx.fillStyle = colorValue;
ctx.strokeStyle = colorValue;
ctx.lineWidth = options.lineWidth;
var w = this.coo.x - this.startCoo.x;