public override void Paint() { for (int i = 0; i < strip.led_count; i++) { strip[i] = RGBWColor.FromHSV(i + count, 1, 1); } }
public void Fill(int start, int end, RGBWColor c, FillType mode = FillType.Set) { switch (mode) { case FillType.Set: for (int i = start; i <= end; i++) { this[i] = c; } break; case FillType.Add: for (int i = start; i <= end; i++) { this[i] += c; } break; case FillType.Factor: var width = end - start; var half = width / 2; for (int i = 0; i < width; i++) { this[start + i] += c * Math.Abs(i / half); } break; } }
public override async Task Render() { lastRender = DateTime.UtcNow; conditions = await Services.Weather.GetConditions(); text = Math.Round(conditions.TempF); color = CurrentColor(Services.Sun.NightMode, conditions.Weather); }
public RGBColor(RGBWColor c) { var rgb = c.toRGB(); this.r = rgb.r; this.g = rgb.g; this.b = rgb.b; }
// Note: this doesn't handle the sub-1px case public void Fill(double start, double end, RGBWColor c, FillType mode = FillType.Set) { if (start == end) { return; } var width = (int)Math.Ceiling(end - start); switch (mode) { case FillType.Set: Fill((int)Math.Floor(start), (int)Math.Ceiling(end), new RGBWColor(0, 0, 0, 0), FillType.Set); Fill(start, end, c, FillType.Add); break; case FillType.Add: for (int i = -1; i < width + 1; i++) { var a = (int)Math.Floor(start + i); var b = (int)Math.Ceiling(start + i); if (a >= 0 && a < led_count && i >= 0) { this[a] += BlendStart(start + i, c); } if (b >= 0 && b < led_count && i < width) { this[b] += BlendEnd(start + i, c); } } break; case FillType.Factor: var half = width / 2.0; for (int i = -1; i < width + 1; i++) { var newc = c * (1 - Math.Abs((i - half) / half)); var a = (int)Math.Floor(start + i); var b = (int)Math.Ceiling(start + i); if (a >= 0 && a < led_count && i >= 0) { this[a] += BlendStart(start + i, newc); } if (b >= 0 && b < led_count && i < width) { this[b] += BlendEnd(start + i, newc); } } break; } }
public override void Initialize(IStrip s, PluginConfig config) { base.Initialize(s, config); DayColor = RGBWColor.Parse((string)config["day"]); NightColor = RGBWColor.Parse((string)config["night"]); Services.Sun.OnSunEvent += (ev) => { if (enabled) { _smudged = true; } }; }
public override void Paint() { // Pick color var color = new RGBWColor(25, 0, 0, 0); // Render for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { if (state[x, y]) { s2d[x, y] = color; } else { s2d[x, y] = new RGBWColor(0, 0, 0, 0); } } } }
public override void Paint() { var time = DateTime.UtcNow; var minuteColor = new RGBWColor(255, 0, 0, 0); var hourColor = new RGBWColor(0, 0, 255, 0); var secondColor = new RGBWColor(255, 255, 255, 255); if (Services.Sun.NightMode) { minuteColor = new RGBWColor(1, 0, 0, 0); hourColor = new RGBWColor(1, 0, 0, 0); secondColor = new RGBWColor(2, 0, 0, 0); } for (int i = 0; i < strip.led_count; i++) { strip[i] = new RGBWColor(0, 0, 0, 0); } for (int i = 0; i < time.Minute; i += 10) { strip[i] += minuteColor; } for (int i = 0; i <= time.Minute; i++) { strip[i] += minuteColor; } for (int i = 0; i <= time.Hour; i++) { strip[i] += hourColor; } for (int i = 0; i < strip.led_count; i++) { strip[i] *= Services.Sun.Brightness; } strip[time.Second] = secondColor; // * (time.Millisecond / 1000.0); }
public override void Initialize(IStrip s, PluginConfig config) { base.Initialize(s, config); this.Color = RGBWColor.Parse((string)config["color"]); }
private RGBWColor BlendEnd(double pixel, RGBWColor c) { return(c * Math.Abs(pixel - Math.Floor(pixel))); }
private RGBWColor BlendStart(double pixel, RGBWColor c) { return(c * (1 - Math.Abs(pixel - Math.Floor(pixel)))); }
internal override async Task <RGBWColor[]> GetValueForDates(DateTime start, DateTime end) { var days = (end - start).Days; var result = new RGBWColor[days]; var user = await GetProgressStats(days); lastRefresh = DateTime.UtcNow; int i = days - 1; foreach (var day in user.ProgressStats) { var timeStudiedToday = TimeSpan.FromSeconds((double)day.timeStudied.day); RGBWColor color = mapTimeStudiedToColor(timeStudiedToday); result[i] = color; i--; } if (enable_logging && logThis) { // TODO: Iterate through stats objects to find today. This is naive and will break. var today = user.ProgressStats[days - 1]; var pt = new InfluxData.Net.InfluxDb.Models.Point() { Name = "skritter", Fields = new Dictionary <string, object>() { { "timeStudiedToday", today.timeStudied.day }, { "word.rune.remembered", today.word.rune.remembered.day }, { "word.rune.learned", today.word.rune.learned.day }, { "word.rune.studied", today.word.rune.studied.day }, { "word.rune.learning", today.word.rune.learning.day }, { "word.rdng.remembered", today.word.rdng.remembered.day }, { "word.rdng.learned", today.word.rdng.learned.day }, { "word.rdng.studied", today.word.rdng.studied.day }, { "word.rdng.learning", today.word.rdng.learning.day }, { "word.tone.remembered", today.word.tone.remembered.day }, { "word.tone.learned", today.word.tone.learned.day }, { "word.tone.studied", today.word.tone.studied.day }, { "word.tone.learning", today.word.tone.learning.day }, { "word.defn.remembered", today.word.defn.remembered.day }, { "word.defn.learned", today.word.defn.learned.day }, { "word.defn.studied", today.word.defn.studied.day }, { "word.defn.learning", today.word.defn.learning.day }, { "char.rune.remembered", today["char"].rune.remembered.day }, { "char.rune.learned", today["char"].rune.learned.day }, { "char.rune.studied", today["char"].rune.studied.day }, { "char.rune.learning", today["char"].rune.learning.day }, { "char.rdng.remembered", today["char"].rdng.remembered.day }, { "char.rdng.learned", today["char"].rdng.learned.day }, { "char.rdng.studied", today["char"].rdng.studied.day }, { "char.rdng.learning", today["char"].rdng.learning.day }, { "char.tone.remembered", today["char"].tone.remembered.day }, { "char.tone.learned", today["char"].tone.learned.day }, { "char.tone.studied", today["char"].tone.studied.day }, { "char.tone.learning", today["char"].tone.learning.day }, { "char.defn.remembered", today["char"].defn.remembered.day }, { "char.defn.learned", today["char"].defn.learned.day }, { "char.defn.studied", today["char"].defn.studied.day }, { "char.defn.learning", today["char"].defn.learning.day }, }, Timestamp = lastRefresh }; await Services.InfluxDB.WriteAsync(pt); } return(result); }