Make – Getting Started with Processing

Make – Getting Started with Processing
اسم المؤلف
Casey Reas and Ben Fry
التاريخ
27 يناير 2024
المشاهدات
213
التقييم
(لا توجد تقييمات)
Loading...

Make – Getting Started with Processing
Casey Reas and Ben Fry
Contents
Preface vii
1/Hello 1
Sketching and Prototyping 2
Flexibility 3
Giants . 4
Family Tree 5
Join In 6
2/Starting to Code 7
Your First Program 8
Show . 10
Save 11
Share . 12
Examples and Reference . 13
3/Draw 15
Basic Shapes 16
Drawing Order . 22
Shape Properties 23
Color .26
Custom Shapes .30
Comments 33
Robot 1: Draw .34
4/Variables 37
Making Variables 39
Processing Variables .40
A Little Math 40
Repetition 42
Robot 2: Variables .49
5/Response 51
Follow 53
Map 58
Click .60
Location 64
Type 68
Robot 3: Response . 74vi Contents
6/Media 77
Images . 78
Fonts .83
Shapes .86
Robot 4: Media 89
7/Motion 91
Speed and Direction .92
Tweening .95
Random 97
Timers .99
Circular . 100
Translate, Rotate, Scale 104
Robot 5: Motion 113
8/Functions 115
Function Basics 116
Make a Function 118
Return Values 124
Robot 6: Functions 126
9/Objects 129
Classes and Objects 130
Robot 7: Objects 138
10/Arrays 141
Make an Array 144
Repetition and Arrays . 147
Arrays of Objects .150
Robot 8: Arrays .153
11/Extend 157
3D 158
Image Export 164
Hello Arduino .168
Community 175
A/Coding Tips 177
B/Data Types 183
C/Order of Operations 185
D/Variable Scope 187
Index 189
Index
Symbols
3D, drawing in, 158–163
// (double slashes) for code comments,
33
== (equal to) operator, 72

(greater than) operator, 44
= (greater than or equal to) operator,
44

(hash mark) symbol, 164

