void Run() { var start = new Vector2i(Width / 2, Height / 2); //start with one pixel colored SetPixel(start, ColorSource.Get()); while (running && ColorSource.Count > 0 && front.Count > 0) { Color4b color = ColorSource.Get(); int bestScore = int.MaxValue; Vector2i bestPos = new Vector2i(); foreach (var v in front) { int score = GetScore(v, color); if (score < bestScore) { bestScore = score; bestPos = v; } } front.Remove(bestPos); SetPixel(bestPos, color); } }
void Run() { colorSource = new ColorSource(imageWidth, imageHeight, 0); generator = new Generator(imageWidth, imageHeight, colorSource); CreateWindow(); CreateInstance(); CreateSurface(); PickPhysicalDevice(); PickQueues(); CreateDevice(); CreateSwapchain(); CreateImageViews(); CreateRenderPass(); CreateDescriptorSetLayout(); CreateGraphicsPipeline(); CreateFramebuffers(); CreateCommandPool(); CreateStagingBuffer(); CreateTextureImage(); CreateTextureImageView(); CreateTextureSampler(); CreateVertexBuffer(); CreateIndexBuffer(); CreateUniformBuffer(); CreateDescriptorPool(); CreateDescriptorSet(); CreateCommandBuffers(); CreateSyncObjects(); MainLoop(); }
public Generator(int width, int height, ColorSource colorSource) { if (colorSource == null) { throw new ArgumentNullException(nameof(colorSource)); } ColorSource = colorSource; Width = width; Height = height; Pixels = new Color4b[width * height]; scratch = new Color4b[Width * Height]; front = new HashSet <Vector2i>(); thread = new Thread(Run); }