RectStretch: Stretch.StretchProc =
BEGIN
PROC [obj: CD.ObPtr, design: CD.Design, place: INT, dir: Direction, amount: INT] RETURNS [CD.ObPtr, Rope.ROPE];
nObj: CD.ObPtr;
nSize: CD.DesignPosition ← obj.size;
IF dir = $right
OR dir = $left
THEN {
IF place > nSize.x OR place < 0 THEN RETURN[NIL, "Program tried to stretch a rectangle ouside of its boundaries"];
nSize.x ← nSize.x + amount;
}
ELSE {
IF place > nSize.y OR place < 0 THEN RETURN[NIL, "Program tried to stretch a rectangle ouside of its boundaries"];
nSize.y ← nSize.y + amount;
};
SELECT obj.p.objectType
FROM
$Rect => nObj ← CDRects.CreateBareRect[nSize, obj.level];
$SaveRect => nObj ← CDRects.CreateSaveRect[nSize, obj.level];
ENDCASE => RETURN[NIL, "Program called StretchRect to stretch something other than a rectangle"];
nObj.properties ← CDProperties.CopyProps[obj.properties];
RETURN[nObj, NIL];
END;