public IEnumerable <Color> Execute(IFxContext ctx) { var secondsPerCycle = (1.0 / CyclesPerSecond); var posBase = (ctx.TimeNow.TotalSeconds % secondsPerCycle) / secondsPerCycle * 2; var posShift = false; while (true) { ColorReal clr = BaseColour; clr.Saturation = Saturation; var pos = posBase; if (posShift) { pos = (posBase + 1) % 2; } posShift = !posShift; if (pos > 1) { clr.Luminance = LumLow + ((2 - pos) * (LumHigh - LumLow)); } else { clr.Luminance = LumLow + (pos * (LumHigh - LumLow)); } yield return(clr); posBase += StridePerPixel; if (posBase > 2) { posBase -= 2; } } }
public Flare(int p_pixel, ColorReal p_colour, double p_step) { m_pixel = p_pixel; m_clr = p_colour; m_clr.Luminance = 0; m_asc = true; m_step = p_step; }
static void SendCylon() { var payload = new byte[150]; cylonpos += cylondir; if (cylonpos >= 49) { cylondir = -1; } else if (cylonpos <= 0) { cylondir = 1; } cylonclr.Luminance += cylonclrstep; if (cylonclr.Luminance > 0.5 || cylonclr.Luminance < 0.01) { cylonclrstep = 0 - cylonclrstep; } ColorReal overbright = new ColorReal(cylonclr); overbright.Luminance += 0.3; Color clr = cylonclr; int ordinal = cylonpos * 3; if (ordinal > 0) { payload[ordinal - 3 + 0] = clr.B; payload[ordinal - 3 + 1] = clr.R; payload[ordinal - 3 + 2] = clr.G; } if (ordinal <= 144) { payload[ordinal + 3 + 0] = clr.B; payload[ordinal + 3 + 1] = clr.R; payload[ordinal + 3 + 2] = clr.G; } clr = overbright; payload[ordinal + 0] = clr.B; payload[ordinal + 1] = clr.R; payload[ordinal + 2] = clr.G; Send(payload); }
public IEnumerable <Color> Execute(IFxContext ctx) { ColorReal rc = Color.Red; // any RGB primary color will do as a seed double hueStridePerPixel = 1.0 / HueCyclePixelLength; if (ctx.TimeLength.TotalSeconds > 0.0) { rc.Hue = ctx.TimeNow.TotalSeconds / ctx.TimeLength.TotalSeconds; } else { rc.Hue = (ctx.TimeNow.TotalSeconds % HueSecondsPerCycle) / HueSecondsPerCycle; } while (true) { yield return(rc); rc.Hue -= hueStridePerPixel; } }