62 lines
1.2 KiB
Java
62 lines
1.2 KiB
Java
package io.gitlab.jfronny.ImgJava.util;
|
|
|
|
import java.awt.*;
|
|
|
|
public class MColor {
|
|
public int r;
|
|
public int g;
|
|
public int b;
|
|
public int a;
|
|
|
|
public MColor(Color c) {
|
|
this(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha());
|
|
}
|
|
|
|
public MColor(int r, int g, int b, int a) {
|
|
this.r = r;
|
|
this.g = g;
|
|
this.b = b;
|
|
this.a = a;
|
|
}
|
|
|
|
public MColor() {
|
|
this(0, 0, 0, 0);
|
|
}
|
|
|
|
public Color get() {
|
|
return new Color(Math.max(r, 0), Math.max(g, 0), Math.max(b, 0), Math.max(a, 0));
|
|
}
|
|
|
|
public MColor add(Color c) {
|
|
return add(new MColor(c));
|
|
}
|
|
|
|
public MColor add(MColor m) {
|
|
r += m.r;
|
|
g += m.g;
|
|
b += m.b;
|
|
a += m.a;
|
|
return this;
|
|
}
|
|
|
|
public MColor addM(Color c, double factor) {
|
|
return add(new MColor(c).mult(factor));
|
|
}
|
|
|
|
public MColor mult(double factor) {
|
|
r *= factor;
|
|
g *= factor;
|
|
b *= factor;
|
|
a *= factor;
|
|
return this;
|
|
}
|
|
|
|
public MColor div(double factor) {
|
|
r /= factor;
|
|
g /= factor;
|
|
b /= factor;
|
|
a /= factor;
|
|
return this;
|
|
}
|
|
}
|