Example usage for java.awt Color HSBtoRGB

List of usage examples for java.awt Color HSBtoRGB

Introduction

In this page you can find the example usage for java.awt Color HSBtoRGB.

Prototype

public static int HSBtoRGB(float hue, float saturation, float brightness) 

Source Link

Document

Converts the components of a color, as specified by the HSB model, to an equivalent set of values for the default RGB model.

Usage

From source file:Main.java

public static void main(String[] args) {
    int rgb = Color.HSBtoRGB(1.0f, 1.0f, 1.0f);
    System.out.println(rgb);
}

From source file:Main.java

public static void main() {

    float hue = 12;
    float saturation = 13;
    float brightness = 14;

    int rgb = Color.HSBtoRGB(hue, saturation, brightness);
    int red = (rgb >> 16) & 0xFF;
    int green = (rgb >> 8) & 0xFF;
    int blue = rgb & 0xFF;

}

From source file:MainClass.java

public void paint(Graphics g) {
    int n = 3;/*from w w  w  .j av a2  s  .  c  o m*/
    int xdata[] = new int[n];
    int ydata[] = new int[n];
    xdata[0] = 50;
    ydata[0] = 150;
    xdata[1] = 200;
    ydata[1] = 50;
    xdata[2] = 350;
    ydata[2] = 150;
    int rgb = Color.HSBtoRGB(1.0f, 1.0f, 1.0f);
    g.setColor(new Color(rgb));
    g.fillPolygon(xdata, ydata, n);

}

From source file:ColorSchemaGenerator.java

/**
 * Create the schema color./*from ww w .  j a v  a  2s  .  c om*/
 * 
 * @param base
 * @param i (a color between 0 and 3)
 * @param schemaName
 * @return
 */
public static Color createColor(Color base, int i, String schemaName) {

    i = Math.abs(i %= 3);
    if (schemaName == null)
        schemaName = SCHEMA_SOFT;
    float[] schema = schemas.get(schemaName);

    float[] components = Color.RGBtoHSB(base.getRed(), base.getGreen(), base.getBlue(), null);

    components[1] = (schema[i * 2] < 0) ? -schema[i * 2] * components[1] : schema[i * 2];
    if (components[1] > 1)
        components[1] = 1.0f;
    if (components[1] < 0)
        components[1] = 0;

    components[2] = (schema[i * 2 + 1] < 0) ? -schema[i * 2 + 1] * components[2] : schema[i * 2 + 1];
    if (components[2] > 1)
        components[2] = 1.0f;
    if (components[2] < 0)
        components[2] = 0;

    return new Color(Color.HSBtoRGB(components[0], components[1], components[2]));
}

From source file:lisong_mechlab.view.graphs.WeaponColouredDrawingSupplier.java

private Color colorShift(Color aColour, int aMax, int aCurr) {
    float hsb[] = new float[3];
    Color.RGBtoHSB(aColour.getRed(), aColour.getGreen(), aColour.getBlue(), hsb);

    float blend = aMax == 1 ? 1.0f : (float) aCurr / (aMax - 1);
    float range_min = 0.55f;
    float range_max = 1.0f;
    float saturation = (range_max - range_min) * blend + range_min;

    hsb[1] *= saturation;//from   w  w w . j ava2s. com
    hsb[2] *= saturation;

    return new Color(Color.HSBtoRGB(hsb[0], hsb[1], hsb[2]));
}

From source file:simulador.controle.GraficoCategorias.java

private static void renderizarGrafico(JFreeChart grafico) {

    if (DEBUG) {//  w  w  w .j  av  a  2  s  .  c om
        System.out.println("GraficoRadiais.renderizarGrafico");
    }

    XYLineAndShapeRenderer renderizador = new XYLineAndShapeRenderer();
    int qtdSeries, aux;

    qtdSeries = grafico.getXYPlot().getDataset().getSeriesCount();
    //aux = (Color.WHITE.getRGB() - Color.BLACK.getRGB())/qtdSeries;   
    aux = 360 / qtdSeries;

    //System.out.println("aux = "+aux);
    for (int i = 0; i < qtdSeries; i++) {
        renderizador.setSeriesPaint(i, new Color(Color.HSBtoRGB((aux * i) / 360.0f, 1.0f, 1.0f)));
        renderizador.setSeriesStroke(i, new BasicStroke(1.0f));
    }

    //renderizador.setSeriesLinesVisible(0, false);

    grafico.getXYPlot().setRenderer(renderizador);

}

From source file:com.whizzosoftware.hobson.lifx.api.message.HSBK.java

public String toRGBString() {
    int rgb = Color.HSBtoRGB(this.hue / 65535.0f, this.saturation / 65535.0f, this.brightness / 65535.0f);
    return "rgb(" + ((rgb >> 16) & 0xFF) + "," + ((rgb >> 8) & 0xFF) + "," + (rgb & 0xFF) + ")";
}

From source file:ml.hsv.java

public static void HSV2File(hsv hsvImage[][], int width, int height) throws IOException //store img output as hsv2file.png
{
    BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
    WritableRaster raster = image.getRaster();
    for (int i = 0; i < height; i++) {
        for (int j = 0; j < width; j++) {
            int RGB = Color.HSBtoRGB(hsvImage[i][j].h, hsvImage[i][j].s, hsvImage[i][j].v);
            Color c = new Color(RGB);
            int temp[] = { c.getRed(), c.getGreen(), c.getBlue() };
            raster.setPixel(j, i, temp);
        }/*www  . j  a v a  2s. co m*/
    }
    ImageIO.write(image, "PNG",
            new File("/home/shinchan/FinalProject/PaperImplementation/Eclipse/ML/output/hsv2file.png"));
}

From source file:fi.iki.tsnorri.gonia.logic.Tetromino.java

private static Color tetrominoColor(float angle) {
    int rgb = Color.HSBtoRGB(angle / 360.0f, SATURATION, BRIGHTNESS);
    return new Color(rgb);
}

From source file:vazkii.psi.common.item.component.ItemCADColorizer.java

@Override
public int getColor(ItemStack stack) {
    if (stack.getItemDamage() < 16)
        return ItemDye.dyeColors[15 - stack.getItemDamage()];

    switch (stack.getItemDamage()) {
    case 16: {/*from   w w w.  ja  v a 2 s.c  o m*/
        float time = ClientTickHandler.total;
        return Color.HSBtoRGB(time * 0.005F, 1F, 1F);
    }
    case 17:
        float time = ClientTickHandler.total;
        float w = (float) (Math.sin(time * 0.4) * 0.5 + 0.5) * 0.1F;
        float r = (float) (Math.sin(time * 0.1) * 0.5 + 0.5) * 0.5F + 0.25F + w;
        float g = 0.5F + w;
        float b = 1F;

        return new Color((int) (r * 255), (int) (g * 255), (int) (b * 255)).getRGB();
    }

    return 0xFFFFFF;
}