From d3af3c17d0770f7301ce77610ca1db02d195e2fc Mon Sep 17 00:00:00 2001 From: yugecin Date: Thu, 29 Sep 2016 22:41:56 +0200 Subject: [PATCH] move shit to utils --- src/itdelatrisu/opsu/Utils.java | 12 ++++++++++++ src/itdelatrisu/opsu/objects/Circle.java | 11 +---------- src/itdelatrisu/opsu/objects/Slider.java | 11 +---------- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/itdelatrisu/opsu/Utils.java b/src/itdelatrisu/opsu/Utils.java index 9ff34ffe..1e669712 100644 --- a/src/itdelatrisu/opsu/Utils.java +++ b/src/itdelatrisu/opsu/Utils.java @@ -58,6 +58,7 @@ import org.lwjgl.BufferUtils; import org.lwjgl.opengl.Display; import org.lwjgl.opengl.GL11; import org.newdawn.slick.Animation; +import org.newdawn.slick.Color; import org.newdawn.slick.GameContainer; import org.newdawn.slick.Input; import org.newdawn.slick.state.StateBasedGame; @@ -575,4 +576,15 @@ public class Utils { return y < Options.height / 2d ? 1 : 4; } + public static Color shiftHue(Color color, double H) { + double U = Math.cos(H * Math.PI / 180d); + double W = Math.sin(H * Math.PI / 180d); + + Color n = new Color(0, 0, 0); + n.r = (float) ((0.299d + 0.701d * U + 0.168d * W) * color.r + (0.587d - 0.587d * U + 0.330d * W) * color.g + (0.114d - 0.114d * U - 0.497 * W) * color.b); + n.g = (float) ((0.299 + 0.299 * U - 0.328 * W) * color.r + (0.587d - 0.413 * U + 0.035 * W) * color.g + (0.114d - 0.114d * U - 0.292 * W) * color.b); + n.b = (float) ((0.299d + 0.300d * U + 1.250d * W) * color.r + (0.587d - 0.585d * U + 1.050d * W) * color.g + (0.114 - 0.886 * U - 0.203 * W) * color.b); + return n; + } + } diff --git a/src/itdelatrisu/opsu/objects/Circle.java b/src/itdelatrisu/opsu/objects/Circle.java index 3ccfdcc6..f76460b8 100644 --- a/src/itdelatrisu/opsu/objects/Circle.java +++ b/src/itdelatrisu/opsu/objects/Circle.java @@ -92,16 +92,7 @@ public class Circle extends GameObject { public void draw(Graphics g, int trackPosition, boolean mirror) { Color orig = color; if (mirror) { - double H = 180d; - double U = Math.cos(H * Math.PI / 180d); - double W = Math.sin(H * Math.PI / 180d); - - Color n = new Color(0, 0, 0); - n.r = (float) ((0.299d + 0.701d * U + 0.168d * W) * color.r + (0.587d - 0.587d * U + 0.330d * W) * color.g + (0.114d - 0.114d * U - 0.497 * W) * color.b); - n.g = (float) ((0.299 + 0.299 * U - 0.328 * W) * color.r + (0.587d - 0.413 * U + 0.035 * W) * color.g + (0.114d - 0.114d * U - 0.292 * W) * color.b); - n.b = (float) ((0.299d + 0.300d * U + 1.250d * W) * color.r + (0.587d - 0.585d * U + 1.050d * W) * color.g + (0.114 - 0.886 * U - 0.203 * W) * color.b); - n.a = color.a; - color = n; + color = Utils.shiftHue(color, 180d); } int timeDiff = hitObject.getTime() - trackPosition; diff --git a/src/itdelatrisu/opsu/objects/Slider.java b/src/itdelatrisu/opsu/objects/Slider.java index e0fe3719..1f7562dc 100644 --- a/src/itdelatrisu/opsu/objects/Slider.java +++ b/src/itdelatrisu/opsu/objects/Slider.java @@ -179,16 +179,7 @@ public class Slider extends GameObject { public void draw(Graphics g, int trackPosition, boolean mirror) { Color orig = color; if (mirror) { - double H = 180d; - double U = Math.cos(H * Math.PI / 180d); - double W = Math.sin(H * Math.PI / 180d); - - Color n = new Color(0, 0, 0); - n.r = (float) ((0.299d + 0.701d * U + 0.168d * W) * color.r + (0.587d - 0.587d * U + 0.330d * W) * color.g + (0.114d - 0.114d * U - 0.497 * W) * color.b); - n.g = (float) ((0.299 + 0.299 * U - 0.328 * W) * color.r + (0.587d - 0.413 * U + 0.035 * W) * color.g + (0.114d - 0.114d * U - 0.292 * W) * color.b); - n.b = (float) ((0.299d + 0.300d * U + 1.250d * W) * color.r + (0.587d - 0.585d * U + 1.050d * W) * color.g + (0.114 - 0.886 * U - 0.203 * W) * color.b); - n.a = color.a; - color = n; + color = Utils.shiftHue(color, 180d); } int timeDiff = hitObject.getTime() - trackPosition;