Title Banner

Previous Book Contents Book Index Next

Newton Developer Technical Information: Newton Programmer's Guide: 2.1 OS Addendum /
Chapter 6 - Drawing and Graphics 2.1 / Using Drawing and Graphics in the Newton 2.1 OS


New Graphic Shape Utility Functions

This section defines a few new utility functions.

The FindShape Function

The new *FindShape function has been provided to overcome some of the deficiencies of HitShape. Since changing HitShape would break existing code, this new function has been introduced. HitShape is now a deprecated function, use *FindShape from now on.

This new function differs from HitShape in the following ways:

The GetPointsArrayXY Function

The GetPointsArray function has existed since the Newton 1.0 OS. It accepts a unit, which is passed in to a ViewWordScript, ViewStrokeScript, or ViewGestureScript method, and returns an array of points in that unit. It returns the points in (y,x) order. That is, the first array element is the first point's y coordinate, the second is its x coordinate, the third is the next point's y coordinate, and so on. The new function *GetPointsArrayXY does the same thing, only that the coordinates are in (x,y) order.

The MungeShape Function

The *MungeShape function can flip a shape or rotate it 90û to the right. The MungeBitmap function has existed since Newton 2.0 OS, it similarly flips and rotates bitmaps. The following code example illustrates the use of the *MungeShape function:

//this is in a ViewDrawScript

local oval := MakeOval (5,5,100,25); //a short and fat oval :DrawShape(oval, {fillPattern: kRGB_Gray3}); //now draw it tall and skinny on top of the original oval MungeShape(oval, 'rotateRight, nil); :DrawShape(oval, {fillPattern: kRGB_Black, transferMode: modeXor});

The above code generated Figure 6-8 on page 6-20.

Figure 6-8 Overlapping ovals



The GetMaskedPixel Function

*GetMaskedPixel augments the existing function PtInPicture. PtInPicture determines whether a specific point is a black pixel in a black and white bitmap. *GetMaskedPixel returns the value of a pixel in a color picture. This function considers the effect of a mask.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
26 APR 1997



Navigation graphic, see text links

Main | Top of Section | What's New | Apple Computer, Inc. | Find It | Feedback | Help