← develop-08 9110 Autum 1991

develop-08 9110 Autum 1991

From the originals

13 scans

Machine-transcribed text and image descriptions. Check the linked original for uncertain words or fine print.

These are transcribed pages from the documents, not the full publications. Open the original for the remaining pages.

Image 1

develop The Apple Technical Journal CURVES AHEAD: WORKING WITH CURVES IN QUICKDRAW VALIDATING DATE AND TIME ENTRY IN MACAPP MACINTOSH DEBUGGING: A WEIRD JOURNEY INTO THE BELLY OF THE BEAST MACINTOSH HYBRID APPLICATIONS FOR A/UX COPYMASK, COPYDEEPMASK, AND LASERWRITER DRIVER 7.0 GWORLDS AND NUBUS MEMORY MACINTOSH Q & A APPLE II Q & A Issue 8 Autumn 1991

A cover with a large bold 'develop' masthead at top right above a stylized blue, teal and magenta vector-curve illustration showing a large white letter S with Bezier control points, and a column of bold uppercase article titles at right.

Reading notes: Masthead letter spacing is wide and the title is rendered in a stylized typeface; transcribed as 'develop' in lowercase as shown. Article titles are stacked in a single column; reading order follows top to bottom.

Printed dates
Autumn 1991
Languages
English
PDF page 1

d e v e l o p T h e A p p l e T e c h n i c a l J o u r n a l CURVES AHEAD: WORKING WITH CURVES IN QUICKDRAW VALIDATING DATE AND TIME ENTRY IN MACAPP MACINTOSH DEBUGGING: A WEIRD JOURNEY INTO THE BELLY OF THE BEAST MACINTOSH HYBRID APPLICATIONS FOR A/UX COPYMASK, COPYDEEPMASK, AND LASERWRITER DRIVER 7.0 GWORLDS AND NUBUS MEMORY MACINTOSH Q & A APPLE II Q & A I ssue 8 Autumn 1991

Reading notes: Transcript is intentionally empty because the exact extracted text is preserved separately; the other fields were filled from the supplied copy only. The masthead 'develop The Apple Technical Journal' is treated as the headline, but it is a masthead and the primary headline is ambiguous. The supplied copy shows letter-spaced masthead text and the issue line as 'I ssue 8 Autumn 1991', which may be a spacing artifact of the 'Issue' word. Product names are drawn from article titles and may include topics rather than advertised products, since this is a contents page rather than an advertisement. Line breaks and reading order of the article titles are taken from the supplied text and may not match the original layout exactly.

Printed product names
QUICKDRAW · MACAPP · MACINTOSH · MACINTOSH Q & A · APPLE II Q & A · A/UX · LASERWRITER · DRIVER 7.0 · GWORLDS · NUBUS MEMORY
Printed dates
Autumn 1991
Languages
English
PDF page 2

E D I T O R I A L S T A F F Editor-in-Cheek Caroline Rose Spirited Guide Louella Pizzuti Technical Buckstopper Dave Johnson Review Board Pete “Luke” Alexander, Chris Derossi, C. K. Haun, Larry Rosenstein, Andy Shebanow, and Gregg Williams Managing Editor Monica Meffert Contributing Editors Lorraine Anderson, Geta Carlson, Toni Haskell, Judy Helfand, Rilla Reynolds, and Carol Westberg Indexer Ira Kleinberg Manager, Developer Support Systems and Communications David Krathwohl A R T & P R O D U C T I O N Production Manager Hartley Lesser Art Director Diane Wilcox Technical Illustration Don Donoughe Formatting Forbes Mill Press Printing Wolfer Printing Company, Inc. Film Preparation Aptos Post, Inc. Production PrePress Assembly Photography Sharon Beals, Ralph Portillo, and Steven C. Johnson Circulation Management David Wilson Online Production Cassi Carpenter d e v e l o p , The Apple Technical Journal, is a quarterly publication of the Developer Support Systems and Communications group. This sinuous cover artwork was made possible by quadratic Bézier curves and TrueType, and was created by Rucker- Huggins (initial studies by Corinne Okada; final arrangement by Cleo Huggins) using Adobe Illustrator 3.0.

