1
0
Fork 0
mirror of https://github.com/correl/mage.git synced 2025-03-13 01:09:53 -09:00

Add highlights to rendered card title and card type round boxes

This commit is contained in:
spjspj 2017-11-24 21:59:11 +11:00
parent 37fc07a256
commit 763b8d30fd

View file

@ -52,6 +52,38 @@ public final class CardRendererUtils {
return bimage;
}
private static Color abitbrighter(Color c) {
int r = c.getRed();
int g = c.getGreen();
int b = c.getBlue();
int alpha = c.getAlpha();
int plus_r = (int) ((255 - r) / 2);
int plus_g = (int) ((255 - g) / 2);
int plus_b = (int) ((255 - b) / 2);
return new Color(r + plus_r,
g + plus_g,
b + plus_b,
alpha);
}
private static Color abitdarker(Color c) {
int r = c.getRed();
int g = c.getGreen();
int b = c.getBlue();
int alpha = c.getAlpha();
int plus_r = (int) ((255 - r) / 2);
int plus_g = (int) ((255 - g) / 2);
int plus_b = (int) ((255 - b) / 2);
return new Color(r - plus_r,
g - plus_g,
b - plus_b,
alpha);
}
// Draw a rounded box with a 2-pixel border
// Used on various card parts.
public static void drawRoundedBox(Graphics2D g, int x, int y, int w, int h, int bevel, Paint border, Paint fill) {
@ -68,10 +100,11 @@ public final class CardRendererUtils {
g.fillOval(x + 2, y + 2, bevel * 2 - 4, h - 4);
g.fillOval(x + 2 + w - bevel * 2, y + 2, bevel * 2 - 4, h - 4);
g.fillRect(x + bevel, y + 2, w - 2 * bevel, h - 4);
g.setPaint(border);
g.setColor(g.getColor().brighter().brighter());
g.setPaint(fill);
g.setColor(abitbrighter(g.getColor()));
g.drawLine(x + 1 + bevel, y + 1, x + 1 + bevel + w - 2 * bevel - 2, y + 1);
g.setColor(g.getColor().darker().darker());
g.setPaint(fill);
g.setColor(abitdarker(g.getColor()));
g.drawLine(x + 1 + bevel, y + h - 2, x + 1 + bevel + w - 2 * bevel - 2, y + h - 2);
}