Skip to content

Commit

Permalink
dont call .disabled behaviour in a hard loop
Browse files Browse the repository at this point in the history
  • Loading branch information
ianharrigan committed Mar 31, 2024
1 parent ea649b7 commit 0dcea90
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions haxe/ui/components/ColorPicker.hx
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,14 @@ private class HSVColorPickerImpl extends ColorPickerImpl {
_saturationValueGraphBytes = Bytes.alloc(bytesSize);
}

var isDisabled = picker.disabled;
var stepX = 100 / cx;
var stepY = 100 / cy;
for (y in 0...Std.int(cy)) {
for (x in 0...Std.int(cx)) {
var i:Int = Std.int(y * (cx * 4) + x * 4);
var pixel = ColorUtil.hsvToRGBF(_currentColorHSV.h - 1, (x + 1) * stepX, 100 - (y * stepY));
if (picker.disabled) {
if (isDisabled) {
var greypixel = ColorUtil.rgbToGray(Math.round(pixel.r), Math.round(pixel.g), Math.round(pixel.b));
_saturationValueGraphBytes.set(i + 0, greypixel);
_saturationValueGraphBytes.set(i + 1, greypixel);
Expand Down Expand Up @@ -304,12 +305,13 @@ private class HSVColorPickerImpl extends ColorPickerImpl {
_hueGraphBytes = Bytes.alloc(bytesSize);
}

var isDisabled = picker.disabled;
var step = 360 / cx;
for (y in 0...Std.int(cy)) {
for (x in 0...Std.int(cx)) {
var i:Int = Std.int(y * (cx * 4) + x * 4);
var c = ColorUtil.hsvToRGBF(x * step, 100, 100);
if (picker.disabled) {
if (isDisabled) {
var greypixel = ColorUtil.rgbToGray(Math.round(c.r), Math.round(c.g), Math.round(c.b));
_hueGraphBytes.set(i + 0, greypixel);
_hueGraphBytes.set(i + 1, greypixel);
Expand Down

0 comments on commit 0dcea90

Please sign in to comment.