public static int Part2(string inputText) { var program = new IntCodeProgram(InputParser.ListOfLongs(inputText, ','), 0, 0); var robot = new EHPR(program); robot.Painting.Add(new Vector2Int(0, 0), new List <long>(new long[] { 1 })); robot.Run(); AOCExecutor.ActionForMain.Enqueue(() => WriteToFilePainting(robot.Painting, "Day11_Part2.txt")); var bounds = MathUtils.FindBound(robot.Painting.Keys.ToList()); int xOff = -bounds.xMin; int yOff = -bounds.yMin; Debug.Log(bounds); var image = new int[bounds.size.y + 1, bounds.size.x + 1]; foreach (var pt in robot.Painting) { if (pt.Key.x < bounds.min.x || pt.Key.x > bounds.max.x || pt.Key.y < bounds.min.y || pt.Key.y > bounds.max.y) { Debug.Log($"Contains pas {pt.Key}"); } if (pt.Value.Count == 0) { continue; } var value = pt.Value.Last(); image[bounds.size.y - (pt.Key.y + yOff), pt.Key.x + xOff] = (int)value; } AOCExecutor.ActionForMain.Enqueue(() => Day8Main.ImageToTexturee(image, bounds.size.x + 1, bounds.size.y + 1, AOCUI.Instance.Part1ComputeOutput)); return(2); }
private static void MakeImageForGrid(int[,] orderGrid, int vaporizorX, int vaporizorY) { var w = orderGrid.GetLength(1); var h = orderGrid.GetLength(0); var image = new Color32[h, w]; for (int x = 0; x < w; x++) { for (int y = 0; y < h; y++) { if (orderGrid[y, x] == 0) { image[y, x] = Color.black; } else { image[y, x] = Color.Lerp(Color.white, Color.red, orderGrid[y, x] / 255f); } } } image[vaporizorY, vaporizorX] = Color.green; AOCExecutor.ActionForMain.Enqueue(() => Day8Main.ImageToTexturee(image, w, h, AOCUI.Instance.Part1ComputeOutput)); }