!752 !include #1004681 // Concepts sS imageID = "#1002132"; static RGBImage image; static ImageSurface imageSurface; static Choice c; // Choice currently displayed sclass Choice extends Concept { int x, y; // color values in RRGGBB S lua; bool[] mark; } p { loadConceptsFrom("#1004895"); image = loadImage(imageID); int w = image.getWidth(), h = image.getHeight(); c = conceptOfType(Choice.class); bool[] mark = cloneArray(c.mark); fillVertical(mark, w, h, 10); imageSurface = showImage(greenWhiteMarkedImage(image, mark)); } static void fillVertical(bool[] mark, int w, int h, int fillh) { for (int x = 0; x < w; x++) { for (int y = 0; y < h; y++) { if (!mark[y*w+x]) continue; while (y < h && mark[y*w+x]) ++y; int y2 = y+1; while (y2 < h && !mark[y2*w+x]) ++y2; if (y2 >= h) break; // y = first unset pixel, y2 = first set pixel int len = y2-y; if (len <= fillh) while (y < y2) mark[(y++)*w+x] = true; else y = y2; --y; } } }