< (less than) operator, 44
<= (less than or equal to) operator, 44
&& (logical AND operator), 68
|| (logical OR operator), 72
% (modulo operator), 149
!= (not equal to) operator, 44
A
ACM SIGGRAPH archives, 4
alpha values, 29
ambient lights, 162
analogRead() function, 170
animation
bouncing shapes off sides of screen,
94–95
calculating tween positions, 95–96
circular motion with sine and cosine,
103
drawing/moving shapes randomly,
97–99
frame rates, 91–92
moving shapes, 92–93
rotating coordinate system, 108–109
scaling shapes, 110–113
sine wave values/movement, 102–103
spirals, creating, 104
timed events, triggering, 100
tracking time, 99
translating locations, 106–108
wrapping shapes around screen, 93–94
antialiasing (smoothing), 23
applet folder, 12–13
arc() function, 20
Arduino boards
data stream, visualizing, 172–173
overview, 168–169
reading data from serial port, 170–171
reading sensors, 169–170
visualizing data in circular patterns,
173–174
arithmetic operations
operators, 41–42
order of, 185
arrays
creating (examples), 144–147
defined, 141
filling arrays with values in for loops,
148
of objects, 150–152
repetition and, 147
sequence of images stored in, 152–153
tracking mouse movements with,
148–149
arrow keys, detecting, 73
arrows, drawing, 30
B
background() function, 26, 54
beginShape() function, 30
blocks, for loop, 43
boolean data type, 60–62, 183
buttons (mouse), tracking, 63–64190 Index
C
calculations, order of, 185
camera() function, 162–163
char variables, 70
circles
cursor position relative to, 66–67
drawing, 10, 19
circular motion
example, 113–114
with sine and cosine, 103
classes of objects, 130–134
clicks, mouse, 60–63
CLOSE parameter, 31–32
code
coding tips, 177–181
examples, x
modifying with variables, 49–50
repeating with for loops, 42–45
splitting into tabs, 137
coded keys, 73
color
coding, 179
Color Selector, 28–29
drawing with, 26–30
columns and rows, creating with for
loops, 47
comments
adding to code with //, 33–34
multiple-line, 179
tips for writing, 179
community, Processing, 175
comparison operator (==), 72
Console
defined, 8
functions of, 181
constrain() function, 99
constructors (OOP), 132
continuous lines, drawing, 55
cursors, finding location of, 65–68
customizing shapes, 30–33
D
data folder, 77–78
data types
boolean, 60–62, 183
char, 183
float, 183
int, 183
parameters and, 122
PFont, 183
PImage, 183
PShape, 183
String, 183
summary of, 183–184
of variables, 39
declaring object variables, 134
degrees, measuring in, 20–22
directional lights, 162
Display Window, 15
dist() function, 55–56, 66
dot (.) operator, 136
double slashes (//) for code comments,
33
downloading Processing, 7–8
drawing
in 3D, 158–163
basic shapes, 16–18
circles, 10
with color, 26–30
continuous lines, 55
controlling order of, 22–23
draw() function, 51–52
ellipses, 9, 19–20
with fonts, 84–85
images to screen, 78–80
lines, 18
to PDF files, 166–167
points, 16
with radians, 22
rectangles, 19
shapes randomly, 97–99
smooth lines, 23–24
squares and circles, 19
windows, 16Index 191
E
easing
mouse movements, 56–57
smoothing lines with, 57
elements, defined (arrays), 144
ellipses
drawing, 9, 19–20
ellipseMode() function, 25
else blocks, 62–63
embedded for loops, 46
endShape() function, 30
examples and reference (Processing),
13–14
exporting
images, 164–167
sketches, 12–13
expressions, arithmetic, 41–42
F
fields, object, 129–134
fill() function, 26
float data type, 92
float numbers, 183
folders, library, 158
fonts
creating, 83–84
drawing with, 84–85
for loops
examples of, 42–47
filling arrays with values in, 148
frame rates, 91–92
functions
basics of, 116–117
calculating and returning values with,
124–125
coding tips, 178
defined, 15
steps for creating, 118–124
G
Getting Started with Arduino (O’Reilly),
168
GIF image format, 12, 81–82
GIMP software, 81
global variables, 52
gray values, 27–28
H
HTML files in applet folder, 12
I
if blocks, 62–63
images
drawing to screen, 78–80
exporting, 164–167
image() function, 79
resizing, 80–81
saving, 164–165
initialization statement, 44
instances, defined (objects), 130
instance variables, 129
J
JAR file in applet folder, 12
JAVA2D renderer, 158
JPEG image format, 81–82
K
keyboard characters, setting size of, 71
keyCode variable, 73
keyPressed variable, 68–70
keys
detecting specific, 72–73
tapping, 70–71
L
libraries, Processing, 157–158
lighting in 3D (example), 161–162
lights() function, 162
lines
drawing, 18
drawing continuous, 55
drawing smooth, 23–24
and pins, creating, 48
setting thickness of, 55–56
smoothing with easing, 57
Linux, installing Processing on, 7–8
loadFont() function, 84
loadImage() function, 78192 Index
local variables, 187
logical operators
AND (&&), 68
OR (||), 72
M
Mac OS X, installing Processing on, 7
Maeda, John, vii
map() function, 59–60
media files,downloading, 77
message area, defined, 8
methods (OOP), 129–134
modulo (%) operator, 149
mouse
buttons, tracking multiple, 63–64
clicks of, 60–63
easing movements of, 56–57
resizing images with movements of,
80–81
tracking movements with arrays,
148–149
mousePressed variable, 60
mouse speed, calculating with variables,
55–56
mouse tracking, 53–54
N
naming variables, 39
new keyword, 134, 145
nf() function, 152
non-Roman characters, 84
noSmooth() function, 23
O
objects
arrays of, 150–152
basic concepts, 129–130
classes and, 130–134
creating, 134–135
creating multiple, 136–137
OOP (object-oriented programming), 129
OpenGL, 5
OpenGL renderer, 159
operators
arithmetic, 41
relational, 44
order, drawing, 22–23
order of operations (calculations), 185
owl function, creating (example), 118–124
P
P5 Processing Robot. See robot
programs (examples)
parameters
basics of, 122–123
coding tips, 178
PDE file in applet folder, 12
PDF Export library, 165
PDF files, drawing to, 166–167
PEMDAS acronym, 42
PFont data type, 84
PImage data type, 78
pins and lines, creating, 48
pixel basics, 15
PNG image format, 81–82
point lights, 162
points, drawing, 16
popMatrix()/pushMatrix() functions, 107
PostScript, 5
Present command, 11
println() function, 181
Processing
community for sharing programs, 175
defined, 1
downloading/launching, 7–8
examples and Reference, 13
flexibility of, 3
history of, vii–viii, 4
libraries, 157–158
Processing Development Environment
(PDE), 8
related languages and programming
environments, 5
special variables in, 40
versions of, installing, 7–8
website for sharing/networking, 6
properties, shape, 23–25
pushMatrix()/popMatrix() functions, 107Index 193
R
radians
defined, 20–21
drawing with, 22
random() function, 97, 113–114, 117
randomSeed() function, 99
ranges, mapping values to, 58–59
raster images in JPEG/PNG/GIF formats,
81
reading sensors (Arduino), 169–170
rectangles
cursor position relative to, 67–68
drawing, 19
rectMode() function, 25
Reference and examples (Processing), 14
relational operators, 44
resizing images, 80–81
RGB color, 28
robot programs (examples)
arrays of Robot objects, 153–155
drawing P5 robot, 34–35
drawRobot() function, 126–128
loading images from SVG/PNG files,
89–90
modifying code with variables, 49–50
random and circular movements,
113–114
Robot class and objects, 138–139
shapes responding to mouse, 74–76
rotate() function, 108
rotating coordinate system, 108–109
rows and columns, creating with for
loops, 47
Run button, 10–11
S
Safari Books Online, xi
saving
images, 164–165
Save command, 11–12
saveFrame() function, 164
scale() function, 110
scaling shapes, 88, 110–113
scope, variable, 187
sensors, reading (Arduino), 169–170
Serial Library (Processing), 168, 171
setup() function, 52–53
shapes
custom, 30–33
drawing basic, 16–18
drawing randomly, 97–99
drawing with, 87
moving, 92–93
properties, 23–25
responding to mouse, 74–75
scaling, 88
shape() function, 87
shortcuts for calculations, 42
sin() and cos() functions, 101–104
sine wave values/movement, 102–103
size() function, 15–16, 40
sketching
creating/saving sketches, 11–12
exporting sketches, 12–13
overview, 2
sketchbook, defined, 11
Sketch menu, 11
smoothing lines with easing, 57
smooth lines, drawing, 23–24
spirals, creating, 104
spot lights, 162
strings, storing text in, 86
strokeCap() function, 25
stroke() function, 26
strokeJoin() function, 25
stroke weights
consistency of, 111–112
setting, 24
style tips for coding, 180
SVG files, loading and drawing, 87
SVG format, vector shapes in, 81
syntax, precise use of, 9
T
tab feature (Processing Environment),
137
tapping keys, 70–71
test statement, 44194 Index
text
drawing in boxes, 85
editor, defined, 8
storing in strings, 86
textAlign() function, 71
textFont() command, 84
text() function, 71, 84
textSize() function, 71, 84
TIFF format, 164
timed events, triggering, 100
toolbar, defined, 8
Tools Color Selector, 28–29
tracking
mouse, 53–54
multiple mouse buttons, 63–64
translate() function, 106–107
translating locations, 106–109
transparency
with GIF/PNG images, 81–83
setting, 29
tweening (animation), 95–96
U
uppercase/lowercase letters in code, 180
V
values, returning with functions, 124–125
variables
arrays and, 141–143
calculating mouse speed with, 55–56
changing values with, 38
creating, 39
declaring object variables, 134
frameRate variable. See frame rates
global, 52
modifying code with, 49
reusing identical values, 37
variable scope, 187
vector graphics, 165
vector shapes
in SVG format, 81
loading into Processing, 86
scaling, 88
vertex() function, 30–32
VLW format, 83
W
websites, for downloading
media files, 77
Processing libraries, 157
websites, for further information
Arduino boards, 168
resources for sharing programs, 175
width/height variables, 40
Windows (Microsoft), installing
Processing on, 7
wrapping shapes on screen, 93–94

كلمة سر فك الضغط : books-world.net
The Unzip Password : books-world.net

تحميل

يجب عليك التسجيل في الموقع لكي تتمكن من التحميل
تسجيل | تسجيل الدخول

التعليقات

اترك تعليقاً