public void MimickMostUsed(Nanoleaf nanoleaf) { Stopwatch timer = null; Bitmap bitmap = null; while (true) { timer = new Stopwatch(); timer.Start(); bitmap = ImageAnalysis.CaptureBitmap(1); if (bitmap == null) { JArray colors = PaletteController.RandomPalette(1, maxBrightness: 0); lightController.CreateCustom(nanoleaf, colors, 10, 10); } else { int paletteCount = 12; var mostUsed = ImageAnalysis.GetColorsFromImage(bitmap, paletteCount); JArray palette = new JArray(); foreach (LCColor color in mostUsed) { LCColor lcc = new LCColor("rgb", color.r, color.g, color.b); palette.Add(lcc); } lightController.CreateCustom(nanoleaf, palette, 5, 50, animType: "random"); } timer.Stop(); CalcAverage(timer.ElapsedMilliseconds); } }
public void MimickAverage(Nanoleaf nanoleaf) { JArray palette = null; Stopwatch timer = null; Bitmap bitmap = null; while (true) { palette = new JArray(); timer = new Stopwatch(); timer.Start(); bitmap = ImageAnalysis.CaptureBitmap(1); if (bitmap == null) { palette = PaletteController.RandomPalette(1, maxBrightness: 0); } else { int paletteCount = 12; var averages = ImageAnalysis.ReduceColors(ImageAnalysis.GetAverageColors(bitmap, 1, 1), true, paletteCount); throw new Exception(); foreach (LCColor color in averages) { palette.Add(new LCColor("rgb", color.r, color.g, color.b).RGBJO); } } lightController.CreateCustom(nanoleaf, palette, 5, 50, animType: "random"); timer.Stop(); CalcAverage(timer.ElapsedMilliseconds); } }
public void Screenshot(Nanoleaf nanoleaf) { List <LCColor> palette = null; Bitmap bitmap = null; string body = lightController.Get(nanoleaf, "/panelLayout/layout")["body"]; List <Panel> panels = Panel.GetPanels(body); int paletteCount = panels.Count; Tuple <int, int> gcd = ImageAnalysis.DivideScreen(paletteCount); palette = new List <LCColor>(); bitmap = ImageAnalysis.CaptureBitmap(0); if (bitmap == null) { palette.Add(new LCColor(Color.Black)); } else { //palette = ImageAnalysis.ReduceColors(ImageAnalysis.GetAverageColors(bitmap, gcd.Item1, gcd.Item2), true, paletteCount); palette = ImageAnalysis.GetAverageColors(bitmap, gcd.Item1, gcd.Item2, borderReduction: 300); } lightController.CreateCustom(nanoleaf, PaletteController.ToJArray(palette)); }
public Dictionary <string, string> RandomStatic(Nanoleaf nanoleaf) { Dictionary <string, int> settings = PaletteController.Random().HSBtoDict(); return(SetState(nanoleaf, settings, 1000)); }