beautypg.com

Transforming a shape 13 – Apple Newton Programmer’s Newton 2.0 (for Newton 2.0) User Manual

Page 539

background image

C H A P T E R 1 3

Drawing and Graphics

Using the Drawing Interface

13-13

If the style frame includes a

clipping

slot, the drawing of all shapes affected by

this style frame is clipped according to the value of the

clipping

slot. If the

value of the

clipping

slot is

nil

or if the

clipping

slot is not supplied, the

clipping behavior of the destination view is used.

If the

clipping

slot contains a region shape, that region is used as the clipping

boundary for drawing operations affected by this style frame. If the

clipping

slot

contains an array of shapes or regions, the system passes the contents of the

clipping

slot to the

MakeRegion

function to automatically create a new

clipping region from the contents of this slot.

Note

Although putting an array of shapes in the

clipping

slot may

seem convenient, it significantly increases the time required to
process the style frame. For best performance from the view
system, do not use this shortcut in style frames that are used
repeatedly.

Transforming a Shape

13

The

transform

slot changes the size or location of a shape without altering the

shape itself. It accepts an array specifying an

x

,

y

coordinate pair or a pair of

rectangles. The

x

,

y

coordinate arguments relocate a shape by specifying an offset

from the origin of the destination view’s coordinate plane. The rectangle arguments
specify a mapping of the source and destination views that alters both the size and
location (offset) of the source view when it is drawn in the destination view.

The rectangle arguments work the same way as the parameters to the

ScaleShape

function (although transforms won’t accept

nil

for the boundaries

of the source rectangle): the size of the shape is changed proportionately according
to the dimensions of the destination rectangle, and the coordinates of the
destination rectangle can also be used to draw the shape in a new location.

The following code fragments demonstrate the use of offset coordinates and
mapping rectangles as the value of the

transform

slot:

transform: [30,50],// offset shapes by 30 h and 50 v

or

transform:

[SetBounds(0,0,100,100),SetBounds(25,25,75,75)],

// half width and height, centered in relation to

// the original object(not the view) assuming that

// the first rect actually specified correct bounds