SlideShare ist ein Scribd-Unternehmen logo
1 von 32
Downloaden Sie, um offline zu lesen
Processing: Basics
June-Hao Hou
Basic Structure
setup()
draw()
Basic Structure
setup()
draw()
events?
event handlers
declarations
True
False
eventdetection
Basic Structure
setup()
draw()
events?
event handlers
True
False
declarationsLibraries Classes
eventdetection
Coordinates
stroke(0, 128, 128);
noFill();
rect(0, 0, 10, 10);
+x
+y
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
Basic Shapes
point(20, 30);
(20, 30)
(3, 5)
(30, 50)
line(3, 5, 30, 50);
rect(0, 0, 10, 10);
(0, 0)
10
10
ellipse(20, 30, 40, 60);
(20, 30)
40
60
Modes of Shape
rectMode(CORNER);
rect(0, 0, 10, 10);
(0, 0)
10
10
(0, 0)
(10, 10)
rectMode(CORNERS);
rect(0, 0, 10, 10);
rectMode(CENTER);
rect(0, 0, 10, 10);
(0, 0)
10
10
rectMode(RADIUS);
rect(0, 0, 10, 10);
(0, 0)
10
10
預設值
Variable Scope
int x;
void setup() {
int w = 200;
x = 0;
size(w, w);
}
void draw() {
int y;
x = x + 1;
y = x * 2;
rect(0, 0, x, y);
}
int x
int w
int y
draw()
setup()
Variable Scope
class Cube {
float cx;
float cy;
float size;
Cube(float x, float y, float s) {
cx = x;
cy = y;
size = s;
}
float volume() {
float v;
v = size * size * size;
return v;
}
}
float cx
float cy
float size
float x
float y
float s
float v
Cube
Cube()
volume()
For Loop
expressions
condition
True
False
init-statement
next-statement
•init-statement
初始敘述
•condition
繼續執⾏行的條件
•next-statement
下次執⾏行前敘述
•expressions
迴圈主體
for (init; cond; next)
{
expressions
{
For Loop
for (int i = 0; i < 5; i++) {
print(i);
}
01234
for (int i = 0; i <= 5; i++) {
print(i);
}
012345
for (int i = 1; i < 5; i++) {
print(i);
}
1234
for (int i = 0; i < 10; i = i + 2) {
print(i);
}
02468
For Loop
for (int i = 0; i < 5; i++) {
print(_______);
}
43210
for (int i = ____; ____; i--) {
print(i);
}
43210
for (int i = -5; i < 5; i++) {
print(_______);
}
0123456789
for (int i = 0; i < 10; i++) {
print(i / 2);
}
Exercise
For Loop
for (int i = 0; i < 5; i++) {
print(4 - i);
}
43210
for (int i = 4; i >= 0; i--) {
print(i);
}
43210
for (int i = -5; i < 5; i++) {
print(i + 5);
}
0123456789
for (int i = 0; i < 10; i++) {
print(i / 2);
}
0011223344
Answ
er
For Loop
for (int i = 0; i < 100; i = i + 10) {
if (i % 5 == 0) i = i - 5;
println(i);
}
for (int i = 0; true; i++) {
// Do something...
}
<< 執⾏行次數?
Exercise
For Loop
for (int i = 0; i < 100; i = i + 10) {
if (i % 5 == 0) i = i - 5;
println(i);
}
-5
0
5
10
15
...
90 (執⾏行20次)
for (int i = 0; true; i++) {
// Do something...
}
(永不停⽌止)
Answ
er
For Loop
for (int i = 0; i < 5; i++) {
print("X");
}
println();
XXXXX
for (int j = 0; j < 5; j++) {
for (int i = 0; i < 5; i++) {
print("X");
}
println();
}
XXXXX
XXXXX
XXXXX
XXXXX
XXXXX
For Loop
for (int j = 0; j < 5; j++) {
for (int i = j; i < 5; i++) {
print("X");
}
println();
}
for (int j = 0; j < 5; j++) {
for (int i = 0; i < 5; i++) {
if (______) {
print("X");
} else {
print(" ");
}
}
println();
}
X X X
X X X
X X X
X X X
X X X
Exercise
For Loop
for (int j = 0; j < 5; j++) {
for (int i = j; i < 5; i++) {
print("X");
}
println();
}
XXXXX
XXXX
XXX
XX
X
for (int j = 0; j < 5; j++) {
for (int i = 0; i < 5; i++) {
if (i % 2 == 0) {
print("X");
} else {
print(" ");
}
}
println();
}
X X X
X X X
X X X
X X X
X X X
Answ
er
For Loop
X X X
X X X
X X X
i=0 i=1 i=2 i=3 i=4
j=0
j=1
j=2
j=3
j=4
(i % 2) == 0 && (j % 2) == 0
For Loop
X X X
X X
X X
X X
X X X
i=0 i=1 i=2 i=3 i=4
j=0
j=1
j=2
j=3
j=4
((i == 0 || i == 4) || (j == 0 || j == 4))
&& (i != j) && (i + j != 4)
For Loop
XXXXX
X X
X X
X X
XXXXX
X X
X X
X
X X
X X
XXXXX
XXX
X
XXX
XXXXX
X X X
X X
X X X
X X
X X X
XXXX
X XXX
XX XX
XXX X
XXXX
XXXX
XXX X
XX XX
X XXX
XXXX
X X
XX XX
XXXXX
XX XX
X X
XXX
X X X
XX XX
X X X
XXX
X
X X
X X
X X
X
Exercise
For Loop
XXXXX
X X
X X
X X
XXXXX
X X
X X
X
X X
X X
XXXXX
XXX
X
XXX
XXXXX
((i == 0) || (i == 4)) || ((j == 0) || (j == 4))
(i == j) || (i + j == 4)
((i >= j) && (i <= 4 - j)) || ((i <= j) && (i >= 4 - j))
((i == 0) || (i == 4)) || ((j == 0) || (j == 4))
(i == j) || (i + j == 4)
((i >= j) && (i <= 4 - j)) || ((i <= j) && (i >= 4 - j))
((i == 0) || (i == 4)) || ((j == 0) || (j == 4))
(i == j) || (i + j == 4)
((i >= j) && (i <= 4 - j)) || ((i <= j) && (i >= 4 - j))
Answ
er
1 2 3
1
2
3
參考答案,並⾮非唯⼀一解法
For Loop
X X X
X X
X X X
X X
X X X
XXXX
X XXX
XX XX
XXX X
XXXX
XXXX
XXX X
XX XX
X XXX
XXXX
(i + j) % 2 == 0
!(i == j)
!(i + j == 4)
(i + j) % 2 == 0
!(i == j)
!(i + j == 4)
(i + j) % 2 == 0
!(i == j)
!(i + j == 4)
Answ
er
1 2 3
1
2
3
參考答案,並⾮非唯⼀一解法
For Loop
X X
XX XX
XXXXX
XX XX
X X
XXX
X X X
XX XX
X X X
XXX
X
X X
X X
X X
X
((i >= j) && (i >= 4 - j)) || ((i <= j) && (i <= 4 - j))
!((i == j) || (i + j == 4))
(i + j == 2) || (i + j == 6) || (j - i == 2) || (i - j ==
2)
((i >= j) && (i >= 4 - j)) || ((i <= j) && (i <= 4 - j))
!((i == j) || (i + j == 4))
(i + j == 2) || (i + j == 6) || (j - i == 2) || (i - j ==
2)
((i >= j) && (i >= 4 - j)) || ((i <= j) && (i <= 4 - j))
!((i == j) || (i + j == 4))
(i + j == 2) || (i + j == 6) || (j - i == 2) || (i - j ==
2)
Answ
er
1 2 3
1
2
3
參考答案,並⾮非唯⼀一解法
For Loop
XXXXX
XXXX
XXX
XX
X
X
XX
XXX
XXXX
XXXXX
XXXXX
XXXX
XXX
XX
X
X
XX
XXX
XXXX
XXXXX
i >= j
i <= j
i <= 4 - j
i >= 4 - j
i >= j
i <= j
i <= 4 - j
i >= 4 - j
i >= j
i <= j
i <= 4 - j
i >= 4 - j
i >= j
i <= j
i <= 4 - j
i >= 4 - j
Exam
ples
1 2 3
1
2
3
4
4
補
充
範
例
For Loop
int i = 0;
for (int i = 0; i < 5; i++) {
print(i);
}
print(i);
int i;
for (i = 0; i < 5; i++) {
print(i);
}
print(i);
Exercise
For Loop
int i = 0;
for (int i = 0; i < 5; i++) {
print(i);
}
print(i);
012340
int i = 0;
for (i = 0; i < 5; i++) {
print(i);
}
print(i);
012345
Answ
er
While Loop
int k = 0;
while (k < 5) {
print(k);
k++;
}
01234
for (int k = 0; k < 5; k++) {
print(k);
}
同義寫法
01234
While Loop
int k = 0;
do {
print(k);
k++;
} while (k < 5);
01234
Calculation
a = ceil(9.2); 10
a = floor(9.2); 9
a = round(9.2); 9
x = constrain(x, 0, 10);
c = lerp(0, 10, 0.5); c = 5
n = norm(5, 0, 10); n = 0.5
m = map(val, low1, high1, low2, high2);
d = dist(x1, y1, x2, y2);
Coding Style
float vx,vy, x,y;
void setup() {
size(200,200 );
vx=random(4);
vy= random(4);
x=random( 100)+50;
y=random(100)+50;
smooth(); }
void draw(){
background(102);
float diameter=30;
float radius=diameter/2.0;
x=x+ vx;
y=y+vy;
if((x<radius)||(x >(width-radius))) {
vx*=-1; }
if((y < radius)||(y > (height -radius))) {
vy*= -1;}
ellipse(x, y, diameter, diameter);
}
float vx, vy, x, y;
void setup() {
size(200, 200);
vx = random(4);
vy = random(4);
x = random(100) + 50;
y = random(100) + 50;
smooth();
}
void draw() {
background(102);
float diameter = 30;
float radius = diameter / 2.0;
x = x + vx;
y = y + vy;
if ((x < radius) || (x > (width - radius))) {
vx *= -1;
}
if ((y < radius) || (y > (height - radius))) {
vy *= -1;
}
ellipse(x, y, diameter, diameter);
}
You are a designer. Try to make your code pretty.
X
After using
Space and
Ctrl-T
(Cmd-T on
the Mac).
OpenProcessing.org
http://www.openprocessing.org/user/907
Student
works
Examples

Weitere ähnliche Inhalte

Was ist angesagt?

Integral table
Integral tableIntegral table
Integral tablezzzubair
 
Single page-integral-table
Single page-integral-tableSingle page-integral-table
Single page-integral-tableMonique Anderson
 
Tabela derivadas-e-integrais
Tabela derivadas-e-integraisTabela derivadas-e-integrais
Tabela derivadas-e-integraismariasousagomes
 
Ecuaciones dispositivos electronicos
Ecuaciones dispositivos electronicosEcuaciones dispositivos electronicos
Ecuaciones dispositivos electronicosfsdewr
 
Tabela completa de derivadas e integrais
Tabela completa de derivadas e integraisTabela completa de derivadas e integrais
Tabela completa de derivadas e integraisDiego Rodrigues Vaz
 
基礎からのベイズ統計学 輪読会資料 第8章 「比率・相関・信頼性」
基礎からのベイズ統計学 輪読会資料  第8章 「比率・相関・信頼性」基礎からのベイズ統計学 輪読会資料  第8章 「比率・相関・信頼性」
基礎からのベイズ統計学 輪読会資料 第8章 「比率・相関・信頼性」Ken'ichi Matsui
 
Integral table
Integral tableIntegral table
Integral tableAnkitcos0
 
jhkl,l.มือครูคณิตศาสตร์พื้นฐาน ม.4 สสวท เล่ม 2fuyhfg
jhkl,l.มือครูคณิตศาสตร์พื้นฐาน ม.4 สสวท เล่ม 2fuyhfgjhkl,l.มือครูคณิตศาสตร์พื้นฐาน ม.4 สสวท เล่ม 2fuyhfg
jhkl,l.มือครูคณิตศาสตร์พื้นฐาน ม.4 สสวท เล่ม 2fuyhfgTonn Za
 
第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」
第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」
第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」Ken'ichi Matsui
 
THTT so 449 tháng 11 năm 2014
THTT so 449 tháng 11 năm 2014THTT so 449 tháng 11 năm 2014
THTT so 449 tháng 11 năm 2014Hoàng Ngọc
 
formulas calculo integral y diferencial
formulas calculo integral y diferencialformulas calculo integral y diferencial
formulas calculo integral y diferencialUANL-FIME
 

Was ist angesagt? (20)

QMT202/SET2
QMT202/SET2QMT202/SET2
QMT202/SET2
 
Integral table
Integral tableIntegral table
Integral table
 
Integral table
Integral tableIntegral table
Integral table
 
Single page-integral-table
Single page-integral-tableSingle page-integral-table
Single page-integral-table
 
Tabela derivadas-e-integrais
Tabela derivadas-e-integraisTabela derivadas-e-integrais
Tabela derivadas-e-integrais
 
Prelude to halide_public
Prelude to halide_publicPrelude to halide_public
Prelude to halide_public
 
Trabajo matemáticas 7
Trabajo matemáticas 7Trabajo matemáticas 7
Trabajo matemáticas 7
 
Single page-integral-table
Single page-integral-table Single page-integral-table
Single page-integral-table
 
05 2 관계논리비트연산
05 2 관계논리비트연산05 2 관계논리비트연산
05 2 관계논리비트연산
 
Ecuaciones dispositivos electronicos
Ecuaciones dispositivos electronicosEcuaciones dispositivos electronicos
Ecuaciones dispositivos electronicos
 
Integral calculus
  Integral calculus   Integral calculus
Integral calculus
 
Tabela completa de derivadas e integrais
Tabela completa de derivadas e integraisTabela completa de derivadas e integrais
Tabela completa de derivadas e integrais
 
Basic m4-2-chapter1
Basic m4-2-chapter1Basic m4-2-chapter1
Basic m4-2-chapter1
 
基礎からのベイズ統計学 輪読会資料 第8章 「比率・相関・信頼性」
基礎からのベイズ統計学 輪読会資料  第8章 「比率・相関・信頼性」基礎からのベイズ統計学 輪読会資料  第8章 「比率・相関・信頼性」
基礎からのベイズ統計学 輪読会資料 第8章 「比率・相関・信頼性」
 
Integral table
Integral tableIntegral table
Integral table
 
jhkl,l.มือครูคณิตศาสตร์พื้นฐาน ม.4 สสวท เล่ม 2fuyhfg
jhkl,l.มือครูคณิตศาสตร์พื้นฐาน ม.4 สสวท เล่ม 2fuyhfgjhkl,l.มือครูคณิตศาสตร์พื้นฐาน ม.4 สสวท เล่ม 2fuyhfg
jhkl,l.มือครูคณิตศาสตร์พื้นฐาน ม.4 สสวท เล่ม 2fuyhfg
 
第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」
第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」
第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」
 
Calculo
CalculoCalculo
Calculo
 
THTT so 449 tháng 11 năm 2014
THTT so 449 tháng 11 năm 2014THTT so 449 tháng 11 năm 2014
THTT so 449 tháng 11 năm 2014
 
formulas calculo integral y diferencial
formulas calculo integral y diferencialformulas calculo integral y diferencial
formulas calculo integral y diferencial
 

Ähnlich wie Processing Basics 1

Ähnlich wie Processing Basics 1 (20)

Python
PythonPython
Python
 
Vcs5
Vcs5Vcs5
Vcs5
 
Vcs16
Vcs16Vcs16
Vcs16
 
Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語
 
Wu Mamber (String Algorithms 2007)
Wu  Mamber (String Algorithms 2007)Wu  Mamber (String Algorithms 2007)
Wu Mamber (String Algorithms 2007)
 
Mutation @ Spotify
Mutation @ Spotify Mutation @ Spotify
Mutation @ Spotify
 
Python 1 liners
Python 1 linersPython 1 liners
Python 1 liners
 
Java operators
Java operatorsJava operators
Java operators
 
201707 CSE110 Lecture 13
201707 CSE110 Lecture 13   201707 CSE110 Lecture 13
201707 CSE110 Lecture 13
 
Fisica matematica final
Fisica matematica finalFisica matematica final
Fisica matematica final
 
Hypercritical C++ Code Review
Hypercritical C++ Code ReviewHypercritical C++ Code Review
Hypercritical C++ Code Review
 
for loop in java
for loop in java for loop in java
for loop in java
 
Mecánica estática
Mecánica estática Mecánica estática
Mecánica estática
 
C Code and the Art of Obfuscation
C Code and the Art of ObfuscationC Code and the Art of Obfuscation
C Code and the Art of Obfuscation
 
ALE2014 let tests drive or let dijkstra derive
ALE2014 let tests drive or let dijkstra deriveALE2014 let tests drive or let dijkstra derive
ALE2014 let tests drive or let dijkstra derive
 
関数潮流(Function Tendency)
関数潮流(Function Tendency)関数潮流(Function Tendency)
関数潮流(Function Tendency)
 
11 1. multi-dimensional array eng
11 1. multi-dimensional array eng11 1. multi-dimensional array eng
11 1. multi-dimensional array eng
 
Ejercicios john rangel
Ejercicios john rangelEjercicios john rangel
Ejercicios john rangel
 
05 1 수식과 연산자
05 1 수식과 연산자05 1 수식과 연산자
05 1 수식과 연산자
 
An introduction to Google test framework
An introduction to Google test frameworkAn introduction to Google test framework
An introduction to Google test framework
 

Mehr von June-Hao Hou

Arduino: Analog I/O
Arduino: Analog I/OArduino: Analog I/O
Arduino: Analog I/OJune-Hao Hou
 
Arduino: Intro and Digital I/O
Arduino: Intro and Digital I/OArduino: Intro and Digital I/O
Arduino: Intro and Digital I/OJune-Hao Hou
 
ETH+NCTU workshop 0419 Kyle
ETH+NCTU workshop 0419 KyleETH+NCTU workshop 0419 Kyle
ETH+NCTU workshop 0419 KyleJune-Hao Hou
 
ETH+NCTU workshop 0412 ETH
ETH+NCTU workshop 0412 ETHETH+NCTU workshop 0412 ETH
ETH+NCTU workshop 0412 ETHJune-Hao Hou
 
ETH+NCTU workshop 0412 Kyle group
ETH+NCTU workshop 0412 Kyle groupETH+NCTU workshop 0412 Kyle group
ETH+NCTU workshop 0412 Kyle groupJune-Hao Hou
 
ETH+NCTU workshop 0412 MS
ETH+NCTU workshop 0412 MSETH+NCTU workshop 0412 MS
ETH+NCTU workshop 0412 MSJune-Hao Hou
 
Taiwanese Tea culture
Taiwanese Tea cultureTaiwanese Tea culture
Taiwanese Tea cultureJune-Hao Hou
 
ETH_NCTU_Workshop_0405_Kyle
ETH_NCTU_Workshop_0405_KyleETH_NCTU_Workshop_0405_Kyle
ETH_NCTU_Workshop_0405_KyleJune-Hao Hou
 
ETH_NCTU_Workshop_0405_MS
ETH_NCTU_Workshop_0405_MSETH_NCTU_Workshop_0405_MS
ETH_NCTU_Workshop_0405_MSJune-Hao Hou
 
ETH_NCTU_Workshop_0329
ETH_NCTU_Workshop_0329ETH_NCTU_Workshop_0329
ETH_NCTU_Workshop_0329June-Hao Hou
 
Design Collaboration: Harvard-NCTU Experiences
Design Collaboration: Harvard-NCTU ExperiencesDesign Collaboration: Harvard-NCTU Experiences
Design Collaboration: Harvard-NCTU ExperiencesJune-Hao Hou
 

Mehr von June-Hao Hou (12)

Arduino: Analog I/O
Arduino: Analog I/OArduino: Analog I/O
Arduino: Analog I/O
 
Arduino: Intro and Digital I/O
Arduino: Intro and Digital I/OArduino: Intro and Digital I/O
Arduino: Intro and Digital I/O
 
跨領域設計
跨領域設計跨領域設計
跨領域設計
 
ETH+NCTU workshop 0419 Kyle
ETH+NCTU workshop 0419 KyleETH+NCTU workshop 0419 Kyle
ETH+NCTU workshop 0419 Kyle
 
ETH+NCTU workshop 0412 ETH
ETH+NCTU workshop 0412 ETHETH+NCTU workshop 0412 ETH
ETH+NCTU workshop 0412 ETH
 
ETH+NCTU workshop 0412 Kyle group
ETH+NCTU workshop 0412 Kyle groupETH+NCTU workshop 0412 Kyle group
ETH+NCTU workshop 0412 Kyle group
 
ETH+NCTU workshop 0412 MS
ETH+NCTU workshop 0412 MSETH+NCTU workshop 0412 MS
ETH+NCTU workshop 0412 MS
 
Taiwanese Tea culture
Taiwanese Tea cultureTaiwanese Tea culture
Taiwanese Tea culture
 
ETH_NCTU_Workshop_0405_Kyle
ETH_NCTU_Workshop_0405_KyleETH_NCTU_Workshop_0405_Kyle
ETH_NCTU_Workshop_0405_Kyle
 
ETH_NCTU_Workshop_0405_MS
ETH_NCTU_Workshop_0405_MSETH_NCTU_Workshop_0405_MS
ETH_NCTU_Workshop_0405_MS
 
ETH_NCTU_Workshop_0329
ETH_NCTU_Workshop_0329ETH_NCTU_Workshop_0329
ETH_NCTU_Workshop_0329
 
Design Collaboration: Harvard-NCTU Experiences
Design Collaboration: Harvard-NCTU ExperiencesDesign Collaboration: Harvard-NCTU Experiences
Design Collaboration: Harvard-NCTU Experiences
 

Kürzlich hochgeladen

Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...chiefasafspells
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburgmasabamasaba
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in sowetomasabamasaba
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...masabamasaba
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...masabamasaba
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationJuha-Pekka Tolvanen
 

Kürzlich hochgeladen (20)

Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 

Processing Basics 1

  • 5. Coordinates stroke(0, 128, 128); noFill(); rect(0, 0, 10, 10); +x +y 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
  • 6. Basic Shapes point(20, 30); (20, 30) (3, 5) (30, 50) line(3, 5, 30, 50); rect(0, 0, 10, 10); (0, 0) 10 10 ellipse(20, 30, 40, 60); (20, 30) 40 60
  • 7. Modes of Shape rectMode(CORNER); rect(0, 0, 10, 10); (0, 0) 10 10 (0, 0) (10, 10) rectMode(CORNERS); rect(0, 0, 10, 10); rectMode(CENTER); rect(0, 0, 10, 10); (0, 0) 10 10 rectMode(RADIUS); rect(0, 0, 10, 10); (0, 0) 10 10 預設值
  • 8. Variable Scope int x; void setup() { int w = 200; x = 0; size(w, w); } void draw() { int y; x = x + 1; y = x * 2; rect(0, 0, x, y); } int x int w int y draw() setup()
  • 9. Variable Scope class Cube { float cx; float cy; float size; Cube(float x, float y, float s) { cx = x; cy = y; size = s; } float volume() { float v; v = size * size * size; return v; } } float cx float cy float size float x float y float s float v Cube Cube() volume()
  • 11. For Loop for (int i = 0; i < 5; i++) { print(i); } 01234 for (int i = 0; i <= 5; i++) { print(i); } 012345 for (int i = 1; i < 5; i++) { print(i); } 1234 for (int i = 0; i < 10; i = i + 2) { print(i); } 02468
  • 12. For Loop for (int i = 0; i < 5; i++) { print(_______); } 43210 for (int i = ____; ____; i--) { print(i); } 43210 for (int i = -5; i < 5; i++) { print(_______); } 0123456789 for (int i = 0; i < 10; i++) { print(i / 2); } Exercise
  • 13. For Loop for (int i = 0; i < 5; i++) { print(4 - i); } 43210 for (int i = 4; i >= 0; i--) { print(i); } 43210 for (int i = -5; i < 5; i++) { print(i + 5); } 0123456789 for (int i = 0; i < 10; i++) { print(i / 2); } 0011223344 Answ er
  • 14. For Loop for (int i = 0; i < 100; i = i + 10) { if (i % 5 == 0) i = i - 5; println(i); } for (int i = 0; true; i++) { // Do something... } << 執⾏行次數? Exercise
  • 15. For Loop for (int i = 0; i < 100; i = i + 10) { if (i % 5 == 0) i = i - 5; println(i); } -5 0 5 10 15 ... 90 (執⾏行20次) for (int i = 0; true; i++) { // Do something... } (永不停⽌止) Answ er
  • 16. For Loop for (int i = 0; i < 5; i++) { print("X"); } println(); XXXXX for (int j = 0; j < 5; j++) { for (int i = 0; i < 5; i++) { print("X"); } println(); } XXXXX XXXXX XXXXX XXXXX XXXXX
  • 17. For Loop for (int j = 0; j < 5; j++) { for (int i = j; i < 5; i++) { print("X"); } println(); } for (int j = 0; j < 5; j++) { for (int i = 0; i < 5; i++) { if (______) { print("X"); } else { print(" "); } } println(); } X X X X X X X X X X X X X X X Exercise
  • 18. For Loop for (int j = 0; j < 5; j++) { for (int i = j; i < 5; i++) { print("X"); } println(); } XXXXX XXXX XXX XX X for (int j = 0; j < 5; j++) { for (int i = 0; i < 5; i++) { if (i % 2 == 0) { print("X"); } else { print(" "); } } println(); } X X X X X X X X X X X X X X X Answ er
  • 19. For Loop X X X X X X X X X i=0 i=1 i=2 i=3 i=4 j=0 j=1 j=2 j=3 j=4 (i % 2) == 0 && (j % 2) == 0
  • 20. For Loop X X X X X X X X X X X X i=0 i=1 i=2 i=3 i=4 j=0 j=1 j=2 j=3 j=4 ((i == 0 || i == 4) || (j == 0 || j == 4)) && (i != j) && (i + j != 4)
  • 21. For Loop XXXXX X X X X X X XXXXX X X X X X X X X X XXXXX XXX X XXX XXXXX X X X X X X X X X X X X X XXXX X XXX XX XX XXX X XXXX XXXX XXX X XX XX X XXX XXXX X X XX XX XXXXX XX XX X X XXX X X X XX XX X X X XXX X X X X X X X X Exercise
  • 22. For Loop XXXXX X X X X X X XXXXX X X X X X X X X X XXXXX XXX X XXX XXXXX ((i == 0) || (i == 4)) || ((j == 0) || (j == 4)) (i == j) || (i + j == 4) ((i >= j) && (i <= 4 - j)) || ((i <= j) && (i >= 4 - j)) ((i == 0) || (i == 4)) || ((j == 0) || (j == 4)) (i == j) || (i + j == 4) ((i >= j) && (i <= 4 - j)) || ((i <= j) && (i >= 4 - j)) ((i == 0) || (i == 4)) || ((j == 0) || (j == 4)) (i == j) || (i + j == 4) ((i >= j) && (i <= 4 - j)) || ((i <= j) && (i >= 4 - j)) Answ er 1 2 3 1 2 3 參考答案,並⾮非唯⼀一解法
  • 23. For Loop X X X X X X X X X X X X X XXXX X XXX XX XX XXX X XXXX XXXX XXX X XX XX X XXX XXXX (i + j) % 2 == 0 !(i == j) !(i + j == 4) (i + j) % 2 == 0 !(i == j) !(i + j == 4) (i + j) % 2 == 0 !(i == j) !(i + j == 4) Answ er 1 2 3 1 2 3 參考答案,並⾮非唯⼀一解法
  • 24. For Loop X X XX XX XXXXX XX XX X X XXX X X X XX XX X X X XXX X X X X X X X X ((i >= j) && (i >= 4 - j)) || ((i <= j) && (i <= 4 - j)) !((i == j) || (i + j == 4)) (i + j == 2) || (i + j == 6) || (j - i == 2) || (i - j == 2) ((i >= j) && (i >= 4 - j)) || ((i <= j) && (i <= 4 - j)) !((i == j) || (i + j == 4)) (i + j == 2) || (i + j == 6) || (j - i == 2) || (i - j == 2) ((i >= j) && (i >= 4 - j)) || ((i <= j) && (i <= 4 - j)) !((i == j) || (i + j == 4)) (i + j == 2) || (i + j == 6) || (j - i == 2) || (i - j == 2) Answ er 1 2 3 1 2 3 參考答案,並⾮非唯⼀一解法
  • 25. For Loop XXXXX XXXX XXX XX X X XX XXX XXXX XXXXX XXXXX XXXX XXX XX X X XX XXX XXXX XXXXX i >= j i <= j i <= 4 - j i >= 4 - j i >= j i <= j i <= 4 - j i >= 4 - j i >= j i <= j i <= 4 - j i >= 4 - j i >= j i <= j i <= 4 - j i >= 4 - j Exam ples 1 2 3 1 2 3 4 4 補 充 範 例
  • 26. For Loop int i = 0; for (int i = 0; i < 5; i++) { print(i); } print(i); int i; for (i = 0; i < 5; i++) { print(i); } print(i); Exercise
  • 27. For Loop int i = 0; for (int i = 0; i < 5; i++) { print(i); } print(i); 012340 int i = 0; for (i = 0; i < 5; i++) { print(i); } print(i); 012345 Answ er
  • 28. While Loop int k = 0; while (k < 5) { print(k); k++; } 01234 for (int k = 0; k < 5; k++) { print(k); } 同義寫法 01234
  • 29. While Loop int k = 0; do { print(k); k++; } while (k < 5); 01234
  • 30. Calculation a = ceil(9.2); 10 a = floor(9.2); 9 a = round(9.2); 9 x = constrain(x, 0, 10); c = lerp(0, 10, 0.5); c = 5 n = norm(5, 0, 10); n = 0.5 m = map(val, low1, high1, low2, high2); d = dist(x1, y1, x2, y2);
  • 31. Coding Style float vx,vy, x,y; void setup() { size(200,200 ); vx=random(4); vy= random(4); x=random( 100)+50; y=random(100)+50; smooth(); } void draw(){ background(102); float diameter=30; float radius=diameter/2.0; x=x+ vx; y=y+vy; if((x<radius)||(x >(width-radius))) { vx*=-1; } if((y < radius)||(y > (height -radius))) { vy*= -1;} ellipse(x, y, diameter, diameter); } float vx, vy, x, y; void setup() { size(200, 200); vx = random(4); vy = random(4); x = random(100) + 50; y = random(100) + 50; smooth(); } void draw() { background(102); float diameter = 30; float radius = diameter / 2.0; x = x + vx; y = y + vy; if ((x < radius) || (x > (width - radius))) { vx *= -1; } if ((y < radius) || (y > (height - radius))) { vy *= -1; } ellipse(x, y, diameter, diameter); } You are a designer. Try to make your code pretty. X After using Space and Ctrl-T (Cmd-T on the Mac).