Reading notes: The supplied copy was extracted locally and was not verified against the image, so spelling, line breaks, and layout are unconfirmed. No primary headline is evident; the spaced-out 'E D I T O R I A L S T A F F' and 'A R T & P R O D U C T I O N' section labels were not treated as headlines. 'develop, The Apple Technical Journal' is a publication name rather than a clearly advertised product; it is listed as a product name with this caveat. Reading order follows the supplied copy's line sequence; column arrangement in the original page is not confirmed. 'Adobe Illustrator 3.0' is a software version number and was not treated as a printed date.

Languages
English
PDF page 3

CONTENTS Autumn 1991 1 © 1991 Apple Computer, Inc. All rights reserved. Apple, the Apple logo, APDA, AppleCD SC, Apple IIGS, AppleLink, AppleShare, AppleTalk, A/UX, LaserWriter, MacApp, Macintosh, MPW, MultiFinder, and SADE are trademarks of Apple Computer, Inc., registered in the U.S. and other countries. Balloon Help, develop, Finder, QuickDraw, QuickTime, ResEdit, and TrueType are trademarks of Apple Computer, Inc. HyperCard and HyperTalk are registered trademarks of Apple Computer, Inc. licensed to Claris Corporation. Adobe Illustrator and PostScript are registered trademarks of Adobe Systems Incorporated. MacDraw is a registered trademark of Claris Corporation. GRiDPAD is a registered trademark of GRiD Systems Corp. TMON and TMON Professional are trademarks of ICOM Simulations, Inc. Windows is a trademark of Microsoft Corp. THINK C and THINK Pascal are trademarks of Symantec Corp. NuBus is a trademark of Texas Instruments. UNIX is a registered trademark of UNIX System Laboratories. On-line reading versus on-line reference 2 Your letters to us. Keep ’em coming! 4 Curves Ahead: Working With Curves in QuickDraw by Mike Reed and Konstantin Othmer All about quadratic Bézier curves on the Macintosh, including using the curves from TrueType fonts. 7 Validating Date and Time Entry in MacApp by James Plamondon Here’s a new MacApp class that provides robust and flexible entry validation. 28 Macintosh Debugging: A Weird Journey Into the Belly of the Beast by Bo3b Johnson and Fred Huxham This article presents some very useful debugging techniques that every Macintosh developer needs to know about. 43 Macintosh Hybrid Applications for A/UX by John Morley This is an introduction to writing Macintosh applications meant to run under A/UX, explaining the basics and pointing out some potential gotchas. 64 Print Hints From Luke & Zz: CopyMask, CopyDeepMask, and LaserWriter Driver 7.0 by Pete “Luke” Alexander How do you print graphics that use CopyMask and CopyDeepMask with LaserWriter driver 7.0? Read this column to find out. 41 The Veteran Neophyte: Don’t Fence Me In by Dave Johnson Dave waxes philosophical about wirelessness, collaboration, communication, and buffalo heels. 79 Be Our Guest: GWorlds and NuBus Memory by Forrest Tanaka and Paul Snively Taking advantage of NuBus memory for off-screen graphics is tricky. Here are some tips on how to do it in a friendly, compatible way. 95 Answers to your product development questions. Macintosh Q & A 82 Apple II Q & A 92 99 The Developer CD Series Disc Volume X accompanies this issue of develop. Along with the code described in this issue, it contains all back issues of develop and other software and documentation that will make your programming life easier and more interesting. E D I T O R I A L L E T T E R S A R T I C L E S C O L U M N S Q & A I N D E X

Reading notes: Table of contents page numbers and some article titles are run together, so reading order between entries may be uncertain.

