sclass SimpleScanlineImage { // core value (mandatory): first row occupied int y1; // core value (mandatory): x coordinates per row // x_left is inclusive, x_right is exclusive // // Order in array: // x_left at y1, x_right at y1, // x_left at y1+1, x_right at y1+1, ,,, int[] data; // color is optional Color color = Color.red; // bounds can be calculated quickly from core values simplyCached Rect bounds() { int x1 = Int.MAX_VALUE, x2 = 0; for (int i = 0; i < l(data); i += 2) { x1 = min(x1, data[i]); x2 = max(x2, data[i+1]); } ret rectFromPoints(x1, y1, x2, y2()); } int y2() { ret y+l(data)/2; } }