mirror of
https://github.com/magefree/mage.git
synced 2025-12-23 03:51:58 -08:00
Merge pull request #4195 from spjspj/master
Add highlights to rendered card title and card type round boxes
This commit is contained in:
commit
d00aa759f8
1 changed files with 38 additions and 5 deletions
|
|
@ -16,8 +16,8 @@ import java.util.regex.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author stravant@gmail.com
|
* @author stravant@gmail.com
|
||||||
* <p>
|
* <p>
|
||||||
* Various static utilities for use in the card renderer
|
* Various static utilities for use in the card renderer
|
||||||
*/
|
*/
|
||||||
public final class CardRendererUtils {
|
public final class CardRendererUtils {
|
||||||
|
|
||||||
|
|
@ -52,6 +52,38 @@ public final class CardRendererUtils {
|
||||||
return bimage;
|
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
|
// Draw a rounded box with a 2-pixel border
|
||||||
// Used on various card parts.
|
// 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) {
|
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, y + 2, bevel * 2 - 4, h - 4);
|
||||||
g.fillOval(x + 2 + w - bevel * 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.fillRect(x + bevel, y + 2, w - 2 * bevel, h - 4);
|
||||||
g.setPaint(border);
|
g.setPaint(fill);
|
||||||
g.setColor(g.getColor().brighter().brighter());
|
g.setColor(abitbrighter(g.getColor()));
|
||||||
g.drawLine(x + 1 + bevel, y + 1, x + 1 + bevel + w - 2 * bevel - 2, y + 1);
|
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);
|
g.drawLine(x + 1 + bevel, y + h - 2, x + 1 + bevel + w - 2 * bevel - 2, y + h - 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue