SlideShare a Scribd company logo
1 of 36
Download to read offline
1
ZAWA WORKS
2
FMS 2
Processing 6
@zawaworks
@Zawa_works
3
for , while
size()
background() , ll(), stroke(), strokeWeight()
rect(), ellipse(), arc()
mousePressed(), keyPressed()
random()
int, oat, string, boolean
if
4
5
surface.setLocation(x, y)
6
int count = 0;
void setup() {
size(500, 500);
}
void draw() {
//60フレーム後に実行画面の位置を変更
if (count%60 == 0) {
int x = (int)random(displayWidth - width);
int y = (int)random(displayHeight - height);
surface.setLocation(x, y);
}
count++;
}
60
surface.setLocation(x, y)
7
size(640, 480);
int screenX = (displayWidth - width)/2;
int screenY = (displayHeight - height)/2;
surface.setLocation(screenX, screenY);
fullScreen()
8
fullScreen();
background(0);
ellipse(width/2, height/2, 200, 200);
size(640, 480);
background(0);
ellipse(width/2, height/2, 200, 200);
fullScreen()
9
map(a, b, c, d, e)
10
a b-c d-e
map(a, b, c, d, e)
11
int progress = 0;
int progressMax = 300;
void setup() {
size(500, 100);
noStroke();
}
void draw() {
background(255);
fill(0, 255, 0 );
//進行状況を0~widthの範囲に変換
float w = map(progress, 0, progressMax, 0, width);
rect(0, 0, w, height);
progress++;
}
a b-c d-e
map(a, b, c, d, e)
HP
HP
12
int hpMax = 300;
int hp = hpMax;
int damage = 30;
void setup() {
size(500, 100);
noStroke();
}
void draw() {
background(255);
float w = map(hp, 0, hpMax, 0, width);
fill(0, 255, 0 );
rect(0, 0, w, height);
}
void mousePressed(){
hp -= damage;
}
a b-c d-e
map(a, b, c, d, e)
13
int progress = 0;
int progressMax = 300;
void setup() {
size(500, 500);
noStroke();
}
void draw() {
background(255);
fill(0, 255, 0 );
//進行状況を0~widthの範囲に変換
float rad = map(progress, 0, progressMax, -HALF_PI, 3*PI/2 );
arc(width/2, height/2, 400, 400, -HALF_PI, rad);
progress++;
}
map(a, b, c, d, e)
14
int count = 0;
int x0, y0, x1, y1;
void setup() {
size(500, 500);
x0 = (int)random(width);
y0 = (int)random(height);
x1 = (int)random(width);
y1 = (int)random(height);
}
void draw() {
background(228);
fill(255, 0, 0);
ellipse(x0, y0, 10, 10);
ellipse(x1, y1, 10, 10);
float x = map(count, 0, 100, x0, x1);
float y = map(count, 0, 100, y0, y1);
fill(255);
ellipse(x, y, 50, 50);
count++;
if (count >= 100)count = 0;
}
15
translate(x, y)
16
size(640, 360);
background(0);
fill(255);
ellipse(0, 0, 100, 100);
size(640, 360);
background(0);
translate(width, height);//追加
fill(255);
ellipse(0, 0, 100, 100);
translate()
translate(x, y)
17
translate(x, y)
(x, y)
( , )
translate(x, y)
18
void setup() {
size(500, 500);
noCursor();
}
void draw() {
background(0);
 
//複数の図形がマウスに追従する
translate(mouseX, mouseY);
fill(255);
ellipse(-100, 100, 100, 100);
fill(255, 0, 0);
rect(50, -100, 100, 100);
}
push();//追加
translate(mouseX, mouseY);
fill(255);
ellipse(-100, 100, 100, 100);
pop();//追加
push() pop() ellipse()
rotate(rad)
19
int count = 0;
void setup() {
size(500, 500);
}
void draw() {
background(0);
rotate(radians(count));
fill(255, 0, 0);
rect(100, 50, 100, 100);
count += 2;
}
1
rotate(rad)
20
rotate(rad)
rad
rotate(rad)
21
int count = 0;
void setup() {
size(500, 500);
}
void draw() {
background(0);
translate(width/2, height/2);//追加
rotate(radians(count));
fill(255, 0, 0);
rect(100, 50, 100, 100);
count += 2;
}
1
rotate(rad)
22
int count = 0;
void setup() {
size(500, 500);
}
void draw() {
background(0);
translate(width/2, height/2);
rotate(radians(count));
translate(-50, -50);//-rectの幅/2, -rectの高さ/2
fill(255, 0, 0);
rect(0, 0, 100, 100);
count += 2;
}
scale(s)
scale()
23
size(500, 500);
rect(50, 50, 100, 100);
scale( )
scale( . ) scale( , )
size(500, 500);
scale(3);
rect(50, 50, 100, 100);
size(500, 500);
scale(0.4);
rect(50, 50, 100, 100);
size(500, 500);
scale(2, 3);
rect(50, 50, 100, 100);
scale(s)
24
scale(s)
s
scale(s)
scale( , )
25
scale(- , )
scale( , - ) scale(- , - )
size(500, 500);
push();
translate(width/2, height/2);
scale(-1, 1);//ここを書き換える
rect(50, 50, 100, 100);
pop();
stroke(255, 0, 0);
line(width/2, 0, width/2, height);
line(0, height/2 , width, height/2);
scale(s)
26
boolean isLeft = false;
void setup() {
size(500, 500);
}
void draw() {
background(0);
translate(width/2, height/2);
if (isLeft)scale(-1, 1);
fill(255, 0, 0);
rect(0, 0, 100, 100);
}
void keyPressed() {
if (keyCode == LEFT)isLeft = true;
if (keyCode == RIGHT)isLeft = false;
}
scale(s)
27
28
rectMode(mode)
rect()
29
void setup() {
size(500, 500);
rectMode(CENTER);
}
void draw() {
stroke(0);
rect(width/2, height/2, 100, 100);
stroke(255, 0, 0);
line(width/2, 0, width/2, height);
line(0, height/2, width, height/2);
}
rectMode(CENTER)
rectMode(mode)
30
int count = 0;
void setup() {
size(500, 500);
rectMode(CENTER);
}
void draw() {
background(0);
translate(width/2, height/2);
rotate(radians(count));
fill(255, 0, 0);
rect(0, 0, 100, 100);
count += 2;
}
(x , y )
(x , y )
rectMode()
31
CORNER
rect(x, y, width, height)
(x, y)
CENTER
rect(x, y, width, height)
(x, y)
CORNERS
rect(x , y , x , y )
(x , y ) (x , y )
RADIUS
rect(x, y, w_h, h_h)
(x, y)
(x, y)
w
h
(x, y)
w_h
h_h
(x, y)
w
h
ellipseMode()
32
CORNER
ellipse(x, y, width, height)
(x, y)
CENTER
ellipse(x, y, width, height)
(x, y)
CORNERS
ellipse(x , y , x , y )
(x , y ) (x , y )
RADIUS
ellipse(x, y, w_h, h_h)
(x, y)
(x, y)
w
h
(x , y )
(x , y )
(x, y)
w
h
(x, y)
w_h
h_h
(x, y)
w
h
imageMode()
33
PImage img;
void setup() {
size(500, 500);
img = loadImage(“images/bear.jpg”);
imageMode(CENTER);//ここを書き換える
}
void draw() {
image(img, width/2, height/2);
stroke(255, 0, 0);
line(width/2, 0, width/2, height);
line(0, height/2, width, height/2);
}
CORNER
image(img, x, y, width, height)
(x, y)
CORNERS
image(img, x , y , x , y )
(x , y ), (x , y )
CENTER
image(img, x, y, width, height)
(x, y)
(x, y)
w
h
(x , y )
(x , y )
imageMode()
rotate()
34
PImage img;
int x, y;
float rad;
void setup() {
size(500, 500);
img = loadImage("images/topview_man.png");
x = width/2;
y = height/2;
rad = 0;
imageMode(CENTER);
}
void draw() {
background(255);
translate(x, y);
rotate(rad);
image(img, 0, 0, 100, 100);
if (keyPressed&&keyCode == UP) {
rad = PI;
y -= 10;
}
if (keyPressed&&keyCode == DOWN) {
rad = 0;
y += 10;
}
if (keyPressed&&keyCode == LEFT) {
rad = HALF_PI;
x -= 10;
}
if (keyPressed&&keyCode == RIGHT) {
rad = -HALF_PI;
x += 10;
}
}
imageMode(mode)
rotate()
35
rotate( ) rotate(HALF_PI) rotate(PI) rotate(-HALF_PI)
imageMode()
scale()
36
PImage img;
float s = 0;
float ds = 0.02;
void setup() {
size(500, 500);
img = loadImage("images/heart_eyes.png");
imageMode(CENTER);
}
void draw() {
background(255);
translate(width/2, height/2);
scale(s);
image(img, 0, 0);
s += ds;
if(s > 1 || s < 0)ds = -ds;
}

More Related Content

What's hot

Representacion funciones sage cell
Representacion funciones sage cellRepresentacion funciones sage cell
Representacion funciones sage cellMarcos Otero
 
Plot3D Package and Example in R.-Data visualizat,on
Plot3D Package and Example in R.-Data visualizat,onPlot3D Package and Example in R.-Data visualizat,on
Plot3D Package and Example in R.-Data visualizat,onDr. Volkan OBAN
 
Visual Basic
Visual BasicVisual Basic
Visual BasicVj NiroSh
 
Creative Coding 1 - 2 Variables
Creative Coding 1 - 2 VariablesCreative Coding 1 - 2 Variables
Creative Coding 1 - 2 VariablesTill Nagel
 
Processing iii
Processing iiiProcessing iii
Processing iiicitylore
 
functions
functionsfunctions
functionssmirn4
 
ARTDM 170, Week13: Processing
ARTDM 170, Week13: ProcessingARTDM 170, Week13: Processing
ARTDM 170, Week13: ProcessingGilbert Guerrero
 
5.7 rolle's thrm & mv theorem
5.7 rolle's thrm & mv theorem5.7 rolle's thrm & mv theorem
5.7 rolle's thrm & mv theoremdicosmo178
 
5.3 curve sketching
5.3 curve sketching5.3 curve sketching
5.3 curve sketchingdicosmo178
 
5.2 first and second derivative test
5.2 first and second derivative test5.2 first and second derivative test
5.2 first and second derivative testdicosmo178
 

What's hot (17)

Day 3 examples
Day 3 examplesDay 3 examples
Day 3 examples
 
Representacion funciones sage cell
Representacion funciones sage cellRepresentacion funciones sage cell
Representacion funciones sage cell
 
Plot3D Package and Example in R.-Data visualizat,on
Plot3D Package and Example in R.-Data visualizat,onPlot3D Package and Example in R.-Data visualizat,on
Plot3D Package and Example in R.-Data visualizat,on
 
Include
IncludeInclude
Include
 
Joclad 2010 d
Joclad 2010 dJoclad 2010 d
Joclad 2010 d
 
R graphics
R graphicsR graphics
R graphics
 
Kwp2 091217
Kwp2 091217Kwp2 091217
Kwp2 091217
 
Visual Basic
Visual BasicVisual Basic
Visual Basic
 
Creative Coding 1 - 2 Variables
Creative Coding 1 - 2 VariablesCreative Coding 1 - 2 Variables
Creative Coding 1 - 2 Variables
 
Processing iii
Processing iiiProcessing iii
Processing iii
 
Derivative graphs
Derivative graphsDerivative graphs
Derivative graphs
 
functions
functionsfunctions
functions
 
Calc 3.6a
Calc 3.6aCalc 3.6a
Calc 3.6a
 
ARTDM 170, Week13: Processing
ARTDM 170, Week13: ProcessingARTDM 170, Week13: Processing
ARTDM 170, Week13: Processing
 
5.7 rolle's thrm & mv theorem
5.7 rolle's thrm & mv theorem5.7 rolle's thrm & mv theorem
5.7 rolle's thrm & mv theorem
 
5.3 curve sketching
5.3 curve sketching5.3 curve sketching
5.3 curve sketching
 
5.2 first and second derivative test
5.2 first and second derivative test5.2 first and second derivative test
5.2 first and second derivative test
 

Similar to Know more processing

Similar to Know more processing (20)

Kwp2 100121
Kwp2 100121Kwp2 100121
Kwp2 100121
 
Canvas
CanvasCanvas
Canvas
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
 
Proga 0608
Proga 0608Proga 0608
Proga 0608
 
Exploring Canvas
Exploring CanvasExploring Canvas
Exploring Canvas
 
SVGo workshop
SVGo workshopSVGo workshop
SVGo workshop
 
Kwp2 100114
Kwp2 100114Kwp2 100114
Kwp2 100114
 
Selective codes
Selective codesSelective codes
Selective codes
 
Matlab ploting
Matlab plotingMatlab ploting
Matlab ploting
 
Computer Graphics Lab File C Programs
Computer Graphics Lab File C ProgramsComputer Graphics Lab File C Programs
Computer Graphics Lab File C Programs
 
ES6(ES2015) is beautiful
ES6(ES2015) is beautifulES6(ES2015) is beautiful
ES6(ES2015) is beautiful
 
ECMAScript 6 major changes
ECMAScript 6 major changesECMAScript 6 major changes
ECMAScript 6 major changes
 
Proga 0629
Proga 0629Proga 0629
Proga 0629
 
SwiftUI Animation - The basic overview
SwiftUI Animation - The basic overviewSwiftUI Animation - The basic overview
SwiftUI Animation - The basic overview
 
Lec2
Lec2Lec2
Lec2
 
Proga 0622
Proga 0622Proga 0622
Proga 0622
 
Advanced
AdvancedAdvanced
Advanced
 
Creating an Uber Clone - Part VIII.pdf
Creating an Uber Clone - Part VIII.pdfCreating an Uber Clone - Part VIII.pdf
Creating an Uber Clone - Part VIII.pdf
 
Creating masterpieces with raphael
Creating masterpieces with raphaelCreating masterpieces with raphael
Creating masterpieces with raphael
 
Create a java project that - Draw a circle with three random init.pdf
Create a java project that - Draw a circle with three random init.pdfCreate a java project that - Draw a circle with three random init.pdf
Create a java project that - Draw a circle with three random init.pdf
 

Recently uploaded

Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 

Know more processing

  • 1. 1
  • 2. ZAWA WORKS 2 FMS 2 Processing 6 @zawaworks @Zawa_works
  • 3. 3 for , while size() background() , ll(), stroke(), strokeWeight() rect(), ellipse(), arc() mousePressed(), keyPressed() random() int, oat, string, boolean if
  • 4. 4
  • 5. 5
  • 6. surface.setLocation(x, y) 6 int count = 0; void setup() { size(500, 500); } void draw() { //60フレーム後に実行画面の位置を変更 if (count%60 == 0) { int x = (int)random(displayWidth - width); int y = (int)random(displayHeight - height); surface.setLocation(x, y); } count++; } 60
  • 7. surface.setLocation(x, y) 7 size(640, 480); int screenX = (displayWidth - width)/2; int screenY = (displayHeight - height)/2; surface.setLocation(screenX, screenY);
  • 8. fullScreen() 8 fullScreen(); background(0); ellipse(width/2, height/2, 200, 200); size(640, 480); background(0); ellipse(width/2, height/2, 200, 200); fullScreen()
  • 9. 9
  • 10. map(a, b, c, d, e) 10 a b-c d-e
  • 11. map(a, b, c, d, e) 11 int progress = 0; int progressMax = 300; void setup() { size(500, 100); noStroke(); } void draw() { background(255); fill(0, 255, 0 ); //進行状況を0~widthの範囲に変換 float w = map(progress, 0, progressMax, 0, width); rect(0, 0, w, height); progress++; } a b-c d-e
  • 12. map(a, b, c, d, e) HP HP 12 int hpMax = 300; int hp = hpMax; int damage = 30; void setup() { size(500, 100); noStroke(); } void draw() { background(255); float w = map(hp, 0, hpMax, 0, width); fill(0, 255, 0 ); rect(0, 0, w, height); } void mousePressed(){ hp -= damage; } a b-c d-e
  • 13. map(a, b, c, d, e) 13 int progress = 0; int progressMax = 300; void setup() { size(500, 500); noStroke(); } void draw() { background(255); fill(0, 255, 0 ); //進行状況を0~widthの範囲に変換 float rad = map(progress, 0, progressMax, -HALF_PI, 3*PI/2 ); arc(width/2, height/2, 400, 400, -HALF_PI, rad); progress++; }
  • 14. map(a, b, c, d, e) 14 int count = 0; int x0, y0, x1, y1; void setup() { size(500, 500); x0 = (int)random(width); y0 = (int)random(height); x1 = (int)random(width); y1 = (int)random(height); } void draw() { background(228); fill(255, 0, 0); ellipse(x0, y0, 10, 10); ellipse(x1, y1, 10, 10); float x = map(count, 0, 100, x0, x1); float y = map(count, 0, 100, y0, y1); fill(255); ellipse(x, y, 50, 50); count++; if (count >= 100)count = 0; }
  • 15. 15
  • 16. translate(x, y) 16 size(640, 360); background(0); fill(255); ellipse(0, 0, 100, 100); size(640, 360); background(0); translate(width, height);//追加 fill(255); ellipse(0, 0, 100, 100); translate()
  • 18. translate(x, y) 18 void setup() { size(500, 500); noCursor(); } void draw() { background(0);   //複数の図形がマウスに追従する translate(mouseX, mouseY); fill(255); ellipse(-100, 100, 100, 100); fill(255, 0, 0); rect(50, -100, 100, 100); } push();//追加 translate(mouseX, mouseY); fill(255); ellipse(-100, 100, 100, 100); pop();//追加 push() pop() ellipse()
  • 19. rotate(rad) 19 int count = 0; void setup() { size(500, 500); } void draw() { background(0); rotate(radians(count)); fill(255, 0, 0); rect(100, 50, 100, 100); count += 2; } 1
  • 21. rotate(rad) 21 int count = 0; void setup() { size(500, 500); } void draw() { background(0); translate(width/2, height/2);//追加 rotate(radians(count)); fill(255, 0, 0); rect(100, 50, 100, 100); count += 2; } 1
  • 22. rotate(rad) 22 int count = 0; void setup() { size(500, 500); } void draw() { background(0); translate(width/2, height/2); rotate(radians(count)); translate(-50, -50);//-rectの幅/2, -rectの高さ/2 fill(255, 0, 0); rect(0, 0, 100, 100); count += 2; }
  • 23. scale(s) scale() 23 size(500, 500); rect(50, 50, 100, 100); scale( ) scale( . ) scale( , ) size(500, 500); scale(3); rect(50, 50, 100, 100); size(500, 500); scale(0.4); rect(50, 50, 100, 100); size(500, 500); scale(2, 3); rect(50, 50, 100, 100);
  • 25. scale(s) scale( , ) 25 scale(- , ) scale( , - ) scale(- , - ) size(500, 500); push(); translate(width/2, height/2); scale(-1, 1);//ここを書き換える rect(50, 50, 100, 100); pop(); stroke(255, 0, 0); line(width/2, 0, width/2, height); line(0, height/2 , width, height/2);
  • 26. scale(s) 26 boolean isLeft = false; void setup() { size(500, 500); } void draw() { background(0); translate(width/2, height/2); if (isLeft)scale(-1, 1); fill(255, 0, 0); rect(0, 0, 100, 100); } void keyPressed() { if (keyCode == LEFT)isLeft = true; if (keyCode == RIGHT)isLeft = false; }
  • 28. 28
  • 29. rectMode(mode) rect() 29 void setup() { size(500, 500); rectMode(CENTER); } void draw() { stroke(0); rect(width/2, height/2, 100, 100); stroke(255, 0, 0); line(width/2, 0, width/2, height); line(0, height/2, width, height/2); } rectMode(CENTER)
  • 30. rectMode(mode) 30 int count = 0; void setup() { size(500, 500); rectMode(CENTER); } void draw() { background(0); translate(width/2, height/2); rotate(radians(count)); fill(255, 0, 0); rect(0, 0, 100, 100); count += 2; }
  • 31. (x , y ) (x , y ) rectMode() 31 CORNER rect(x, y, width, height) (x, y) CENTER rect(x, y, width, height) (x, y) CORNERS rect(x , y , x , y ) (x , y ) (x , y ) RADIUS rect(x, y, w_h, h_h) (x, y) (x, y) w h (x, y) w_h h_h (x, y) w h
  • 32. ellipseMode() 32 CORNER ellipse(x, y, width, height) (x, y) CENTER ellipse(x, y, width, height) (x, y) CORNERS ellipse(x , y , x , y ) (x , y ) (x , y ) RADIUS ellipse(x, y, w_h, h_h) (x, y) (x, y) w h (x , y ) (x , y ) (x, y) w h (x, y) w_h h_h
  • 33. (x, y) w h imageMode() 33 PImage img; void setup() { size(500, 500); img = loadImage(“images/bear.jpg”); imageMode(CENTER);//ここを書き換える } void draw() { image(img, width/2, height/2); stroke(255, 0, 0); line(width/2, 0, width/2, height); line(0, height/2, width, height/2); } CORNER image(img, x, y, width, height) (x, y) CORNERS image(img, x , y , x , y ) (x , y ), (x , y ) CENTER image(img, x, y, width, height) (x, y) (x, y) w h (x , y ) (x , y )
  • 34. imageMode() rotate() 34 PImage img; int x, y; float rad; void setup() { size(500, 500); img = loadImage("images/topview_man.png"); x = width/2; y = height/2; rad = 0; imageMode(CENTER); } void draw() { background(255); translate(x, y); rotate(rad); image(img, 0, 0, 100, 100); if (keyPressed&&keyCode == UP) { rad = PI; y -= 10; } if (keyPressed&&keyCode == DOWN) { rad = 0; y += 10; } if (keyPressed&&keyCode == LEFT) { rad = HALF_PI; x -= 10; } if (keyPressed&&keyCode == RIGHT) { rad = -HALF_PI; x += 10; } }
  • 36. imageMode() scale() 36 PImage img; float s = 0; float ds = 0.02; void setup() { size(500, 500); img = loadImage("images/heart_eyes.png"); imageMode(CENTER); } void draw() { background(255); translate(width/2, height/2); scale(s); image(img, 0, 0); s += ds; if(s > 1 || s < 0)ds = -ds; }