public Color[] generateColors(int n) { Color[] cols = new Color[n]; for (int i = 0; i < n; i++) { cols[i] = Color.getHSBColor((float) i / (float) n, 0.85f, 1.0f); } return cols; }
/** * Calculate hue color for current hue index. */ private Color colorAt(int y) { return Color.getHSBColor(1 - (float) y / (height - 1), 1, 1); } }
private static Color rs2hsbToColor(int hsb) { int decode_hue = (hsb >> 10) & 0x3f; int decode_saturation = (hsb >> 7) & 0x07; int decode_brightness = (hsb & 0x7f); return Color.getHSBColor((float) decode_hue / 63, (float) decode_saturation / 7, (float) decode_brightness / 127); } }
private static Color createColor(float[] colorHSB) { return colorHSB == null ? null : Color.getHSBColor(colorHSB[0], colorHSB[1], colorHSB[2]); }
@Override public Color getColor(double value) { if (value > max) { // Red (brightness=0.7) to black (brightness=0.0) gradient float x = (float) ((value - max) / (maxMax - max)); if (x > 1.0f) x = 1.0f; return Color.getHSBColor(0.0f, 1.0f, 0.7f - x * 0.7f); } else { // Green (hue=0.3) to red (hue=1.0) gradient float x = (float) ((value - min) / (max - min)); if (x < 0.0f) x = 0.0f; return Color.getHSBColor(0.3f + 0.7f * x, 1.0f, 0.7f); } } }
public Color toColor() { return Color.getHSBColor(hue.floatValue() / 360, saturation.floatValue() / 100, value.floatValue() / 100); }
import java.awt.Color; float hsbVals[] = Color.RGBtoHSB( originalColour.getRed(), originalColour.getGreen(), originalColour.getBlue(), null ); Color highlight = Color.getHSBColor( hsbVals[0], hsbVals[1], 0.5f * ( 1f + hsbVals[2] )); Color shadow = Color.getHSBColor( hsbVals[0], hsbVals[1], 0.5f * hsbVals[2] );
private static Color brighter(int color) { float[] hsv = new float[3]; Color.RGBtoHSB(color >>> 16, (color >> 8) & 0xFF, color & 0xFF, hsv); return Color.getHSBColor(hsv[0], 1.f, 1.f); }
private void redrawGradient() { Color primaryRight = Color.getHSBColor(1f - this.selectedY / (float) (size - 1), 1, 1); Graphics2D g = image.createGraphics(); GradientPaint primary = new GradientPaint( 0f, 0f, Color.WHITE, size - 1, 0f, primaryRight); GradientPaint shade = new GradientPaint( 0f, 0f, new Color(0, 0, 0, 0), 0f, size - 1, Color.BLACK); g.setPaint(primary); g.fillRect(0, 0, size, size); g.setPaint(shade); g.fillRect(0, 0, size, size); g.dispose(); forceRedraw = true; }
public Color nextColor() { if (colorIndex < PREDEFINED_COLORS.length) { return PREDEFINED_COLORS[colorIndex++]; } else { return Color.getHSBColor((float) random(), (float) random(), (float) random()); } } }
g.setColor(Color.getHSBColor(relDepth, 1.0f, 0.9f)); g.fillRect(x1, EXT_PAD, x2 - x1, GRAPH_HEIGHT); g.setColor(Color.getHSBColor(relDepth, 1.0f, 0.9f)); int y1 = HEIGHT * (depth - minDepth) / (maxDepth - minDepth + 1); int y2 = HEIGHT * (depth + 1 - minDepth) / (maxDepth - minDepth + 1); g.setColor(Color.getHSBColor(relDepth, 1.0f, 0.9f)); g.fillRect(lastX, GRAPH_HEIGHT + EXT_PAD + PAD, w, GRAPH_HEIGHT);
RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setPaint(Color.getHSBColor(r.nextFloat(), 1, 1)); g2d.setStroke(new BasicStroke(size / 8)); g2d.drawLine(0, size / 2, size, size / 2);
private Color colorFromPoint(int x, int y) { float h = x / 255.0F; float s = 1.0F; float b = 1.0F - (y / 100.0F); return java.awt.Color.getHSBColor(h, s, b); }
private java.awt.Color colorFromPoint(int x, int y) { float h = x / 255.0F; float s = 1.0F; float b = 1.0F - (y / 100.0F); return java.awt.Color.getHSBColor(h, s, b); }
private void drawSaturation(Graphics g) { Rectangle r = g.getClipBounds(); int width = r.width - WIDTH_OFFSET; for (int i = 0; i < width; i++) { Color hsb = Color.getHSBColor(hue, (float) i / width, brightness); Color c = new Color(hsb.getRed(), hsb.getGreen(), hsb.getBlue()); g.setColor(c); g.fillRect(i + HALF_WIDTH_OFFSET, 0, 1, r.height - HEIGHT_OFFSET); } }
private void drawHue(Graphics g) { Rectangle r = g.getClipBounds(); int width = r.width - WIDTH_OFFSET; for (int i = 0; i < width; i++) { Color hsb = Color.getHSBColor((float) i / width, saturation, brightness); Color c = new Color(hsb.getRed(), hsb.getGreen(), hsb.getBlue()); g.setColor(c); g.fillRect(i + HALF_WIDTH_OFFSET, 0, 1, r.height - HEIGHT_OFFSET); } }
private void drawBrightness(Graphics g) { Rectangle r = g.getClipBounds(); int width = r.width - WIDTH_OFFSET; for (int i = 0; i < width; i++) { Color hsb = Color.getHSBColor(hue, saturation, (float) i / width); Color c = new Color(hsb.getRed(), hsb.getGreen(), hsb.getBlue()); g.setColor(c); g.fillRect(i + HALF_WIDTH_OFFSET, 0, 1, r.height - HEIGHT_OFFSET); } }
LineAttributes lineAttributes = (LineAttributes) Factory.createOrGet( config.getNode(LINE_ATTRIBUTES_KEY), new ShapeAttributes(null, Color.getHSBColor((curveIndex % 6) / 6f, 1f, 0.8f), 0, null));
private void drawNode(Graphics2D g, List<RectangleDepth> nodes) { for (final RectangleDepth node : nodes) { final Color color = Color.getHSBColor(node.getDepth() / (maxDepth + 1f), 1f, 1f); g.setStroke(new BasicStroke(Math.max(0.5f, maxDepth - node.getDepth() + 1 - 1))); g.setColor(color); final Rectangle r = node.getRectangle(); drawRectangle(g, r); } }
@Override @Optional.Method(modid="albedo") public Light provideLight() { if(getPassengers().isEmpty()) return null; Entity passenger = getPassengers().get(0); Color color = Color.getHSBColor(passenger.ticksExisted / 36F, 1F, 1F); return Light.builder().pos(this).color(color.getRGB(), false).radius(5).build(); }