# The Magic of Macintosh: Programming Graphics and Sound — source transcripts, page 1

[Canonical transcript page](https://www.vintageapple.net/transcripts/media/va-the-magic-of-macintosh-programming-graphics-and-sound-1986-aea3c0/1)

## Transcribed source material

Machine transcriptions and image descriptions; uncertain copy may be marked [illegible]. Verify against the linked originals. Historical rights remain with the original owners.

These are transcribed excerpts, not the full publications. Open the originals for remaining pages.

### Image 1

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-the-magic-of-macintosh-programming-graphics-and-sound-1986-aea3c0/1#scan-4f58603bba0c0c29c51dd043c793542dce5c1f85f23524101b7b9a80eb51190e)

Transcribed text:

THE MAGIC OF MACINTOSH
Programming Graphics and Sound
William B. Twitty
b
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9 10

Image description: A red book cover with bold black and white title type at top and a grid of colorful graphic illustrations below, including a hand with a diagonal square and labeled sides b and c, a pixel grid with axis numbers 0 to 10, a blue-grey shape, a dotted-pattern panel, and an oval with rectangles.

Reading notes: Small axis labels and the stray letter 'b' at left edge and the small 'c' and 'a' labels in the hand illustration are uncertain and may be diagram fragments rather than copy. Partial text fragments at the left edge are cut off and not transcribed. The 'Programming Graphics and Sound' subtitle is printed in black and the title in white, reading order follows top-to-bottom.

Printed product names: Macintosh

Languages: English

[Original Image 1](https://www.vintageapple.net/files/185ae6bb75d26b0c3e6fffba18f9719ba899c71cccfa98de21e4b99fb639e01d/baadff9c8df015d9c72a97fd.webp)

### PDF page 1

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-the-magic-of-macintosh-programming-graphics-and-sound-1986-aea3c0/1#scan-3211293e7aec4316ca6896b01b32b00036da092f784505a3f7373edc02b7aa2a)

Transcribed text:

THE MAGIC OF MACINTOSH
Programming Graphics and Sound
William B. Twitty
b
c
a
b
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9 10

Image description: A red book cover with a bold title block at top, a grid of geometric and pixel-style illustrations including a hand with diagram labels, a dotted pattern, a bitmap grid with connecting lines, and abstract blue and gray shapes.

Reading notes: Small diagram labels (b, c, a, and grid axis numbers) are partially legible and their reading order is approximate. Left-edge partial letter fragment near the illustrations is not clearly legible and was omitted.

Languages: English

[Original PDF page 1](https://www.vintageapple.net/files/69a38de9ac7e54e516f6f162a556cc2cc21712b8a96e3ee48fd260eaf5fece60/The_Magic_Of_Macintosh_Programming_Graphics_and_Sound_1986.pdf#page=1)

### PDF page 2

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-the-magic-of-macintosh-programming-graphics-and-sound-1986-aea3c0/1#scan-1bd086ecae273ec649d52a415fea80d753444f67bd65a22ddf72c5ad6c9c5467)

THE MAGIC OF MACINTOSH

Transcribed text:

11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
THE   MAGIC   OF
MACINTOSH
6)<5
-

Reading notes: Headline taken from the supplied extracted text (THE MAGIC OF MACINTOSH) and not verified against the image. The string '6)<5' is unclear and may be OCR noise or a fragment of artwork, not a price or date. A long row of '1' characters appears in the source text and is likely scanning or extraction noise. 'MACINTOSH' is not confirmed as an advertised product name because the context of the advertisement is not visible. Layout, reading order, and any additional body copy could not be verified from the supplied text.

Languages: English

[Original PDF page 2](https://www.vintageapple.net/files/69a38de9ac7e54e516f6f162a556cc2cc21712b8a96e3ee48fd260eaf5fece60/The_Magic_Of_Macintosh_Programming_Graphics_and_Sound_1986.pdf#page=2)

### PDF page 3

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-the-magic-of-macintosh-programming-graphics-and-sound-1986-aea3c0/1#scan-d54dab0030b90e76c86a196e493e4d634bce1a41146f0a3d4f9d184b82f55912)

THE MAGIC OF MACINTOSH

Transcribed text:

11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
THE   MAGIC   OF
MACINTOSH
Programming Graphics
and Sound
William   B. Twitty
Scott,   Foresman and Company
Glenview,   Illinois   London
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111

Reading notes: Source contains a run of repeated '1' characters above and below the text, which may be a scanning artifact or border

Languages: English

[Original PDF page 3](https://www.vintageapple.net/files/69a38de9ac7e54e516f6f162a556cc2cc21712b8a96e3ee48fd260eaf5fece60/The_Magic_Of_Macintosh_Programming_Graphics_and_Sound_1986.pdf#page=3)

### PDF page 4

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-the-magic-of-macintosh-programming-graphics-and-sound-1986-aea3c0/1#scan-85eb8fecaf317426587761f4fab571c4dcb5c36bc8bd6f6d52054e59809ad3f8)

Transcribed text:

11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
For   Othermamma
Macintosh is a trademark of   Mcintosh   Laboratory, Inc. and is licensed to Apple
Computer, Inc. and is being used with express permission of its owner.
MacPaint, MacWrite, MacDraw, and Macintosh Pascal are trademarks of Apple
Computer, Inc.
Library of Congress Cataloging-in-Publication Data
Twitty, William B.
The magic of Macintosh.
Bibliography: p.   305
Includes index.
1. Macintosh (Computer)-Programming.
graphics.   3.   Computer sound processing.
QA76.8.M3T84   1986   006.6'76
ISBN   0-673-18253-3
2.   Computer
I.   Title.
86-3750
1   2   3   4   5   6-KPF-91   90   89   88   87   86
ISBN   0-673-18253-3
Copyright © 1986 William B. Twitty and Pacific Systems, Inc.
All Rights Reserved.
Printed in the   United   States   of America.
Notice of Liability
The information in this book is distributed on an   "As   Is"   basis, without
warranty. Neither the author nor   Scott,   Foresman and Company shall have any
liability to customer or any other person or entity with respect to any liability,
loss, or damage caused or alleged to be caused directly or indirectly by the
programs contained herein. This includes, but is not limited to, interruption of
service, loss of data, loss of business or anticipatory profits, or consequential
damages from the use of the programs.
Scott,   Foresman Professional Publishing Group books are available for bulk
sales at quantity discounts. For information, please contact Marketing Manager,
Professional Books, Professional Publishing Group,   Scott,   Foresman and
Company,   1900   East Lake Avenue, Glenview, IL   60025.

Reading notes: Leading line of repeated '1' characters appears to be a scanning artifact, not text. Reading order of the Library of Congress cataloguing block is scrambled (ISBN and subject heading lines interleaved).

Printed product names: Macintosh · MacPaint · MacWrite · MacDraw · Macintosh Pascal

Printed dates: 1986 · 86-3750

Languages: English

[Original PDF page 4](https://www.vintageapple.net/files/69a38de9ac7e54e516f6f162a556cc2cc21712b8a96e3ee48fd260eaf5fece60/The_Magic_Of_Macintosh_Programming_Graphics_and_Sound_1986.pdf#page=4)

### PDF page 5

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-the-magic-of-macintosh-programming-graphics-and-sound-1986-aea3c0/1#scan-75bf7df2eb44951da698e2e679bcd5bbc645871c7e5404d8b1331414d28d6d5b)

Transcribed text:

11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
PREFACE
The magic of the Macintosh is its graphics and sound. The Macintosh's
ease of use and its appeal to nonprogrammers depend on its graphics.
Anyone who writes programs for the Macintosh quickly finds that learning
how to generate and manipulate images is an absolute must; you can't do
anything on the Macintosh until you can understand and use the Quick-
Draw graphics package.
This book was written to introduce programmers with little or no
graphics background to Macintosh graphics and sound. The book has a
fair amount of technical material, but there's also a lot of fun with graphics
and sound.
The early chapters are very basic and deal with graphics fundamen-
tals, QuickDraw, making images on the Macintosh, and drawing text in
various type fonts. The later chapters address more technical subjects but
always with the understanding that the reader may be able to program but
has no prior experience with computer graphics.
The material is ordered so that a user can start writing programs
immediately without having to understand all of the details of QuickDraw
coordinates and mathematics. Those kinds of details are covered in later
chapters.
The emphasis is on explaining by example. I felt it important to
provide a concise example for each concept that is explained in the text,
so   The Magic of Macintosh   is filled with programming examples and
illustrations. The examples are designed so that the reader can take parts

Reading notes: Heading line for the source is not clearly printed, so headline is null Page-break hyphenation in 'Quick-Draw' and 'fundamen-tals' may be a line-wrap artifact

Printed product names: Macintosh · QuickDraw · The Magic of Macintosh

Languages: English

[Original PDF page 5](https://www.vintageapple.net/files/69a38de9ac7e54e516f6f162a556cc2cc21712b8a96e3ee48fd260eaf5fece60/The_Magic_Of_Macintosh_Programming_Graphics_and_Sound_1986.pdf#page=5)

### PDF page 6

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-the-magic-of-macintosh-programming-graphics-and-sound-1986-aea3c0/1#scan-32c50791880be9cc6d5e5941609d76909df2b92db12027208701f370dc46e5cf)

Transcribed text:

of the programs and transfer them to his or her own applications. They are
a set of pretested parts for the software builder.
The example programs are written in Macintosh   Pascal.   To keep them
as simple as possible, I did not use any toolbox routines except those
directly associated with graphics and sound.
Chapter 1 introduces the reader to computer graphics and their
implementation on the Macintosh. Chapter 2 explains the fundamentals of
drawing in two dimensions and coordinate systems and begins introduc-
ing QuickDraw topics. Chapter 3 goes into more detail on drawing shapes
and patterns with QuickDraw. Chapter 4 introduces the reader to text
fonts and how they are drawn on the Macintosh with tools from the
QuickDraw package. Chapter 5 deals with the mouse, the cursor, and
more advanced tools in QuickDraw, as well as pictures, polygons, and
regions.   Chapter 6 leads the reader into the more technical subjects
through an understanding of the fundamental concepts behind Quick-
Draw, its coordinate systems and data structures.
From chapter 7 on, the topics are not strictly limited to the Macintosh
and QuickDraw but range over a variety of technical methods used in
computer-aided design systems and other graphics programs. Chapter 7
discusses how to draw and store objects. Chapter 8 takes us into the exotic
climes of spline curves and fractals.
Chapter 9 brings the book to a close with explanations and examples
of how to produce complex sounds on the Macintosh.
Writing a technical book is a demanding task, but along with the work
on this book, there was a lot of fun doing graphics and sound with the
magical Macintosh. I hope that you have as much fun with this book as
I did.
Programmers new to the Macintosh will find the first book in this
series,   Programming the Macintosh: An Advanced Guide,   to be another
useful addition to their library.
Many people helped to create and produce this book. Among them
are the folks at Apple Computer who provided information and technical
advice and my editor at   Scott,   Foresman, Richard Swadley, who had more
patience than one could reasonably expect. A special thank-you goes to
Jeanine Johnson, who put in many editing hours helping to make sense out
of my technical ramblings and fumble-fingered typing.

Reading notes: Source begins mid-sentence; reading order and any preceding heading are unclear.

Printed product names: Macintosh Pascal · Programming the Macintosh: An Advanced Guide · QuickDraw

Languages: English

[Original PDF page 6](https://www.vintageapple.net/files/69a38de9ac7e54e516f6f162a556cc2cc21712b8a96e3ee48fd260eaf5fece60/The_Magic_Of_Macintosh_Programming_Graphics_and_Sound_1986.pdf#page=6)

### PDF page 7

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-the-magic-of-macintosh-programming-graphics-and-sound-1986-aea3c0/1#scan-7944f2a514852f42ca3f2d40396311863dd169454e6c6792a123ea7414f1e2de)

Transcribed text:

11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
CONTENTS
CHAPTER   1   UN•   EASHING   THE   MAGICIAN   1
The Magic in   Your   Macintosh   2
The Macintosh Display   3
Pixel   Coordinates   4
Jaggies   7
Halftone Images   8
QuickDraw   9
Programming   9
CHAPTER   2   DRAWING   IN   TWO   DIMENSIONS   11
Dimensions   12
Coordinate   Systems   12
Pixels   and Memory   13
The   Pen   13
Coordinate Transformations   15
Points   and Rectangles   20
Clipping and Windows   24
CHAPTER   3   DRAWING   SHAPES   AND   PAnFRNS   27
Coordinates and the   Pen   28
The   Pen   Pattern   29
Drawing Modes   31
QuickDraw   Shapes   40
Drawing QuickDraw Shapes   44

Reading notes: Chapter 1 title contains garbled characters ('UN•   EASHING'), likely 'UNVEILING' Chapter 3 title reads 'PAnFRNS', likely 'PATTERNS'

Languages: English

[Original PDF page 7](https://www.vintageapple.net/files/69a38de9ac7e54e516f6f162a556cc2cc21712b8a96e3ee48fd260eaf5fece60/The_Magic_Of_Macintosh_Programming_Graphics_and_Sound_1986.pdf#page=7)

### PDF page 8

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-the-magic-of-macintosh-programming-graphics-and-sound-1986-aea3c0/1#scan-8770ccb8ca437df5a4017d25f3b7ee69f533a27d16748164ff6a8d7b8ac3f3aa)

Transcribed text:

CHAPTER   4   DRAWING   TEXT   49
Displaying Text with Type Fonts   50
Type Style   51
Type Size   51
Font Files   5   3
Text Character Images   5 3
Kerning   55
QuickDraw and the Font Manager   5 7
QuickDraw Routines   58
Drawing Text   59
Getting Information about the Font   61
A Program to Draw a Font's Character Set   63
CHAPTER   5   MORE TOOLS FOR THE   MAGICIAN   69
The Cursor   70
The Mouse   76
Pictures, Polygons, and Regions   79
Creating QuickDraw Pictures   83
QuickDraw Polygons   87
Using Regions   94
CHAPTER   6   QUICKDRAW   COORDINATES   AND
DATA STRUCTURES   101
Coordinates and Data Structures   102
QuickDraw Coordinates   102
Pixels and Memory   106
The Graph Port   108
More on Coordinates   111
Translation and Scaling   116
CHAPTER   7   DRAWING   OBJECTS   119
What's an   Object?   120
Using Data Structures to Define   Objects   121
An   Object   as a Collection of Shapes   122
Basic Trigonometry   12   8
Rotation   130
Rotation about an Arbitrary Point   134
Scaling an   Object   135
A Program with   Objects   139
Modifying the Object-Drawing Program   152

Reading notes: Headline not clearly identified; the source is a table of contents rather than an advertisement. Some character spacing in chapter titles may reflect extraction artifacts (e.g., 'Font Files 5 3').

Languages: English

[Original PDF page 8](https://www.vintageapple.net/files/69a38de9ac7e54e516f6f162a556cc2cc21712b8a96e3ee48fd260eaf5fece60/The_Magic_Of_Macintosh_Programming_Graphics_and_Sound_1986.pdf#page=8)

### PDF page 9

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-the-magic-of-macintosh-programming-graphics-and-sound-1986-aea3c0/1#scan-485920673b59d06db585019a84e7bd776225d5d327c0c7751927bd2be173085b)

Transcribed text:

CHAPTER   8   SPLINES   AND FRACTALS   179
Drawing Smooth Curves   180
Spline   Curves   184
The   Spline   Program   190
Drawing Jagged Curves   191
Drawing Fractals   193
Simulating Nature   200
CHAPTER   9   SOUND   MAGIC   227
Sound Basics   228
Making Music with the Macintosh   230
SysBeep and Note   232
Controlling the Volume   233
The Sound Synthesizers   234
Generating Square-Wave Tones   237
Sound from Free-Form Waves   239
Using the Four-Voice Synthesizer   245
APPENDIXES   265
A   QuickDraw Data Structures   267
B   QuickDraw Routines   271
C   Mouse Routines   293
D   Macintosh   Pascal   Window Routines   295
E   Sound Routines and Data Structures   297
GLOSSARY   301
BIBLIOGRAPHY   305
INDEX   307

Reading notes: Source text is a table of contents with no advertised products, prices, or dates; headline is not identifiable as a primary heading.

Languages: English

[Original PDF page 9](https://www.vintageapple.net/files/69a38de9ac7e54e516f6f162a556cc2cc21712b8a96e3ee48fd260eaf5fece60/The_Magic_Of_Macintosh_Programming_Graphics_and_Sound_1986.pdf#page=9)

### PDF page 10

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-the-magic-of-macintosh-programming-graphics-and-sound-1986-aea3c0/1#scan-eac53a01373767705452881e935cfb3b584e79df3694ae12ed563bed48916367)

The Magic in Your Macintosh

Transcribed text:

CHAPTER
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
The Magic in   Your   Macintosh
The Macintosh Display
Pixel Coordinates
Jaggies
Halftone Images
QuickDraw
Programming
lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
1

Reading notes: Repeated '1' and 'l' characters appear as decorative rules and page number; uncertain whether '1' is chapter number or page number

Printed product names: Macintosh

Languages: English

[Original PDF page 10](https://www.vintageapple.net/files/69a38de9ac7e54e516f6f162a556cc2cc21712b8a96e3ee48fd260eaf5fece60/The_Magic_Of_Macintosh_Programming_Graphics_and_Sound_1986.pdf#page=10)

### PDF page 11

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-the-magic-of-macintosh-programming-graphics-and-sound-1986-aea3c0/1#scan-b150f480766869e6123a6a771b38ac223b1be03b7975e2a789b76a4c5672ca03)

UNLEASHING THE MAGICIAN

Transcribed text:

2   UNLEASHING   THE MAGICIAN
THE   MAGIC   IN   YOUR
11111111111111111111111111111111   MACINTOSH
A magician is someone who performs supernatural and astonishing feats
through the mastery of secret and mysterious forces. And what could be
more magical than a tan-colored box that draws pictures and makes music
by its own hand? Your Macintosh computer is like a magician, accom-
plishing tasks that no small computer could before. However, the real
magic within the Macintosh lies in the programs that produce the pictures
and sound.
Writing programs for sound and graphics may seem an arcane art
calling for secret knowledge, but taken step by step, it's really very simple.
When you learn the basics of computer graphics with examples pro-
grammed for the Macintosh, you are on your way to unleashing the
magician in your Macintosh.
The Macintosh produces pictures of striking quality for an inexpen-
sive computer. The basis of this high quality is the high-resolution display,
which produces finely detailed images. The inexpensive high-resolution
graphics   open   up   many   new   possibilities   for   graphics   on   personal
computers.
The high-resolution display provides the fine artist with an entirely
new medium in which to work and a new set of tools as well. Every
medium has its own characteristics, and artists have been quick to capi-
talize on the Macintosh's. Commercial artists were not caught napping
either.   Some   of the first third-party products for the Macintosh were disks
containing pictures that any nonartist could use to add spice to proposals,
newsletters, circulars, or other types of documents produced on the
Macintosh.
Business people use the graphics capabilities of the Macintosh to
prepare for presentations and illustrate financial data. Engineers now have
a tool for quickly producing graphs and charts based on engineering
calculations.   There are a number of low-cost computer-aided design
programs on the market that will do everything from lay out printed circuit
boards to help you design a garden.   Of   all the new application programs
for personal computers, the most exciting are the ones designed specially
for the Macintosh. They relate pictures to information in new and inno-
vative ways.   Some   are so new in concept that old labels no longer apply.
Commercial packages provide graphics-based tools for doing a job. In
this book we are more interested in the fun of graphics and sound on the
Macintosh. We don't have any specific goals to produce a useful program.
We're in it for the fun. Along the way we will learn a lot about graphics and

Reading notes: Chapter number '2' and running header text may be page furniture rather than headline

Printed product names: Macintosh

Languages: English

[Original PDF page 11](https://www.vintageapple.net/files/69a38de9ac7e54e516f6f162a556cc2cc21712b8a96e3ee48fd260eaf5fece60/The_Magic_Of_Macintosh_Programming_Graphics_and_Sound_1986.pdf#page=11)

[Next transcribed scans](https://www.vintageapple.net/transcripts/media/va-the-magic-of-macintosh-programming-graphics-and-sound-1986-aea3c0/2.md)