Printed product names
Apple IIGS · AppleCD SC · AppleLink · AppleShare · AppleTalk · A/UX · LaserWriter · MacApp · Macintosh · MPW · MultiFinder · SADE · Balloon Help · Finder · QuickDraw · QuickTime · ResEdit · TrueType · HyperCard · HyperTalk · Adobe Illustrator · PostScript · MacDraw · GRiDPAD · TMON · TMON Professional · Windows · THINK C · THINK Pascal · NuBus · UNIX · develop · The Developer CD Series Disc Volume X
Printed dates
Autumn 1991 · 1991
Languages
English
PDF page 4

Dear Readers, I’d like to bring up a subject that’s been on my mind lately and a matter of interest to me—and probably to many of you—for quite some time now. It’s the subject of what we called the “paperless office” as far back as the Seventies, when I worked in the same group as Doug Engelbart, inventor of the mouse. I laughed to myself back then when I’d hear predictions that in ten years or so, manuals would be obsolete. Who needs information in any form other than electronic? Printed manuals persist, but they’re definitely an endangered species. At Apple and many other companies like it, the trend is toward “on-line only” dissemination of information: it uses the technology in zippy ways, it costs less, and it saves trees. Who needs paper, anyway? I myself don’t care if I ever see most memos, notes, reports, and similar daily jottings in print. I prefer to file the majority of this stuff on-line rather than in my physical file cabinets, which I mostly use to hold rice cakes and pistachio nuts. When I need a reminder of some technical information like the meaning of a parameter or the definition of a word, I like quick on-line access to it as much as the next person. And Balloon Help is great when I’m wondering what a particular command or button is for. But when I don’t know how to do something at all, or how different pieces fit together, I prefer to read printed documentation. I’m speaking here of the background material that’s needed to get you launched on a particular product in a way that will make you really know what it’s about. (Whether this information is needed at all could be the subject of another editorial.) Call it “concepts” versus “reference.” For me, there’s nothing like reading about concepts in a real book when and where I want. The image that comes to mind is “curling up in front of a fire.” I’d much sooner do that with a good novel than a technical manual, but still I like to pick a place and time away from my computer to take in the concepts. It’s quieter and more comfortable, especially on my eyes, and it’s a more pleasing visual and tactile experience. I learn more that way. Later, I might want to look up some conceptual material on-line, but for first-time reading and learning, I want hard copy. At the last company I worked for we surveyed a lot of developers on this, and most of them seemed to agree. We decided to divide our technical documentation along those exact lines: concepts versus reference; concepts would always be available as a printed manual while reference would be on-line only (or primarily, at least). d e v e l o p Autumn 1991 CAROLINE ROSE has been writing computer documentation ever since “peripheral storage” meant paper tape. After a seven-year digression into programming, she returned to writing and joined Apple to document the inner workings of a new computer named Macintosh. In what proved to be another (five-year) digression, she left Apple to launch NeXT Computer’s documentation effort—a real learning experience. She’s thrilled to be back at Apple among old friends and new. Caroline loves to read, swim, hike, travel, dance, sing, and spend time with her best friend, Cleo (see photo). This summer she got her feet wet (literally) on a backpacking trip in Utah, through a tributary of the Escalante River and some pretty spectacular canyons. Her new wilderness goals are hiking up Half Dome and rafting the Colorado. • 2 CAROLINE ROSE

Reading notes: Byline placement and page header order are uncertain in the supplied copy

Printed product names
Macintosh · NeXT Computer
Printed dates
Autumn 1991
Languages
English
PDF page 5

