mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-12 00:38:44 +00:00
Merge pull request #8189 from kevlahnota/nyxDesktop
add nyx effect to desktop card renders
This commit is contained in:
@@ -82,8 +82,12 @@ public class ImageCache {
|
|||||||
.expireAfterAccess(15, TimeUnit.MINUTES)
|
.expireAfterAccess(15, TimeUnit.MINUTES)
|
||||||
.build(new ImageLoader());
|
.build(new ImageLoader());
|
||||||
private static final BufferedImage _defaultImage;
|
private static final BufferedImage _defaultImage;
|
||||||
|
private static final BufferedImage _stars;
|
||||||
|
private static final BufferedImage _inv_stars;
|
||||||
static {
|
static {
|
||||||
BufferedImage defImage = null;
|
BufferedImage defImage = null;
|
||||||
|
BufferedImage stars = null;
|
||||||
|
BufferedImage inv_stars = null;
|
||||||
try {
|
try {
|
||||||
defImage = ImageIO.read(new File(ForgeConstants.NO_CARD_FILE));
|
defImage = ImageIO.read(new File(ForgeConstants.NO_CARD_FILE));
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
@@ -91,6 +95,40 @@ public class ImageCache {
|
|||||||
} finally {
|
} finally {
|
||||||
_defaultImage = (null == defImage) ? new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB) : defImage;
|
_defaultImage = (null == defImage) ? new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB) : defImage;
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
stars = ImageIO.read(new File(ForgeConstants.STARS_FILE));
|
||||||
|
inv_stars =ImageIO.read(new File(ForgeConstants.STARS_FILE));
|
||||||
|
// https://github.com/yusufshakeel/Java-Image-Processing-Project/blob/master/example/Negative.java
|
||||||
|
//get image width and height
|
||||||
|
int width = inv_stars.getWidth();
|
||||||
|
int height = inv_stars.getHeight();
|
||||||
|
|
||||||
|
//convert to negative
|
||||||
|
for(int y = 0; y < height; y++){
|
||||||
|
for(int x = 0; x < width; x++){
|
||||||
|
int p = inv_stars.getRGB(x,y);
|
||||||
|
|
||||||
|
int a = (p>>24)&0xff;
|
||||||
|
int r = (p>>16)&0xff;
|
||||||
|
int g = (p>>8)&0xff;
|
||||||
|
int b = p&0xff;
|
||||||
|
|
||||||
|
//subtract RGB from 255
|
||||||
|
r = 255 - r;
|
||||||
|
g = 255 - g;
|
||||||
|
b = 255 - b;
|
||||||
|
|
||||||
|
//set new RGB value
|
||||||
|
p = (a<<24) | (r<<16) | (g<<8) | b;
|
||||||
|
inv_stars.setRGB(x, y, p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
System.err.println("could not load default stars image");
|
||||||
|
} finally {
|
||||||
|
_stars = (null == stars) ? new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB) : stars;
|
||||||
|
_inv_stars = (null == inv_stars) ? new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB) : inv_stars;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clear() {
|
public static void clear() {
|
||||||
@@ -464,4 +502,8 @@ public class ImageCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static BufferedImage getDefaultImage() { return _defaultImage; }
|
public static BufferedImage getDefaultImage() { return _defaultImage; }
|
||||||
|
|
||||||
|
public static BufferedImage getStarsImage() { return _stars; }
|
||||||
|
|
||||||
|
public static BufferedImage getInvertedStarsImage() { return _inv_stars; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import java.util.Map;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import forge.ImageCache;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import forge.card.CardRarity;
|
import forge.card.CardRarity;
|
||||||
@@ -287,6 +288,11 @@ public class FCardImageRenderer {
|
|||||||
//determine colors for borders
|
//determine colors for borders
|
||||||
final List<DetailColors> borderColors = CardDetailUtil.getBorderColors(state, true);
|
final List<DetailColors> borderColors = CardDetailUtil.getBorderColors(state, true);
|
||||||
Color[] colors = fillColorBackground(g, borderColors, x, y, w, h, BLACK_BORDER_THICKNESS);
|
Color[] colors = fillColorBackground(g, borderColors, x, y, w, h, BLACK_BORDER_THICKNESS);
|
||||||
|
if (state.isEnchantment()) {
|
||||||
|
//draw fake nyx effect
|
||||||
|
g.drawImage(state.getColors().hasWhite() && state.getColors().countColors() == 1 ?
|
||||||
|
ImageCache.getInvertedStarsImage() : ImageCache.getStarsImage(), x, y, w, h, null);
|
||||||
|
}
|
||||||
|
|
||||||
x += OUTER_BORDER_THICKNESS;
|
x += OUTER_BORDER_THICKNESS;
|
||||||
y += OUTER_BORDER_THICKNESS;
|
y += OUTER_BORDER_THICKNESS;
|
||||||
|
|||||||
BIN
forge-gui/res/defaults/stars.png
Normal file
BIN
forge-gui/res/defaults/stars.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 155 KiB |
@@ -67,20 +67,20 @@ public class CardDetailUtil {
|
|||||||
|
|
||||||
public static DetailColors getBorderColor(final CardStateView card, final boolean canShow) {
|
public static DetailColors getBorderColor(final CardStateView card, final boolean canShow) {
|
||||||
if (card == null) {
|
if (card == null) {
|
||||||
return getBorderColors(null, false, false, false).iterator().next();
|
return getBorderColors(null, false, false, false, false).iterator().next();
|
||||||
}
|
}
|
||||||
return getBorderColors(card.getColors(), card.isLand(), canShow, false).iterator().next();
|
return getBorderColors(card.getColors(), card.isLand(), canShow, false, card.isEnchantment()).iterator().next();
|
||||||
}
|
}
|
||||||
public static List<DetailColors> getBorderColors(final CardStateView card, final boolean canShow) {
|
public static List<DetailColors> getBorderColors(final CardStateView card, final boolean canShow) {
|
||||||
if (card == null) {
|
if (card == null) {
|
||||||
return getBorderColors(null, false, false, true);
|
return getBorderColors(null, false, false, true, false);
|
||||||
}
|
}
|
||||||
return getBorderColors(card.getColors(), card.isLand(), canShow, true);
|
return getBorderColors(card.getColors(), card.isLand(), canShow, true, card.isEnchantment());
|
||||||
}
|
}
|
||||||
public static List<DetailColors> getBorderColors(final ColorSet colorSet) {
|
public static List<DetailColors> getBorderColors(final ColorSet colorSet) {
|
||||||
return getBorderColors(colorSet, false, true, true);
|
return getBorderColors(colorSet, false, true, true, false);
|
||||||
}
|
}
|
||||||
private static List<DetailColors> getBorderColors(final ColorSet cardColors, final boolean isLand, final boolean canShow, final boolean supportMultiple) {
|
private static List<DetailColors> getBorderColors(final ColorSet cardColors, final boolean isLand, final boolean canShow, final boolean supportMultiple, final boolean isEnchantment) {
|
||||||
final List<DetailColors> borderColors = new ArrayList<>();
|
final List<DetailColors> borderColors = new ArrayList<>();
|
||||||
|
|
||||||
if (cardColors == null || !canShow) {
|
if (cardColors == null || !canShow) {
|
||||||
|
|||||||
@@ -279,6 +279,7 @@ public final class ForgeConstants {
|
|||||||
// data that has defaults in the program dir but overrides/additions in the user dir
|
// data that has defaults in the program dir but overrides/additions in the user dir
|
||||||
private static final String _DEFAULTS_DIR = RES_DIR + "defaults" + PATH_SEPARATOR;
|
private static final String _DEFAULTS_DIR = RES_DIR + "defaults" + PATH_SEPARATOR;
|
||||||
public static final String NO_CARD_FILE = _DEFAULTS_DIR + "no_card.jpg";
|
public static final String NO_CARD_FILE = _DEFAULTS_DIR + "no_card.jpg";
|
||||||
|
public static final String STARS_FILE = _DEFAULTS_DIR + "stars.png";
|
||||||
public static final FileLocation WINDOW_LAYOUT_FILE = new FileLocation(_DEFAULTS_DIR, USER_PREFS_DIR, "window.xml");
|
public static final FileLocation WINDOW_LAYOUT_FILE = new FileLocation(_DEFAULTS_DIR, USER_PREFS_DIR, "window.xml");
|
||||||
public static final FileLocation MATCH_LAYOUT_FILE = new FileLocation(_DEFAULTS_DIR, USER_PREFS_DIR, "match.xml");
|
public static final FileLocation MATCH_LAYOUT_FILE = new FileLocation(_DEFAULTS_DIR, USER_PREFS_DIR, "match.xml");
|
||||||
public static final FileLocation WORKSHOP_LAYOUT_FILE = new FileLocation(_DEFAULTS_DIR, USER_PREFS_DIR, "workshop.xml");
|
public static final FileLocation WORKSHOP_LAYOUT_FILE = new FileLocation(_DEFAULTS_DIR, USER_PREFS_DIR, "workshop.xml");
|
||||||
|
|||||||
Reference in New Issue
Block a user