Skip to content

Commit e236cac

Browse files
Update setHSL
Checking `if (h)` yields `false` when `h = 0`, but 0 is an acceptable value here. Had to decide between caching HSL verification and doing `typeof` 3x/pixel and opted for the temporary variables.
1 parent 609b38c commit e236cac

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

src/gameobjects/BitmapData.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -782,12 +782,11 @@ Phaser.BitmapData.prototype = {
782782
* @return {Phaser.BitmapData} This BitmapData object for method chaining.
783783
*/
784784
setHSL: function (h, s, l, region) {
785+
var bHaveH = typeof(h) === "number",
786+
bHaveS = typeof(s) === "number",
787+
bHaveL = typeof(l) === "number";
785788

786-
if (h === undefined || h === null) { h = false; }
787-
if (s === undefined || s === null) { s = false; }
788-
if (l === undefined || l === null) { l = false; }
789-
790-
if (!h && !s && !l)
789+
if (!bHaveH && !bHaveS && !bHaveL)
791790
{
792791
return;
793792
}
@@ -805,17 +804,17 @@ Phaser.BitmapData.prototype = {
805804
{
806805
Phaser.Color.unpackPixel(this.getPixel32(x, y), pixel, true);
807806

808-
if (h)
807+
if (bHaveH)
809808
{
810809
pixel.h = h;
811810
}
812811

813-
if (s)
812+
if (bHaveS)
814813
{
815814
pixel.s = s;
816815
}
817816

818-
if (l)
817+
if (bHaveL)
819818
{
820819
pixel.l = l;
821820
}

0 commit comments

Comments
 (0)