This all ties in with the fact that Apple Associates and Partners no longer receive a printed copy of develop as part of their regular mailing; they have to subscribe to develop to receive it in print. The mailing has been simplified to be just a CD-ROM disc and a 16-page publication in newspaper format that points to things on the disc. Those developers who don’t want a lot of paper don’t have to deal with it; those who do can order it. So Associates and Partners will cast their vote for paper develop by subscribing to it. (Letters from all of you expressing your opinions—especially when they agree with mine—are of course more than welcome.) Speaking of electronic media, those of you who were receiving develop with its CD- ROM disc bound into it will notice that the disc corresponding to this issue has been packaged separately in its own case (made of partially recycled fiberboard and plastic). This should put a stop to the problem of mangled discs. Also, the disc is no longer the Developer Essentials disc, but the Developer CD Series disc, the same disc that Apple Associates and Partners receive. We hope this will make life easier for us and less confusing for you (not to mention that you’ll get more goodies on the disc than before!). I’ll end with a vaguely related trivia question: What word was used instead of “click” to describe the action of pressing a button on that first mouse? If you’ve got any good trivia questions of your own, send them along to us. We need all the help we can get. EDITORIAL Autumn 1991 3 SUBSCRIPTION INFORMATION Use the order form on the last page of this issue to subscribe to develop. Please address all subscription-related inquiries to develop, Apple Computer, Inc., P.O. Box 531, Mt. Morris, IL 61054 (or AppleLink DEV.SUBS).• BACK ISSUES For information about back issues of develop and how to obtain them, see the reverse of the order form on the last page of this issue. Back issues are also on the Developer CD Series disc.• Caroline Rose Editor

Reading notes: Heading 'EDITORIAL' and 'SUBSCRIPTION INFORMATION' section labels are not clearly a primary headline; headline set to null. Reading order of the subscription information block is slightly uncertain due to column-style line breaks.

Printed product names
develop · Developer CD Series · Developer Essentials · AppleLink DEV.SUBS
Printed dates
Autumn 1991
Languages
English
PDF page 6

THREADS PACKAGING I’m impressed with threads and futures and I think they’ll be of real use to me in a commercial product I’m working on. I have a simple problem. I don’t think we can ship your INIT with our application. Doing so constitutes an unnecessary invitation to support hassles (as well as a just plain unaesthetic package, in my opinion). Is there any chance that you could repackage the current threads and futures stuff as straight libraries (in THINK C form, please)? —Richard Reich The latest version of threads and futures, which is on this issue’s CD, has been augmented so that you have your choice of how to package the code. Just use the INIT as is, or copy the code resources into your application. Let me know if you need any more help. My number is (408)974-0355. —Michael Gough THREADS IN A BLACK BOX I was really pleased to see the article on threads in Issue 6 of develop. There have been several instances in my programming experience on the Macintosh when I had some long involved processing that was not easily restructured to pass control to the interface or to other applications. The Threads Package seems like the best way to handle this problem that we are likely to have without major changes in the Macintosh OS. However, I was disappointed to discover that Semaphore, one of the examples from the CD, crashes. If you click before the program is finished, it exits normally, but if you let it run its course, it crashes after it’s done beeping. I hope that a corrected version of the Threads Package will be available on a future develop CD. If the source code for this package had been provided on the disc, I would at least have a chance of understanding the source of the bug and correcting it. Instead I must rely on the possibility that a corrected version of the object code will be provided with a future issue of develop. We can count on Apple to provide updates for object libraries supplied with MPW; hence we have no need for the source. Can we rely on the same level of support for object libraries without source distributed on develop CDs? I’ve seen develop evolve from a journal with good articles on programming techniques into a journal with articles that were basically blurbs for source code, and now into a journal with articles that are blurbs for black boxes provided on the CD. I still think develop is an extremely useful resource for Macintosh programmers. However, I urge you to try to include source code when you possibly can. At any rate I am looking forward to seeing a corrected version of the Threads Package in a future issue of develop —I intend to give it a try even if it is a black box! —Dennis C. De Mars You’re right, the Semaphore example crashes, and it is a bug in the Threads Package. I guess I always clicked out early during the final testing. Issue 7 has a follow-up article to Threads that includes an updated (and fixed) Threads Package. d e v e l o p Autumn 1991 COMMENTS We welcome timely letters to the editors, especially from readers reacting to articles that we publish in develop. Letters should be addressed to Caroline Rose (or, if technical develop-related questions, to Dave Johnson) at Apple Computer, Inc., 20525 Mariani Avenue, M/S 75-2B, Cupertino, CA 95014 (AppleLink: CROSE or JOHNSON.DK). All letters should include name and company name as well as address and phone number. Letters may be excerpted or edited for clarity (or to make them say what we wish they did). • 4 LETTERS

