// *{x,y}{1,2} key: d=dest s=src, p=bounds of this picture, i=intersection of s and p, pd = dest of this pic
for(int i=0;i<pics.length;i++) {
for(int j=0;j<pics[i].length;j++) {
- int px1 = j*psize;
- int py1 = i*psize;
- int px2 = min(px1+psize,totalWidth);
- int py2 = min(py1+psize,totalHeight);
- int ix1 = max(px1,cx1);
- int iy1 = max(py1,cy1);
- int ix2 = min(px2,cx2);
- int iy2 = min(py2,cy2);
- if (ix1 >= ix2 || iy1 >= iy2) continue; // no intersection
- pics[i][j].draw(px1, py1, ix1, iy1, ix2, iy2);
+ int px1 = j*psize + dx;
+ int py1 = i*psize + dy;
+ pics[i][j].draw(px1, py1, cx1, cy1, cx2, cy2);
}
}
}