textcomponent: add option to outline text

This commit is contained in:
Adam
2020-06-22 12:41:48 -04:00
committed by Adam
parent cb45966a30
commit ac60e7772c

View File

@@ -43,6 +43,7 @@ public class TextComponent implements RenderableEntity
private String text;
private Point position = new Point();
private Color color = Color.WHITE;
private boolean outline;
@Override
public Dimension render(Graphics2D graphics)
@@ -63,6 +64,13 @@ public class TextComponent implements RenderableEntity
graphics.setColor(Color.BLACK);
graphics.drawString(textWithoutCol, x + 1, position.y + 1);
if (outline)
{
graphics.drawString(textWithoutCol, x - 1, position.y - 1);
graphics.drawString(textWithoutCol, x - 1, position.y + 1);
graphics.drawString(textWithoutCol, x + 1, position.y - 1);
}
// actual text
graphics.setColor(Color.decode("#" + colColor));
graphics.drawString(textWithoutCol, x, position.y);
@@ -76,6 +84,13 @@ public class TextComponent implements RenderableEntity
graphics.setColor(Color.BLACK);
graphics.drawString(text, position.x + 1, position.y + 1);
if (outline)
{
graphics.drawString(text, position.x - 1, position.y - 1);
graphics.drawString(text, position.x - 1, position.y + 1);
graphics.drawString(text, position.x + 1, position.y - 1);
}
// actual text
graphics.setColor(color);
graphics.drawString(text, position.x, position.y);