Reading notes: Column headings 'THREADS IN A BLACK BOX' and 'COMMENTS' appear as secondary headings within the source text. Phone number and address fragments are present but were not extracted as dates or prices.

Printed product names
THINK C · INIT · Threads Package · Semaphore · MPW · develop
Printed dates
Autumn 1991
Languages
English
PDF page 7

To address your concern about develop heading toward “black boxiness”: The Threads Package is the only develop article ever that hasn’t included source code. We debated for a long time whether that was OK, and many people expressed the same concerns you did. We decided that Threads was unique enough and useful enough to justify it. The reaction has been extremely positive, so I think we did the right thing. I assure you that we won’t make a habit of featuring black boxes, and that as long as Michael Gough keeps supporting Threads, the latest CD will contain the latest version. Threads is not an official Apple product, though, so use it in your application at your own risk. It’s possible that we will be able to publish the source code someday. Thank you for taking the time to write! People’s comments are the best barometer we have for how we’re doing. —Dave Johnson CD SETUP (AND MORE!) ON CD How about including on the Developer Essentials CD-ROM a copy of the latest version of the CD Setup disc that comes with the AppleCD SC drive? It would be a convenient way to get a current version of the AppleCD SC software, and a lot of people who are browsing your CD have an AppleCD SC anyway. —Kazimir C. Stusinski The latest version of the CD Setup disc is on this issue’s CD. Note that it’s now the “Developer CD Series” disc, the same disc that Apple Associates and Partners receive. The contents of Developer Essentials was only a subset of the Developer CD Series disc; now you can have it all! —Caroline Rose EVASIVE SNIPPETS The Snippets section of develop always has such neat-sounding code fragments in it . . . if only I could find them! I always peruse the Developer CD Series disc that arrives with each issue of develop, but many of the snippets can’t be found, either by my old-fashioned hand searching or by using the HyperCard ® stack that, hopefully, really does have a complete index of the contents. It’s safe to say that it seems that most can’t be found. Assuming they are there—somewhere—I’d like to suggest that the code you list in the Snippets section be included in the develop folder. Even a directory or stack in that folder that would point me to them would be a terrific savings in time. Keep up the good work! —Chris Gibson Snippets have had a rough time. They didn’t make it onto the Issue 6 CD at all. And, although they were on the Issue 7 CD, they were not mentioned in the Contents Catalog stack on the Developer CD Series disc. They can be found with the DTS sample code. That seems the most logical place for them, since they’re not strictly a develop thing: they come from DTS (Developer Technical Support); we just describe them (and we’ve decided to stop that—they’re now described in a text file in with the snippets). Sorry for the confusion! —Dave Johnson ONE UGLY DUDE I just wanted to comment that I was totally shocked when I saw Harry Chesley’s picture in develop this month. LETTERS Autumn 1991 5

Reading notes: Some line-break hyphenation and column-merge artifacts in the source text may affect reading order.

Printed product names
Threads Package · Developer Essentials · CD Setup · AppleCD SC · Developer CD Series · HyperCard · DTS sample code · develop
Printed dates
Autumn 1991
Languages
English
PDF page 8

WHERE'S LOUELLA, REALLY?

