Add support for HEX-defined colors
This commit is contained in:
@@ -5,6 +5,10 @@ public interface Color {
|
|||||||
|
|
||||||
void setRGBA(float red, float green, float blue, float alpha);
|
void setRGBA(float red, float green, float blue, float alpha);
|
||||||
|
|
||||||
|
void setRGB(int hex);
|
||||||
|
|
||||||
|
void setRGBA(long hex);
|
||||||
|
|
||||||
void setRed(float value);
|
void setRed(float value);
|
||||||
|
|
||||||
void setGreen(float value);
|
void setGreen(float value);
|
||||||
@@ -13,6 +17,14 @@ public interface Color {
|
|||||||
|
|
||||||
void setAlpha(float value);
|
void setAlpha(float value);
|
||||||
|
|
||||||
|
void setRed(int value);
|
||||||
|
|
||||||
|
void setGreen(int value);
|
||||||
|
|
||||||
|
void setBlue(int value);
|
||||||
|
|
||||||
|
void setAlpha(int value);
|
||||||
|
|
||||||
float getRed();
|
float getRed();
|
||||||
|
|
||||||
float getGreen();
|
float getGreen();
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ public class Label extends BaseComponent {
|
|||||||
public Label(Context context, GUI gui) {
|
public Label(Context context, GUI gui) {
|
||||||
super(context, gui);
|
super(context, gui);
|
||||||
this.color = gui.createColor();
|
this.color = gui.createColor();
|
||||||
|
this.color.setRGBA(0xFFFFFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getText() {
|
public String getText() {
|
||||||
@@ -61,6 +62,10 @@ public class Label extends BaseComponent {
|
|||||||
color.setRed(value);
|
color.setRed(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRed(Integer value) {
|
||||||
|
color.setRed(value);
|
||||||
|
}
|
||||||
|
|
||||||
public float getGreen() {
|
public float getGreen() {
|
||||||
return color.getGreen();
|
return color.getGreen();
|
||||||
}
|
}
|
||||||
@@ -69,6 +74,10 @@ public class Label extends BaseComponent {
|
|||||||
color.setGreen(value);
|
color.setGreen(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setGreen(Integer value) {
|
||||||
|
color.setGreen(value);
|
||||||
|
}
|
||||||
|
|
||||||
public float getBlue() {
|
public float getBlue() {
|
||||||
return color.getBlue();
|
return color.getBlue();
|
||||||
}
|
}
|
||||||
@@ -77,6 +86,10 @@ public class Label extends BaseComponent {
|
|||||||
color.setBlue(value);
|
color.setBlue(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setBlue(Integer value) {
|
||||||
|
color.setBlue(value);
|
||||||
|
}
|
||||||
|
|
||||||
public float getAlpha() {
|
public float getAlpha() {
|
||||||
return color.getAlpha();
|
return color.getAlpha();
|
||||||
}
|
}
|
||||||
@@ -85,6 +98,10 @@ public class Label extends BaseComponent {
|
|||||||
color.setAlpha(value);
|
color.setAlpha(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setAlpha(Integer value) {
|
||||||
|
color.setAlpha(value);
|
||||||
|
}
|
||||||
|
|
||||||
public void setColor(Float red, Float green, Float blue, Float alpha) {
|
public void setColor(Float red, Float green, Float blue, Float alpha) {
|
||||||
color.setRGBA(red, green, blue, alpha);
|
color.setRGBA(red, green, blue, alpha);
|
||||||
}
|
}
|
||||||
@@ -93,6 +110,10 @@ public class Label extends BaseComponent {
|
|||||||
color.setRGB(red, green, blue);
|
color.setRGB(red, green, blue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setColor(Integer hex) {
|
||||||
|
color.setRGB(hex);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected float getContentWidth() {
|
protected float getContentWidth() {
|
||||||
return bounds[2] - bounds[0];
|
return bounds[2] - bounds[0];
|
||||||
|
|||||||
@@ -29,6 +29,21 @@ public class NanoVGColor implements Color, Disposable {
|
|||||||
color.a(alpha);
|
color.a(alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setRGB(int hex) {
|
||||||
|
color.r(((hex & 0xFF0000) >> 2 * 8) / 255f);
|
||||||
|
color.g(((hex & 0x00FF00) >> 8) / 255f);
|
||||||
|
color.b(((hex & 0x0000FF)) / 255f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setRGBA(long hex) {
|
||||||
|
color.r(((hex & 0xFF000000L) >> 3 * 8) / 255f);
|
||||||
|
color.g(((hex & 0x00FF0000L) >> 2 * 8) / 255f);
|
||||||
|
color.b(((hex & 0x0000FF00L) >> 8) / 255f);
|
||||||
|
color.a(((hex & 0x000000FFL)) / 255f);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setRed(float value) {
|
public void setRed(float value) {
|
||||||
color.r(value);
|
color.r(value);
|
||||||
@@ -37,13 +52,11 @@ public class NanoVGColor implements Color, Disposable {
|
|||||||
@Override
|
@Override
|
||||||
public void setGreen(float value) {
|
public void setGreen(float value) {
|
||||||
color.g(value);
|
color.g(value);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setBlue(float value) {
|
public void setBlue(float value) {
|
||||||
color.b(value);
|
color.b(value);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -51,6 +64,26 @@ public class NanoVGColor implements Color, Disposable {
|
|||||||
color.a(value);
|
color.a(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setRed(int value) {
|
||||||
|
color.r(value / 255f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setGreen(int value) {
|
||||||
|
color.g(value / 255f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBlue(int value) {
|
||||||
|
color.b(value / 255f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setAlpha(int value) {
|
||||||
|
color.a(value / 255f);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getRed() {
|
public float getRed() {
|
||||||
return color.r();
|
return color.r();
|
||||||
|
|||||||
Reference in New Issue
Block a user