Helper to validate and write the RGB color components
@param   red     the intensity of red. A value between 0 and 1
@param   green   the intensity of green. A value between 0 and 1
@param   blue    the intensity of blue. A value between 0 and 1
345691
private void HelperRGB(float red, float green, float blue) {
    	PdfXConformanceImp.checkPDFXConformance(writer, PdfXConformanceImp.PDFXKEY_RGB, null);
        if (red < 0)
            red = 0.0f;
        else if (red > 1.0f)
            red = 1.0f;
        if (green < 0)
            green = 0.0f;
        else if (green > 1.0f)
            green = 1.0f;
        if (blue < 0)
            blue = 0.0f;
        else if (blue > 1.0f)
            blue = 1.0f;
        content.append(red).append(' ').append(green).append(' ').append(blue);
    }
1299822
public function setLightAmbientColor($red, $green, $blue)
    {
        $this->lightAmbientColor = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue);
        return $this;
    }
500229
@SuppressWarnings({ "checkstyle:magicnumber", "static-method" })
	@Pure
	public Color rgba(int color) {
		final int alpha = (color & 0xFF000000) >> 24;
		final int red = (color & 0x00FF0000) >> 16;
		final int green = (color & 0x0000FF00) >> 8;
		final int blue = color & 0x000000FF;
		final double opacity;
		switch (alpha) {
		case 0:
			opacity = 0.;
			break;
		case 255:
			opacity = 1.;
			break;
		default:
			opacity = ((double) alpha) / 255;
		}
		return Color.rgb(red, green, blue, opacity);
	}
121263
public void setEmissive(float red, float green, float blue){
        emissive[0] = red;
        emissive[1] = green;
        emissive[2] = blue;
        Em = true;
    }
256026
public static function fromRgb(int $red, int $green, int $blue): Color
    {
        if (!Validator::isValidRgb($red, $green, $blue)) {
            throw new InvalidColorException('Invalid RGB values');
        }

        return new self($red, $green, $blue);
    }
378642
private static double calculateHue(double red, double green, double blue, double max, double chroma) {

    if (chroma == 0) {
      return 0;
    } else {
      double hue;
      if (red == max) {
        hue = (green - blue) / chroma;
      } else if (green == max) {
        hue = (blue - red) / chroma + 2;
      } else {
        hue = (red - green) / chroma + 4;
      }
      hue = hue * 60.0;
      if (hue < 0) {
        hue = hue + Hue.MAX_VALUE;
      }
      return hue;
    }
  }
1096388
public void setClearColor (float red, float green, float blue, float alpha) {
    cred = red; cgreen = green; cblue = blue; calpha = alpha;
  }
1129690
public void setLighter(Color color)
	{
		int red   = Math.min(255, (int)(color.getRed() * 1.2));
		int green = Math.min(255, (int)(color.getGreen() * 1.2));
		int blue  = Math.min(255, (int)(color.getBlue() * 1.2));
		setColor(new Color(red, green, blue));
	}
502092
public void setGradationColor(GradationMode3D mode, Color color1, Color color2) {
        setGradation(true);
        if (startColor == null || endColor == null) {
            startColor = new RGBColor(0.0, 0.0, 0.0);
            endColor = new RGBColor(0.0, 0.0, 0.0);
        }
        startColor = color1;
        endColor = color2;
        this.mode = mode;

        setGradationCorner();
    }
1016083
def setColor(self, color):
        ''''''
        if color == 'blue':
            self.color = 'blue'
            self.colorCode = self.colors['blue']
            self.colorCodeDark = self.colors['dblue']
        elif color == 'red':
            self.color = 'red'
            self.colorCode = self.colors['red']
            self.colorCodeDark = self.colors['dred']
        elif color == 'yellow':
            self.color = 'yellow'
            self.colorCode = self.colors['yellow']
            self.colorCodeDark = self.colors['dyellow']
        elif color == 'green':
            self.color = 'green'
            self.colorCode = self.colors['green']
            self.colorCodeDark = self.colors['dgreen']
        elif color == 'wild':  # No color modification
            self.wild = True
            self.color = 'wild'
            self.colorCodeDark = self.colors['dwild']
            self.colorCode = self.colors['wild']
948363
private static int toAnsi(long color)
    {
        if (color >= 0) { // an rgb value encoded as in Color.getRGB
            return toAnsi(getRed(color), getGreen(color), getBlue(color));
        }
        else {
            return (int) (-color - 1);
        }
    }
704891
public int getIndexForColor(int rgb) {
		int red = (rgb >> 16) & 0xff;
		int green = (rgb >> 8) & 0xff;
		int blue = rgb & 0xff;

		OctTreeNode node = root;

		for (int level = 0; level <= MAX_LEVEL; level++) {
			OctTreeNode child;
			int bit = 0x80 >> level;

			int index = 0;
			if ((red & bit) != 0)
				index += 4;
			if ((green & bit) != 0)
				index += 2;
			if ((blue & bit) != 0)
				index += 1;

			child = node.leaf[index];

			if (child == null)
				return node.index;
			else if (child.isLeaf)
				return child.index;
			else
				node = child;
		}
		System.out.println("getIndexForColor failed");
		return 0;
	}
699469
public void setIntColor(int x, int y, int c0, int c1, int c2) {
        int alpha = (arrIntColor[((y * width + x))] & 0xFF000000) >>> 24;
        setIntColor(x, y, alpha, c0, c1, c2);
    }
236091
public function setFogColor($red, $green, $blue)
    {
        $this->fogColor = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue);
        return $this;
    }
496215
public function setCloudsMinimumColor($red, $green, $blue)
    {
        $this->cloudsMinimumColor = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue);
        return $this;
    }
245818
def set_color(self, red, green, blue):
        
        if self._pwm_enabled:
            # Set duty cycle of PWM pins.
            rdc, gdc, bdc = self._rgb_to_duty_cycle((red, green, blue))
            self._red.pwm_start(rdc)
            self._green.pwm.start(gdc)
            self._blue.pwm.start(bdc)
        else:
            # Set appropriate backlight pins based on polarity and enabled colors.
            self._red.set(self._blpol if red else not self._blpol)
            self._green.set(self._blpol if green else not self._blpol)
            self._blue.set(self._blpol if blue else not self._blpol)
714588
public static String toColor(String red, String green, String blue) {
		return toColorWithAlpha(red, green, blue, null);
	}