ELSE {
newbox: DeviceRectangle ← [s, f, r.sSize, r.fSize];
sDelta: INTEGER ← s - r.sMin;
fDelta: INTEGER ← f - r.fMin;
old: ImagerManhattan.Polygon ← ImagerManhattan.CreateFromBox[r];
new: ImagerManhattan.Polygon ← ImagerManhattan.CreateFromBox[newbox];
goodBigBits: ImagerManhattan.Polygon ← GoodBigBits[];
GoodBigBits:
PROC
RETURNS [ImagerManhattan.Polygon] ~ {
b: DeviceRectangle ← [r.sMin+1, r.fMin+1, r.sSize-2, r.fSize-2];
b ← ImagerPixelMaps.Intersect[b, displayBounds];
b.sMin ← b.sMin - sDelta;
b.fMin ← b.fMin - fDelta;
b ← ImagerPixelMaps.Intersect[b, displayBounds];
RETURN [ImagerManhattan.CreateFromBox[b]]
};
toRestoreFromSmall: ImagerManhattan.Polygon ← old.Difference[new];
toSaveIntoSmall: ImagerManhattan.Polygon ← new.Difference[old];
toRecompute: ImagerManhattan.Polygon ← new.Difference[goodBigBits];
big.Clip[newbox].Transfer[big.ShiftMap[-sDelta, -fDelta]];
FOR p:
LIST
OF DeviceRectangle ← toRestoreFromSmall, p.rest
UNTIL p=
NIL
DO
big.Transfer[small.Clip[p.first]];
ENDLOOP;
small.Transfer[small.ShiftMap[-sDelta, -fDelta]];
small.sOrigin ← small.sOrigin + sDelta;
small.fOrigin ← small.fOrigin + fDelta;
big.sMin ← big.sMin + sDelta;
big.fMin ← big.fMin + fDelta;
FOR p:
LIST
OF DeviceRectangle ← toSaveIntoSmall, p.rest
UNTIL p=
NIL
DO
small.Transfer[big.Clip[p.first]];
ENDLOOP;
FOR p:
LIST
OF DeviceRectangle ← toRecompute, p.rest
UNTIL p=
NIL
DO
box: DeviceRectangle ← p.first;
centeredBig: PixelMap ← big.ShiftMap[-newbox.sMin - height/2, -newbox.fMin-width/2];
centeredSmall: PixelMap ← small.ShiftMap[-newbox.sMin - height/2, -newbox.fMin-width/2];
box.sMin ← box.sMin - newbox.sMin - height/2;
box.fMin ← box.fMin - newbox.fMin - width/2;
BitDouble[centeredBig.Clip[box], centeredSmall];
ENDLOOP;
big.Fill[[newbox.sMin, newbox.fMin, 1, newbox.fSize], 0];
big.Fill[[newbox.sMin + newbox.sSize - 1, newbox.fMin, 1, newbox.fSize], 0];
big.Fill[[newbox.sMin, newbox.fMin, newbox.sSize, 1], 0];
big.Fill[[newbox.sMin, newbox.fMin + newbox.fSize - 1, newbox.sSize, 1], 0];
old.Destroy;
new.Destroy;
goodBigBits.Destroy;
toRestoreFromSmall.Destroy;
toRecompute.Destroy;
};