Table Of ContentCONTENTS IN DETAIL
TITLE PAGE
COPYRIGHT
ABOUT THE AUTHOR
AUTHOR’S NOTE
INTRODUCTION
The Basics of a Programming Language: Processing
The Beginning
The Middle
The Rest
Variables
How to Write a Program
PART 1: THE FUNDAMENTALS OF DRAWING
Sketch 1: A Circle
Example A
Example B
Example C
Sketch 2: Colors
Example A
Example B
Sketch 3: if Statements—Changing Colors Conditionally
Example A
Example B
Example C
Sketch 4: Loops—Drawing 20 Circles
Example A
Example B
Sketch 5: Lines
Example A
Example B
Sketch 6: Arrays—Drawing Many Circles
Sketch 7: Lines with Rubber Banding
Sketch 8: Random Circles
Sketch 9: A Rectangle
Sketch 10: Triangles and Motion
Sketch 11: Displaying Text
Sketch 12: Manipulating Text Strings
PART 2: WORKING WITH PREEXISTING IMAGES
Sketch 13: Loading and Displaying an Image
Example A
Example B
Sketch 14: Images—Theory and Practice
Example A
Example B
Sketch 15: Manipulating Images I—Aspect Ratio
Example A
Example B
Sketch 16: Manipulating Images II—Cropping
Sketch 17: Manipulating Images III—Magnifier
Sketch 18: Rotation
Example A
Example B
Sketch 19: Rotating About Any Point—Translation
Example A
Example B
Sketch 20: Rotating an Image
Sketch 21: Getting the Value of a Pixel
Sketch 22: Setting and Changing the Values of Pixels
Example A
Example B
Sketch 23: Changing the Values of Pixels—Thresholding
Sketch 24: User-Defined Functions
Sketch 25: Elements of Programming Style
Sketch 26: Duplicating Images—More Functions
PART 3: 2D GRAPHICS AND ANIMATION
Sketch 27: Saving an Image and Adjusting Transparency
Sketch 28: Bouncing an Object in a Window
Sketch 29: Basic Sprite Graphics
Sketch 30: Detecting Sprite-Sprite Collisions
Sketch 31: Animation—Generating TV Static
Sketch 32: Frame Animation
Example A
Example B
Sketch 33: Flood Fill—Filling in Complex Shapes
PART 4: WORKING WITH TEXT AND FILES
Sketch 34: Fonts, Sizes, Character Properties
Sketch 35: Scrolling Text
Sketch 36: Text Animation
Sketch 37: Inputting a Filename
Sketch 38: Inputting an Integer
Sketch 39: Reading Parameters from a File
Sketch 40: Writing Text to a File
Sketch 41: Simulating Text on a Computer Screen
PART 5: CREATING USER INTERFACES AND WIDGETS
Sketch 42: A Button
Sketch 43: The Class Object—Multiple Buttons
Sketch 44: A Slider
Sketch 45: A Gauge Display
Sketch 46: A Likert Scale
Sketch 47: A Thermometer
PART 6: NETWORK COMMUNICATIONS
Sketch 48: Opening a Web Page
Example A
Example B
Sketch 49: Loading Images from a Web Page
Sketch 50: Client/Server Communication
PART 7: 3D GRAPHICS AND ANIMATION
Sketch 51: Basic 3D Objects
Example A
Example B
Sketch 52: 3D Geometry—Viewpoints, Projections
Sketch 53: 3D Illumination
Sketch 54: Bouncing a Ball in 3D
Sketch 55: Constructing 3D Objects Using Planes
Sketch 56: Texture Mapping
Sketch 57: Billboards—Simulating a Tree
Sketch 58: Moving the Viewpoint in 3D
Sketch 59: Spotlights
Sketch 60: A Driving Simulation
PART 8: ADVANCED GRAPHICS AND ANIMATION
Sketch 61: Layering
Sketch 62: Seeing the World Through a Window
Sketch 63: The PShape Object—A Rotating Planet
Sketch 64: Splines—Drawing Curves
Sketch 65: A Driving Simulation with Waypoints
Sketch 66: Many Small Objects—A Snowstorm
Sketch 67: Particle Graphics—Smoke
Sketch 68: Saving a State—A Spinning Propeller
Sketch 69: L-Systems—Drawing Plants
Sketch 70: Warping an Image
PART 9: WORKING WITH SOUND
Sketch 71: Playing a Sound File
Sketch 72: Displaying a Sound’s Volume
Sketch 73: Bouncing a Ball with Sound Effects
Sketch 74: Mixing Two Sounds
Sketch 75: Displaying Audio Waveforms
Sketch 76: Controlling a Graphic with Sound
Sketch 77: Positional Sound
Sketch 78: Synthetic Sounds
Sketch 79: Recording and Saving Sound
PART 10: WORKING WITH VIDEO
Sketch 80: Playing a Video
Sketch 81: Playing a Video with a Jog Wheel
Sketch 82: Saving Still Frames from a Video
Sketch 83: Processing Video in Real Time
Sketch 84: Capturing Video from a Webcam
Sketch 85: Mapping Live Video as a Texture
PART 11: MEASURING AND SIMULATING TIME
Sketch 86: Displaying a Clock
Sketch 87: Time Differences—Measuring Reaction Time
Sketch 88: M/M/1 Queue—Time in Simulations
PART 12: CREATING SIMULATIONS AND GAMES
Sketch 89: Predator-Prey Simulation
Sketch 90: Flocking Behavior
Sketch 91: Simulating the Aurora
Sketch 92: A Dynamic Advertisement
Sketch 93: Nim
Sketch 94: Pathfinding
Sketch 95: Metaballs—A Lava Lamp
Sketch 96: A Robot Arm
Sketch 97: Lightning
Sketch 98: The Computer Game Breakout
Sketch 99: Midpoint Displacement—Simulating Terrain
PART 13: MAKING YOUR WORK PUBLIC
Sketch 100: Processing on the Web
AN ARTIST’S GUIDE TO
PROGRAMMING
A Graphical Introduction
Jim Parker
An Artist’s Guide to Programming. Copyright © 2022 by Jim Parker.
All rights reserved. No part of this work may be reproduced or transmitted in any form or by any
means, electronic or mechanical, including photocopying, recording, or by any information storage or
retrieval system, without the prior written permission of the copyright owner and the publisher.
First printing
25 24 23 22 1 2 3 4 5 6 7 8 9
ISBN-13: 978-1-7185-0164-5 (print)
ISBN-13: 978-1-7185-0165-2 (ebook)
Publisher: William Pollock
Production Manager: Rachel Monaghan
Production Editor: Paula Williamson
Developmental Editors: Athabasca Witschi and Nathan Heidelberger
Cover Illustration: Gina Redman
Interior Design: Octopod Studios
Technical Reviewer: Jeffrey Boyd
Copyeditor: Andy Carroll
Compositor: Jeff Lytle, Happenstance Type-O-Rama
Proofreader: Emelie Battaglia
The following images are reproduced with permission: Figure 96-1 by Brocken Inaglory, printed
under the GNU Free Documentation License, Version 1.2.
For information on distribution, bulk sales, corporate sales, or translations, please contact No Starch
Press, Inc. directly at info@nostarch.com or:
No Starch Press, Inc.
245 8th Street, San Francisco, CA 94103
phone: 1-415-863-9900
www.nostarch.com
Library of Congress Cataloging-in-Publication Data
Names: Parker, J. R. (Jim R.), 1955- author.
Title: An artist’s guide to programming : a graphical introduction / Jim
Parker.
Description: San Francisco : No Starch Press, 2022. | Includes index. |
Identifiers: LCCN 2021046087 (print) | LCCN 2021046088 (ebook) | ISBN
9781718501645 (print) | ISBN 9781718501652 (ebook)
Subjects: LCSH: Multimedia systems. | Computer graphics. |
Microcomputers--Programming. | Processing (Computer program language) |
Java (Computer program language)
Classification: LCC QA76.575 .P357 2022 (print) | LCC QA76.575 (ebook) |
DDC 006.7--dc23
LC record available at https://lccn.loc.gov/2021046087
LC ebook record available at https://lccn.loc.gov/2021046088
No Starch Press and the No Starch Press logo are registered trademarks of No Starch Press, Inc.
Other product and company names mentioned herein may be the trademarks of their respective
owners. Rather than use a trademark symbol with every occurrence of a trademarked name, we are
using the names only in an editorial fashion and to the benefit of the trademark owner, with no
intention of infringement of the trademark.
The information in this book is distributed on an “As Is” basis, without warranty. While every
precaution has been taken in the preparation of this work, neither the author nor No Starch Press, Inc.
shall have any liability to any person or entity with respect to any loss or damage caused or alleged to
be caused directly or indirectly by the information contained in it.