static RGBImage mergeImagePartsHorizontally(RGBImage img, L rects) { RGB spaceColor = new RGB(0.9f); int spacing = imageMergeSpacing(); if (l(rects) == 0) ret new RGBImage(1, 1, spaceColor); int w = intSum(rects, "w")+(l(rects)-1)*spacing, h = intMax(rects, "h"); RGBImage out = new RGBImage(w, h, spaceColor); int x = 0; for i over rects: { Rect r = rects.get(i); int y = (h-r.h)/2; copyRGBImage(img, r.x, r.y, out, x, y, r.w, r.h); x += r.w + spacing; } ret out; }