protected override Image <Rgba32> Run() { TimeSpan countDownSpan = timeSpan - stopwatch.Elapsed; string displayText; Color color = Color.White; FontFamily fo; SystemFonts.TryFind("Times New Roman", out fo); Font font = new Font(fo, 20, FontStyle.Regular); if (countDownSpan.TotalSeconds > 11) { font = new Font(fo, 20, FontStyle.Regular); string hours = string.Empty; string minutes = string.Empty; string seconds = string.Empty; if (countDownSpan.Hours > 0) { hours = "0" + countDownSpan.Hours.ToString(); hours = hours.Substring(hours.Length - 2) + ":"; } minutes = "0" + countDownSpan.Minutes.ToString(); minutes = minutes.Substring(minutes.Length - 2) + ":"; seconds = "0" + countDownSpan.Seconds.ToString(); seconds = seconds.Substring(seconds.Length - 2); displayText = hours + minutes + seconds; } else if (countDownSpan.TotalSeconds <= 1) { displayText = string.Empty; } else { font = new Font(fo, 35, FontStyle.Regular); displayText = countDownSpan.Seconds.ToString(); color = color.WithAlpha(LEDEngine3D.Map(countDownSpan.Milliseconds, 1, 1000, 0f, 1f)); } FontRectangle size = TextMeasurer.Measure( displayText, new RendererOptions(font)); image = new Image <Rgba32>(LEDWidth, LEDHeight); SetBackgroundColor(image); image.Mutate(c => c.DrawText( displayText, font, color, new PointF((image.Width - size.Width) / 2, (image.Height - size.Height) / 2))); return(image); }
private void updateTriangles() { List <Triangle> triangles = new List <Triangle>(); for (int y = 0; y < scaleGrid - 1; y++) { for (int x = 0; x < scaleGrid - 1; x++) { triangles.Add(new Triangle(new List <Vector3D>() { new Vector3D(LEDEngine3D.Map(x, 0, scaleGrid - 1, 0, 1), LEDEngine3D.Map(y + 1, 0, scaleGrid - 1, 0, 1), perlin.perlin(LEDEngine3D.Map(x, 0, scaleGrid - 1, 0, 1), y + 1 + offsetY)), //1 new Vector3D(LEDEngine3D.Map(x + 1, 0, scaleGrid - 1, 0, 1), LEDEngine3D.Map(y, 0, scaleGrid - 1, 0, 1), perlin.perlin(LEDEngine3D.Map(x + 1, 0, scaleGrid - 1, 0, 1), y + offsetY)), //3 new Vector3D(LEDEngine3D.Map(x, 0, scaleGrid - 1, 0, 1), LEDEngine3D.Map(y, 0, scaleGrid - 1, 0, 1), perlin.perlin(LEDEngine3D.Map(x, 0, scaleGrid - 1, 0, 1), y + offsetY)), //2 }, new List <Vector2D>() { new Vector2D(0.0f, LEDEngine3D.Map(y, 0, scaleGrid - 1, 0, 1), 1.0f), new Vector2D(0.0f, 0.0f, 1.0f), new Vector2D(LEDEngine3D.Map(x, 0, scaleGrid - 1, 0, 1), 0.0f, 1.0f), } )); triangles.Add(new Triangle(new List <Vector3D>() { new Vector3D(LEDEngine3D.Map(x, 0, scaleGrid - 1, 0, 1), LEDEngine3D.Map(y + 1, 0, scaleGrid - 1, 0, 1), perlin.perlin(LEDEngine3D.Map(x, 0, scaleGrid - 1, 0, 1), y + 1 + offsetY)), new Vector3D(LEDEngine3D.Map(x + 1, 0, scaleGrid - 1, 0, 1), LEDEngine3D.Map(y + 1, 0, scaleGrid - 1, 0, 1), perlin.perlin(LEDEngine3D.Map(x + 1, 0, scaleGrid - 1, 0, 1), y + 1 + offsetY)), new Vector3D(LEDEngine3D.Map(x + 1, 0, scaleGrid - 1, 0, 1), LEDEngine3D.Map(y, 0, scaleGrid - 1, 0, 1), perlin.perlin(LEDEngine3D.Map(x + 1, 0, scaleGrid - 1, 0, 1), y + offsetY)), }, new List <Vector2D>() { new Vector2D(0.0f, LEDEngine3D.Map(y, 0, scaleGrid - 1, 0, 1), 1.0f), new Vector2D(LEDEngine3D.Map(x, 0, scaleGrid - 1, 0, 1), 0.0f, 1.0f), new Vector2D(LEDEngine3D.Map(x, 0, scaleGrid - 1, 0, 1), LEDEngine3D.Map(y, 0, scaleGrid - 1, 0, 1), 1.0f), } )); } } meshCube.Tris = triangles; offsetY += 1f; }