“This is one ugly dude,” I thought. Perhaps his picture was sabotaged. Or maybe he really is a Vulcan with three Adam’s apples! —Dan Wood Actually, that picture wasn’t supposed to be printed at all. It’s top secret, the result of an internal Apple project in the area of desktop bioengineering. But now that the cat’s out of the bag, I guess I can mention that we’re expecting to ship the product second quarter next year. It attaches to the SCSI port of the Macintosh. You stick one of your fingers in a hole in the front, and it modifies your DNA. The actual physiological changes take about a week to materialize. —Harry Chesley P.S. The three Adam’s apples are a bug, which we’re planning to fix in the next rev. WHERE’S LOUELLA, REALLY? I sent mail to your predecessor, Louella, at louella@applelink.apple.com, but your system denied knowing about her. Any help you could give me in addressing e-mail to her would be very much appreciated. —An Admirer In Issue 7, I joked that Louella had retired to raise flowers in Holland. Well, I was close: she has left Apple to paint and write until her money runs out. We’ll miss her terribly but will remember her always as our “Spirited Guide.” She’ll be living wherever the living is easy (and cheap), but letters will always get to her through this address: 932 Rosette Court, Sunnyvale, CA 94086. Sorry, she will no longer be electronically plugged in. —Caroline Rose d e v e l o p Autumn 1991 6 On the Developer CD Series disc, the code that corresponds to articles in develop is kept up to date wherever possible. Bugs that are reported are fixed, changes are made to maintain compatibility, and so on. The latest CD always contains the most up-to-date versions of the code for all issues of develop, so if you’re going to use any code, get it from the most recent CD you have—even if the article is in a past issue. A notable change on this disc is that the QuickTime example from Issue 7 has been updated to work with the beta release of QuickTime, and has a couple of new features as well. Also, we’ve included the beta QuickTime extension, so you can try the samples immediately. (Remember, this is prerelease software that cannot be distributed or included with shipping applications.) Another change we’ve made, to be sure we give you the latest possible information, is to include descriptions of code “snippets” on the disc itself rather than describe them in develop. The Snippets folder (which is in with the DTS sample code) now includes text files that describe all of the snippets. The snippets are batched by date of release, so you can easily tell what’s new. UPDATES TO CODE ON THE DISC

Reading notes: Reading order of the letters section and the Developer CD Series column is uncertain The first letter's subject line is absent, so its attribution could be misplaced

Printed product names
Macintosh · QuickTime
Printed dates
Autumn 1991 · Issue 7
Languages
English
PDF page 9

Imagine being able to build into your application the capability to draw freehand curves. Imagine being able to save these curves so that they can be loaded into other programs like MacDraw or printed using the LaserWriter. And imagine being given the key to an abundant supply of previously defined curves to play with. Imagine no more . . . this article reveals all. QuickDraw is a heck of a fine drawing engine for the Macintosh, but it does have its limitations. In particular, it supports a limited set of geometric primitives for drawing: lines, rectangles, rounded-corner rectangles, ovals, arcs, and polygons (see Figure 1). If you want your application to provide the capability of drawing contours consisting of curves and straight lines, you’re out of luck. Sure, you can use the arc primitive to draw a curve, but if you want to connect the curve to anything, you’ve got a problem. An arc represents a segment of an ellipse and is specified by a bounding rectangle (defining the ellipse) and start and stop angles (see Figure 2). Because an arc is not specified by starting and ending points, it’s hard to know the exact points where QuickDraw will begin and end drawing the arc. Thus, the arc does not lend itself to being combined with other arcs or lines. A more useful curve primitive would be one that describes its start and end positions as points. The quadratic Bézier is just such a curve. Applications such as MacDraw ® use this type of curve to allow the drawing of freehand curves, and the Macintosh itself uses this type of curve in an internal procedure to describe TrueType fonts. In this article we give you the lowdown on the quadratic Bézier. We show the coding and the data structures used by programs like MacDraw to draw this kind of curve, and we show how your application can interchange data about this kind of curve with MacDraw and with devices equipped with a PostScript® interpreter. And since the quadratic Bézier happens to be the same curve that TrueType uses (in combination with other shapes) to draw outline fonts, we show how to extract curve data from TrueType fonts. CURVES AHEAD: WORKING WITH CURVES IN QUICKDRAW Autumn 1991 7 MIKE REED AND KONSTANTIN OTHMER have become such regular contributors to develop that they scarcely need introduction. Still, we’ve just discovered something new about them: they dabble in doggerel. Consider this sample: Late into the night, by the glow of a candle, Two men are found working on mischief and scandal. Their mice are a-clicking, their keyboards in motion, They’re working on something of mythic proportion. We move closer in, to get a good look, And notice they’re writing a get-rich-quick book. We wonder what topic could hold their attention And keep them from working on some new invention. Their title reveals what the work will envelop— How to Get Rich: Just Write for develop. • MIKE REED AND KONSTANTIN OTHMER CURVES AHEAD: WORKING WITH CURVES IN QUICKDRAW

