/*
 * FXGL - JavaFX Game Library. The MIT License (MIT).
 * Copyright (c) AlmasB (almaslvl@gmail.com).
 * See LICENSE for details.
 */

package com.almasb.fxgl.physics.box2d.particle;

import javafx.scene.paint.Color;

/**
 * Small color object for each particle
 *
 * @author dmurph
 */
public class ParticleColor {
    public byte r, g, b, a;

    public ParticleColor() {
        r = (byte) 127;
        g = (byte) 127;
        b = (byte) 127;
        a = (byte) 50;
    }

    public ParticleColor(byte r, byte g, byte b, byte a) {
        set(r, g, b, a);
    }

    public ParticleColor(Color color) {
        set(color);
    }

    public void set(Color color) {
        r = (byte) (255 * color.getRed());
        g = (byte) (255 * color.getGreen());
        b = (byte) (255 * color.getBlue());
        a = (byte) 255;
    }

    public void set(ParticleColor color) {
        r = color.r;
        g = color.g;
        b = color.b;
        a = color.a;
    }

    public boolean isZero() {
        return r == 0 && g == 0 && b == 0 && a == 0;
    }

    public void set(byte r, byte g, byte b, byte a) {
        this.r = r;
        this.g = g;
        this.b = b;
        this.a = a;
    }
}

@@ -343,139 +343,8 @@
 a;%0A%0A
-    public ParticleColor() %7B%0A        r = (byte) 127;%0A        g = (byte) 127;%0A        b = (byte) 127;%0A        a = (byte) 50;%0A    %7D%0A%0A
     
@@ -540,19 +540,36 @@
         
-r =
+set(%0A               
  (byte) 
@@ -590,17 +590,17 @@
 etRed())
-;
+,
 %0A       
@@ -600,19 +600,23 @@
         
-g =
+       
  (byte) 
@@ -639,17 +639,17 @@
 Green())
-;
+,
 %0A       
@@ -649,19 +649,23 @@
         
-b =
+       
  (byte) 
@@ -687,17 +687,17 @@
 tBlue())
-;
+,
 %0A       
@@ -701,19 +701,23 @@
     
-a =
+       
  (byte) 
 255;
@@ -712,19 +712,52 @@
  (byte) 
+(
 255
+ * color.getOpacity())%0A        )
 ;%0A    %7D%0A
@@ -812,172 +812,47 @@
     
-r = 
+set(
 color.r
-;%0A        g = color.g;%0A        b = color.b;%0A        a = color.a;%0A    %7D%0A%0A    public boolean isZero() %7B%0A        return r == 0 && g == 0 && b == 0 && a == 0
+, color.g, color.b, color.a)
 ;%0A  

clean up