/// <summary> /// Create A RgbLed Object /// </summary> /// <param name="redPin">Pin connect to red</param> /// <param name="greenPin">Pin connect to green</param> /// <param name="bluePin">Pin connect to blue</param> /// <param name="frequency">PWM Frequency</param> /// <param name="type">RGB LED Electrode Type</param> public RgbLed(int redPin, int greenPin, int bluePin, double frequency, RgbType type) { redPinNum = redPin; greenPinNum = greenPin; bluePinNum = bluePin; pwmFrequency = frequency; this.type = type; }
public RgbColor ToRgb(RgbType type = RgbType.Normalized) { var color = ToCmyk(CmykType.CmyNormalized); var converted = new RgbColor(); converted.R = 1 - color.c; converted.G = 1 - color.m; converted.B = 1 - color.y; return(converted.ToRgb(type)); }
public RgbColor ToRgb(RgbType type = RgbType.Normalized) { RgbColor color; if (type == RgbType.Normalized) { color = this; switch (Type) { case RgbType.Percent: color = new RgbColor(type); color.r = r / 100f; color.g = g / 100f; color.b = b / 100f; break; case RgbType.Byte: color = new RgbColor(type); color.r = r / 255f; color.g = g / 255f; color.b = b / 255f; break; } } else { if (Type == RgbType.Normalized) { color = this; switch (type) { case RgbType.Byte: color = new RgbColor(type); color.r = (int)(r * 255); color.g = (int)(g * 255); color.b = (int)(b * 255); break; case RgbType.Percent: color = new RgbColor(type); color.r = r * 100f; color.g = g * 100f; color.b = b * 100f; break; } } else { color = ToRgb().ToRgb(type); } } return(color); }
public RgbColor ToRgb(RgbType type = RgbType.Normalized) { float[] colors = { x, y, z }; var converted = new RgbColor(); for (int i = 0; i < 3; i++) { converted.R += rgbmatconv[0, i] * colors[i]; converted.G += rgbmatconv[1, i] * colors[i]; converted.B += rgbmatconv[2, i] * colors[i]; } return(converted.ToRgb(type)); }
public RgbColor ToRgb(RgbType type = RgbType.Normalized) { float[] colors = { y, i, q }; var converted = new RgbColor(); for (int j = 0; j < 3; j++) { converted.R += rgbmatconv[0, j] * colors[j]; converted.G += rgbmatconv[1, j] * colors[j]; converted.B += rgbmatconv[2, j] * colors[j]; } return(converted.ToRgb(type)); }
public RgbColor(RgbType type = RgbType.Normalized) { Type = type; }
/// <summary> /// Set an RGB color as the named parameter. A conversion might occur depending on the specified type. /// </summary> /// <param name="name">Name of the parameter as defined by Material.</param> /// <param name="type">Whether the color value is encoded as Linear or sRGB.</param> /// <param name="color">Color value.</param> public void SetParameter(string name, RgbType type, Color color) { ThrowExceptionIfDisposed(); Native.MaterialInstance.SetParameterRgbColor(NativePtr, name, (byte)type, color.R, color.G, color.B); }
public RgbColor ToRgb(RgbType type = RgbType.Normalized) { float hh, p, q, t, ff; long i; RgbColor res = new RgbColor(); if (this.s <= 0.0) { // < is bogus, just shuts up warnthisgs res.R = this.v; res.G = this.v; res.B = this.v; return(res); } hh = this.h; if (hh >= 360.0) { hh = 0.0F; } hh /= 60.0F; i = (long)hh; ff = hh - i; p = this.v * (1.0F - this.s); q = this.v * (1.0F - (this.s * ff)); t = this.v * (1.0F - (this.s * (1.0F - ff))); switch (i) { case 0: res.R = this.v; res.G = t; res.B = p; break; case 1: res.R = q; res.G = this.v; res.B = p; break; case 2: res.R = p; res.G = this.v; res.B = t; break; case 3: res.R = p; res.G = q; res.B = this.v; break; case 4: res.R = t; res.G = p; res.B = this.v; break; case 5: default: res.R = this.v; res.G = p; res.B = q; break; } return(res.ToRgb(type)); }