Here you can find the source of RGB(float R, float G, float B)
Parameter | Description |
---|---|
R | red component |
G | green component |
B | blue component |
public static String RGB(float R, float G, float B)
//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]; } }