Java RGB Color Create RGB(float R, float G, float B)

Here you can find the source of RGB(float R, float G, float B)

Description

Constructs a color given 3 RGB values.

License

Open Source License

Parameter

Parameter Description
R red component
G green component
B blue component

Return

string representation of color

Declaration

public static String RGB(float R, float G, float B) 

Method Source Code

//package com.java2s;

public class Main {
    private static final char[] hd = { '0', '1', '2', '3', '4', '5', '6',
            '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };

    /** //from  www  . ja va2 s.c om
     * Constructs a color given 3 RGB values.
     * All values should be between 0 and 1.
     * @param R red component
     * @param G green component
     * @param B blue component
     * @return string representation of color
     */
    public static String RGB(float R, float G, float B) {
        byte r = (byte) (255 * R);
        byte g = (byte) (255 * G);
        byte b = (byte) (255 * B);
        return "#" + hd[r >> 4] + hd[r & 15] + hd[g >> 4] + hd[g & 15]
                + hd[b >> 4] + hd[b & 15];
    }
}

Related

  1. makeIcon(int width, int height, int[] rgb)
  2. makeLinear_sRGBCM(boolean premult)
  3. makeRgbImage(int[][] rbgImage)
  4. msAccesToRGBa(int code)
  5. newRGBImage(int[] rgb, int width, int height, boolean processAlpha)
  6. rgb(float rIn, float gIn, float bIn)
  7. rgb(int a, int r, int g, int b)
  8. rgb(int argb)
  9. rgb(int pixel)