Skip to content

Commit

Permalink
Added ability to change text fill color.
Browse files Browse the repository at this point in the history
  • Loading branch information
HackusatePvP committed Jun 1, 2024
1 parent 7559e8e commit 871a44f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/main/java/me/piitex/renjava/gui/Element.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ public Element(Overlay overlay) {
Font font = textOverlay.getFontLoader().getFont();
text.setFont(font);
}
if (textOverlay.getTextFillColor() != null) {
text.setFill(textOverlay.getTextFillColor());
}
text.setTranslateX(textOverlay.x());
text.setTranslateY(textOverlay.y());
this.node = text;
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/me/piitex/renjava/gui/overlay/TextOverlay.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package me.piitex.renjava.gui.overlay;


import javafx.scene.paint.Color;
import javafx.scene.text.Text;
import me.piitex.renjava.api.loaders.FontLoader;
import me.piitex.renjava.api.scenes.transitions.Transitions;
Expand All @@ -10,6 +11,7 @@

public class TextOverlay implements Overlay, Region {
private final Text text;
private Color textFillColor;
private FontLoader fontLoader;
private double x;
private double y;
Expand All @@ -27,13 +29,29 @@ public TextOverlay(String text, double x, double y) {
this.y = y;
}

public TextOverlay(String text, Color textFillColor, double x, double y) {
this.text = new Text(text);
this.textFillColor = textFillColor;
this.x = x;
this.y = y;
}

public TextOverlay(String text, FontLoader fontLoader, double x, double y) {
this.text = new Text(text);
this.fontLoader = fontLoader;
this.x = x;
this.y = y;
}

public TextOverlay(String text, Color textFillColor, FontLoader fontLoader, double x, double y) {
this.text = new Text(text);
this.textFillColor = textFillColor;
this.fontLoader = fontLoader;
this.x = x;
this.y = y;
}


public TextOverlay(Text text, double x, double y) {
this.text = text;
this.x = x;
Expand All @@ -51,6 +69,10 @@ public Text getText() {
return text;
}

public Color getTextFillColor() {
return textFillColor;
}

@Override
public double x() {
return x;
Expand Down

0 comments on commit 871a44f

Please sign in to comment.