From 38d11442169cbbee82f1283ad2d3c0f5cc4fb71c Mon Sep 17 00:00:00 2001 From: Crazyinfin8 Date: Wed, 5 Apr 2023 07:32:56 -0700 Subject: [PATCH] Simplify and cleanup in small areas (#2755) * remove redundancy in FlxAnimation.play() `finished` must be false in order for this to run which sets it to false again. * remove redundancy in FlxColor.get_hue() `hueRad` calculated this value already so, for readability, we don't need to put the whole formula again. * Saturation isn't used in FlxColor.setHSChromaMatch() --- flixel/animation/FlxAnimation.hx | 1 - flixel/util/FlxColor.hx | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/flixel/animation/FlxAnimation.hx b/flixel/animation/FlxAnimation.hx index a0f59ef5a8..f172c7637a 100644 --- a/flixel/animation/FlxAnimation.hx +++ b/flixel/animation/FlxAnimation.hx @@ -129,7 +129,6 @@ class FlxAnimation extends FlxBaseAnimation if (!Force && !finished && reversed == Reversed) { paused = false; - finished = false; return; } diff --git a/flixel/util/FlxColor.hx b/flixel/util/FlxColor.hx index 70ebe1c327..da0801e787 100644 --- a/flixel/util/FlxColor.hx +++ b/flixel/util/FlxColor.hx @@ -515,7 +515,7 @@ abstract FlxColor(Int) from Int from UInt to Int to UInt { var chroma = Brightness * Saturation; var match = Brightness - chroma; - return setHSChromaMatch(Hue, Saturation, chroma, match, Alpha); + return setHueChromaMatch(Hue, chroma, match, Alpha); } /** @@ -531,13 +531,13 @@ abstract FlxColor(Int) from Int from UInt to Int to UInt { var chroma = (1 - Math.abs(2 * Lightness - 1)) * Saturation; var match = Lightness - chroma / 2; - return setHSChromaMatch(Hue, Saturation, chroma, match, Alpha); + return setHueChromaMatch(Hue, chroma, match, Alpha); } /** * Private utility function to perform common operations between setHSB and setHSL */ - inline function setHSChromaMatch(Hue:Float, Saturation:Float, Chroma:Float, Match:Float, Alpha:Float):FlxColor + inline function setHueChromaMatch(Hue:Float, Chroma:Float, Match:Float, Alpha:Float):FlxColor { Hue %= 360; var hueD = Hue / 60; @@ -730,7 +730,7 @@ abstract FlxColor(Int) from Int from UInt to Int to UInt var hue:Float = 0; if (hueRad != 0) { - hue = 180 / Math.PI * Math.atan2(Math.sqrt(3) * (greenFloat - blueFloat), 2 * redFloat - greenFloat - blueFloat); + hue = 180 / Math.PI * hueRad; } return hue < 0 ? hue + 360 : hue;