public static LED operator -(LED lhs, LED rhs) { LED nL = new LED(); nL.setRClamped(lhs.R - rhs.R); nL.setGClamped(lhs.G - rhs.G); return(nL); }
// fade both R & G public static LED operator --(LED rhs) { LED nL = new LED(rhs.R, rhs.G); nL.decR(); nL.decG(); return(nL); }
// brighten both R & G public static LED operator ++(LED rhs) { LED nL = new LED(rhs.R, rhs.G); nL.incR(); nL.incG(); return(nL); }
public void SetDiscardable(Int32 x, Int32 y, LED led) { if (Dims.Discardable(x, y)) { return; } Data[x, y] = led; }
public void ShiftRow(Int32 y, Int32 amount, bool wrap) { // copy the row in question LED[] row = new LED[Dims.LEDs]; for (Int32 x = 0; x < Dims.LEDs; x++) { row[x] = Data[x, y]; } // apply the shift for (Int32 x = 0; x < Dims.LEDs; x++) { Int32 offsetX = x + amount; if (wrap) { SetWrap(offsetX, y, row[x]); } else { SetDiscardable(offsetX, y, row[x]); } } }
public void ShiftColumn(Int32 x, Int32 amount, bool wrap) { // copy the column in question LED[] col = new LED[Dims.LEDs]; for (Int32 y = 0; y < Dims.LEDs; y++) { col[y] = Data[x, y]; } // apply the shift for (Int32 y = 0; y < Dims.LEDs; y++) { Int32 offsetY = y + amount; if (wrap) { SetWrap(x, offsetY, col[y]); } else { SetDiscardable(x, offsetY, col[y]); } } }
static public void Gradient(float t, GradientColouring gColouring, GradientStyle gStyle, ref LED result) { Byte[] A = new Byte[11] { 1, 2, 3, 3, 3, 3, 2, 1, 0, 0, 0 }; Byte[] B = new Byte[11] { 0, 0, 0, 1, 2, 3, 3, 3, 3, 2, 1 }; if (t < 0.0f) { t = 0.0f; } if (t > 1.0f) { t = 1.0f; } int index = (int)(t * ((gStyle == GradientStyle.Half) ? 5.0f : 10.0f)); if (gColouring == GradientColouring.RedFirst || gColouring == GradientColouring.RedOnly) { result.R = A[index]; if (gColouring == GradientColouring.RedOnly) { result.G = 0; } else { result.G = B[index]; } } else { result.G = A[index]; if (gColouring == GradientColouring.GreenOnly) { result.R = 0; } else { result.R = B[index]; } } }
public LED(LED rhs) { _R = rhs._R; _G = rhs._G; }
public void SetWrap(Int32 x, Int32 y, LED led) { Dims.Wrap(ref x, ref y); Data[x, y] = led; }
public void SetClamp(Int32 x, Int32 y, LED led) { Dims.Clamp(ref x, ref y); Data[x, y] = led; }
public SolidBrush BrushForLED(ref LED led) { return(m_ledBrushes[led.R, led.G]); }