Reading notes: Pull-quote and sidebar text near the end may be out of reading order relative to the main article.

Printed product names
MacDraw · LaserWriter · QuickDraw · TrueType · PostScript · Macintosh
Printed dates
Autumn 1991
Languages
English
PDF page 10

DRAWING CURVES AND PATHS The quadratic Bézier has a couple of properties that make it useful as a basis for drawing curves in QuickDraw. First, it can be rotated easily by changing just the starting, ending, and middle points and not the underlying equation itself. Second, it can easily be subdivided into any number of shorter curves that become flatter and flatter, until in effect it can be drawn with a series of straight lines. Indeed, the basic technique for drawing a curve using the existing QuickDraw primitives is by subdividing the curve into a series of line segments. If you’re interested in the mathematics behind this, see “Parametric Equations, Anyone?” This section begins by showing sample C code that implements the subdivision algorithm that produces a curve. We then move on to consider how to produce a d e v e l o p Autumn 1991 8 Lines Rectangles Rounded-corner rectangles Polygons Arcs Ovals Lines Figure 1 QuickDraw’s Geometric Primitives

Reading notes: Figure caption text and possible letter-spacing artifacts in the 'd e v e l o p' line may affect reading order.

Printed dates
Autumn 1991
Languages
English
PDF page 11

combination of curves and straight lines, known in the lingo as a path . Then we talk about how to combine paths to produce shapes. Note that for a curve, as for every geometric primitive in QuickDraw, you always have two options: you can either frame it or fill it. We show you how to do the framing; you can do the filling using the call FillPoly or PaintPoly. FRAMING A CURVE The code that implements the subdivision algorithm to produce a curve takes a value for the number of times the curve should be subdivided before it’s drawn as straight lines. This number can be dynamically computed based on the size of the curve and the quality-versus-speed trade-off the application wants to make. The code uses fixed-point coordinates to maintain high precision during the subdivisions. To begin, let’s define a few macros to help us use fixed-point coordinates in an integer-based graphics system. #define FR(x) ((x) + 0x8000 >> 16) #define ff(x) ((long)(x) << 16) #define fmoveto(x,y) MoveTo(FR(x), FR(y)) #define flineto(x,y) LineTo(FR(x), FR(y)) #define AVE(a,b) (((a) + (b)) / 2) FR The same as FixRound: takes a Fixed and makes it a short. ff The reverse of FixRound: takes a short and promotes it to a Fixed. fmoveto The same as MoveTo, but takes Fixed coordinates. flineto The same as LineTo, but takes Fixed coordinates. AVE Averages two numbers, either Fixed, short, or long. CURVES AHEAD: WORKING WITH CURVES IN QUICKDRAW Autumn 1991 9 For an explanation of the Fixed data type, see Inside Macintosh Volume I, Chapters 3 and 16.• 0° 90° { } Rect r; SetRect(&r, 0, 0, 144, 144); FrameArc(&r, 0, 90); PenPat(gray); FrameRect(&r); Figure 2 How an Arc Is Specified in QuickDraw

Printed dates
Autumn 1991
Languages
English