protected java.awt.Color modulateColorOpacity(java.awt.Color color, double opacity) { float[] compArray = new float[4]; color.getRGBComponents(compArray); compArray[3] *= (float) opacity; return new java.awt.Color(compArray[0], compArray[1], compArray[2], compArray[3]); }
protected void applyColor(DrawContext dc, java.awt.Color color, double opacity) { if (dc.isPickingMode()) return; double finalOpacity = opacity * (color.getAlpha() / 255.0); GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility. OGLUtil.applyColor(gl, color, finalOpacity, true); }
/** * getBorder. * * @param card a {@link forge.Card} object. * @return a {@link javax.swing.border.Border} object. */ public static Border getBorder(Card card) { // color info if (card == null) return BorderFactory.createEmptyBorder(2, 2, 2, 2); java.awt.Color color; ArrayList<String> list = CardUtil.getColors(card); if (card.isFaceDown()) color = Color.gray; else if (list.size() > 1) color = Color.orange; else if (list.get(0).equals(Constant.Color.Black)) color = Color.black; else if (list.get(0).equals(Constant.Color.Green)) color = new Color(0, 220, 39); else if (list.get(0).equals(Constant.Color.White)) color = Color.white; else if (list.get(0).equals(Constant.Color.Red)) color = Color.red; else if (list.get(0).equals(Constant.Color.Blue)) color = Color.blue; else if (list.get(0).equals(Constant.Color.Colorless)) color = Color.gray; else color = new Color(200, 0, 230); // If your card has a violet border, something is wrong if (color != Color.gray) { int r = color.getRed(); int g = color.getGreen(); int b = color.getBlue(); int shade = 10; r -= shade; g -= shade; b -= shade; r = Math.max(0, r); g = Math.max(0, g); b = Math.max(0, b); color = new Color(r, g, b); return BorderFactory.createLineBorder(color, 2); } else return BorderFactory.createLineBorder(Color.gray, 2); }
public static java.awt.Color getContrastingColor(java.awt.Color color) { float[] hsbvals = new float[3]; java.awt.Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), hsbvals); java.awt.Color c = Color.getHSBColor(0, 0, (hsbvals[2] + 0.5f) % 1f); return new java.awt.Color(c.getRed(), c.getGreen(), c.getBlue(), color.getAlpha()); }
protected void applyColor(DrawContext dc, java.awt.Color color, double opacity) { if (dc.isPickingMode()) return; double finalOpacity = opacity * (color.getAlpha() / 255.0); OGLUtil.applyColor(dc.getGL(), color, finalOpacity, true); }