SlideShare a Scribd company logo
1 of 25
//


boolean pressed = false;
int count;

void setup()
{
  size(400,400);
  noStroke();
  colorMode(HSB,360,100,100,100);
  background(0);
}

void draw()
{
  if(pressed){
     fill(0,0,0,0.4);
     rect(0,0,width,height);
     fill(count%360,80,80,20);
     ellipse(mouseX, mouseY, 40, 40);
     ellipse(width-mouseX, mouseY, 40, 40);
     ellipse(mouseX, height-mouseY, 40, 40);
     ellipse(width-mouseX, height-mouseY, 40, 40);
  }
  count = count + 1;
}
void mousePressed()
{
  pressed = true;
}

void mouseReleased()
{
  pressed = false;
}
//


void setup()
{
  size(400, 400);
  noStroke();
  smooth();
}

void draw()
{
  background(0,0,0);
  fill(31,127,255,200);
  ellipse(mouseX, height/2, mouseY/3, mouseY/3);
  ellipse(width-mouseX,height/2,((height-mouseY)/3),((height-mouseY)/3));
}
//

boolean pressed = false;
int count;

void setup()
{
  size(400, 400);
  noStroke();
  colorMode(HSB,360,100,100,100);
  background(0);
  rectMode(CENTER);
}

void draw()
{
  if(pressed){
     fill(count%360,100,100,5);
     rect(mouseX, height/2, random(10,20), height);
  }
  count = count+1;
}
void mousePressed(){
  pressed = true;
}

void mouseReleased(){
  pressed = false;
}
//

float x, y;
float targetX, targetY;
float easing = 0.05;
boolean pressed = false;

void setup()
{
  size(400, 400);
  smooth();
  noStroke();
  background(0,0,0);
}

void draw()
{
  fill(0,0,0,10);
  rect(0,0,width,height);

     if(pressed){
        targetX = mouseX;
        targetY = mouseY;
     }
float dx = targetX - x;
    x += dx * easing;
    float dy = targetY - y;
    y += dy * easing;

    fill(31,127,255);
    ellipse(x, y, 33, 33);
}

void mousePressed()
{
  pressed = true;
}

void mouseReleased()
{
  pressed = false;
}
//

int NUM = 400;
float[] x = new float[NUM];
float[] y = new float[NUM];
float[] targetX = new float[NUM];
float[] targetY = new float[NUM];
float easing = 0.05;
boolean pressed = false;

void setup()
{
  size(400, 400);
  smooth();
  noStroke();
  background(0,0,0);
  for(int i=0; i<NUM; i++){
     x[i] = targetX[i] = random(width);
     y[i] = targetY[i] = random(height);
  }
}

void draw()
{
  fill(0,0,0,10);
for(int i=0; i<NUM; i++){
       if(pressed){
          targetX[i] = mouseX;
          targetY[i] = mouseY;
       }

        float dx = targetX[i] - x[i];
        x[i] += dx * easing;
        float dy = targetY[i] - y[i];
        y[i] += dy * easing;

        fill(31,127,255,40);
        ellipse(x[i], y[i], 20, 20);
    }
}

void mousePressed()
{
  pressed = true;
}

void mouseReleased()
{
  pressed = false;
  for(int i=0; i<NUM; i++){
void mouseReleased()
{
  pressed = false;
  for(int i=0; i<NUM; i++){
     targetX[i] = random(width);
     targetY[i] = random(height);
  }
}
Processing Interactive Circles and Ellipses

More Related Content

What's hot

Programa expresiones regulares
Programa expresiones regularesPrograma expresiones regulares
Programa expresiones regularesAnel Sosa
 
[3] 프로세싱과 아두이노
[3] 프로세싱과 아두이노[3] 프로세싱과 아두이노
[3] 프로세싱과 아두이노Chiwon Song
 
PYTHON PROGRAMS FOR BEGINNERS
PYTHON PROGRAMS FOR BEGINNERSPYTHON PROGRAMS FOR BEGINNERS
PYTHON PROGRAMS FOR BEGINNERSJEETPRATAPSINGH
 
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
 
Introduction to Generative Art with Processing
Introduction to Generative Art with ProcessingIntroduction to Generative Art with Processing
Introduction to Generative Art with Processingstefk00
 
Creative Coding 1 - 1 Introduction
Creative Coding 1 - 1 IntroductionCreative Coding 1 - 1 Introduction
Creative Coding 1 - 1 IntroductionTill Nagel
 
Visual Basic
Visual BasicVisual Basic
Visual BasicVj NiroSh
 
ARTDM 170, Week13: Processing
ARTDM 170, Week13: ProcessingARTDM 170, Week13: Processing
ARTDM 170, Week13: ProcessingGilbert Guerrero
 
Place Value
Place ValuePlace Value
Place Valuemansuk
 
Processing iii
Processing iiiProcessing iii
Processing iiicitylore
 
Find the output of the following code (Java for ICSE)
Find the output of the following code (Java for ICSE)Find the output of the following code (Java for ICSE)
Find the output of the following code (Java for ICSE)Mokshya Priyadarshee
 
Master Thesis presentation
Master Thesis presentationMaster Thesis presentation
Master Thesis presentationMajid Hajibaba
 

What's hot (17)

Programa expresiones regulares
Programa expresiones regularesPrograma expresiones regulares
Programa expresiones regulares
 
[3] 프로세싱과 아두이노
[3] 프로세싱과 아두이노[3] 프로세싱과 아두이노
[3] 프로세싱과 아두이노
 
Include
IncludeInclude
Include
 
PYTHON PROGRAMS FOR BEGINNERS
PYTHON PROGRAMS FOR BEGINNERSPYTHON PROGRAMS FOR BEGINNERS
PYTHON PROGRAMS FOR BEGINNERS
 
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
 
Introduction to Generative Art with Processing
Introduction to Generative Art with ProcessingIntroduction to Generative Art with Processing
Introduction to Generative Art with Processing
 
Creative Coding 1 - 1 Introduction
Creative Coding 1 - 1 IntroductionCreative Coding 1 - 1 Introduction
Creative Coding 1 - 1 Introduction
 
Seg code
Seg codeSeg code
Seg code
 
Visual Basic
Visual BasicVisual Basic
Visual Basic
 
Day 3 examples
Day 3 examplesDay 3 examples
Day 3 examples
 
ARTDM 170, Week13: Processing
ARTDM 170, Week13: ProcessingARTDM 170, Week13: Processing
ARTDM 170, Week13: Processing
 
Place Value
Place ValuePlace Value
Place Value
 
Introduction to Processing
Introduction to ProcessingIntroduction to Processing
Introduction to Processing
 
Processing iii
Processing iiiProcessing iii
Processing iii
 
Advanced Concepts in Python
Advanced Concepts in PythonAdvanced Concepts in Python
Advanced Concepts in Python
 
Find the output of the following code (Java for ICSE)
Find the output of the following code (Java for ICSE)Find the output of the following code (Java for ICSE)
Find the output of the following code (Java for ICSE)
 
Master Thesis presentation
Master Thesis presentationMaster Thesis presentation
Master Thesis presentation
 

Viewers also liked (8)

Sbaw091013
Sbaw091013Sbaw091013
Sbaw091013
 
Kwp2 091203
Kwp2 091203Kwp2 091203
Kwp2 091203
 
Busipro091008
Busipro091008Busipro091008
Busipro091008
 
Kwp2 1022
Kwp2 1022Kwp2 1022
Kwp2 1022
 
Kwp2 091210
Kwp2 091210Kwp2 091210
Kwp2 091210
 
Sbaw091130
Sbaw091130Sbaw091130
Sbaw091130
 
Kwp2 100114
Kwp2 100114Kwp2 100114
Kwp2 100114
 
Sbaw091006
Sbaw091006Sbaw091006
Sbaw091006
 

Similar to Processing Interactive Circles and Ellipses

ARTDM 170, Week10: Arrays + Using Randomization
ARTDM 170, Week10: Arrays + Using RandomizationARTDM 170, Week10: Arrays + Using Randomization
ARTDM 170, Week10: Arrays + Using RandomizationGilbert Guerrero
 
Artdm170 Week10 Arrays Math
Artdm170 Week10 Arrays MathArtdm170 Week10 Arrays Math
Artdm170 Week10 Arrays MathGilbert Guerrero
 
ARTDM 170, Week 13: Text Elements + Arrays
ARTDM 170, Week 13: Text Elements + ArraysARTDM 170, Week 13: Text Elements + Arrays
ARTDM 170, Week 13: Text Elements + ArraysGilbert Guerrero
 
Processing ii
Processing iiProcessing ii
Processing iicitylore
 
Exploring Canvas
Exploring CanvasExploring Canvas
Exploring CanvasKevin Hoyt
 
Creative Coding 1 - 2 Variables
Creative Coding 1 - 2 VariablesCreative Coding 1 - 2 Variables
Creative Coding 1 - 2 VariablesTill Nagel
 
Creating an Uber Clone - Part VIII - Transcript.pdf
Creating an Uber Clone - Part VIII - Transcript.pdfCreating an Uber Clone - Part VIII - Transcript.pdf
Creating an Uber Clone - Part VIII - Transcript.pdfShaiAlmog1
 
かとうの Kotlin 講座 こってり版
かとうの Kotlin 講座 こってり版かとうの Kotlin 講座 こってり版
かとうの Kotlin 講座 こってり版Yutaka Kato
 
c++ code#include iostream#include string#include stdlib.h.pdf
c++ code#include iostream#include string#include stdlib.h.pdfc++ code#include iostream#include string#include stdlib.h.pdf
c++ code#include iostream#include string#include stdlib.h.pdfapexjaipur
 

Similar to Processing Interactive Circles and Ellipses (13)

Proga 0608
Proga 0608Proga 0608
Proga 0608
 
ARTDM 170, Week10: Arrays + Using Randomization
ARTDM 170, Week10: Arrays + Using RandomizationARTDM 170, Week10: Arrays + Using Randomization
ARTDM 170, Week10: Arrays + Using Randomization
 
Artdm170 Week10 Arrays Math
Artdm170 Week10 Arrays MathArtdm170 Week10 Arrays Math
Artdm170 Week10 Arrays Math
 
ARTDM 170, Week 13: Text Elements + Arrays
ARTDM 170, Week 13: Text Elements + ArraysARTDM 170, Week 13: Text Elements + Arrays
ARTDM 170, Week 13: Text Elements + Arrays
 
Processing ii
Processing iiProcessing ii
Processing ii
 
Proga 0622
Proga 0622Proga 0622
Proga 0622
 
Exploring Canvas
Exploring CanvasExploring Canvas
Exploring Canvas
 
Creative Coding 1 - 2 Variables
Creative Coding 1 - 2 VariablesCreative Coding 1 - 2 Variables
Creative Coding 1 - 2 Variables
 
Creating an Uber Clone - Part VIII - Transcript.pdf
Creating an Uber Clone - Part VIII - Transcript.pdfCreating an Uber Clone - Part VIII - Transcript.pdf
Creating an Uber Clone - Part VIII - Transcript.pdf
 
Sbaw090623
Sbaw090623Sbaw090623
Sbaw090623
 
Of class2
Of class2Of class2
Of class2
 
かとうの Kotlin 講座 こってり版
かとうの Kotlin 講座 こってり版かとうの Kotlin 講座 こってり版
かとうの Kotlin 講座 こってり版
 
c++ code#include iostream#include string#include stdlib.h.pdf
c++ code#include iostream#include string#include stdlib.h.pdfc++ code#include iostream#include string#include stdlib.h.pdf
c++ code#include iostream#include string#include stdlib.h.pdf
 

More from Atsushi Tadokoro

「クリエイティブ・ミュージック・コーディング」- オーディオ・ビジュアル作品のための、オープンソースなソフトウエア・フレームワークの現状と展望
「クリエイティブ・ミュージック・コーディング」- オーディオ・ビジュアル作品のための、オープンソースなソフトウエア・フレームワークの現状と展望「クリエイティブ・ミュージック・コーディング」- オーディオ・ビジュアル作品のための、オープンソースなソフトウエア・フレームワークの現状と展望
「クリエイティブ・ミュージック・コーディング」- オーディオ・ビジュアル作品のための、オープンソースなソフトウエア・フレームワークの現状と展望Atsushi Tadokoro
 
プログラム初級講座 - メディア芸術をはじめよう
プログラム初級講座 - メディア芸術をはじめようプログラム初級講座 - メディア芸術をはじめよう
プログラム初級講座 - メディア芸術をはじめようAtsushi Tadokoro
 
Interactive Music II ProcessingとSuperColliderの連携 -2
Interactive Music II ProcessingとSuperColliderの連携 -2Interactive Music II ProcessingとSuperColliderの連携 -2
Interactive Music II ProcessingとSuperColliderの連携 -2Atsushi Tadokoro
 
coma Creators session vol.2
coma Creators session vol.2coma Creators session vol.2
coma Creators session vol.2Atsushi Tadokoro
 
Interactive Music II ProcessingとSuperColliderの連携1
Interactive Music II ProcessingとSuperColliderの連携1Interactive Music II ProcessingとSuperColliderの連携1
Interactive Music II ProcessingとSuperColliderの連携1Atsushi Tadokoro
 
Interactive Music II Processingによるアニメーション
Interactive Music II ProcessingによるアニメーションInteractive Music II Processingによるアニメーション
Interactive Music II ProcessingによるアニメーションAtsushi Tadokoro
 
Interactive Music II Processing基本
Interactive Music II Processing基本Interactive Music II Processing基本
Interactive Music II Processing基本Atsushi Tadokoro
 
Interactive Music II SuperCollider応用 2 - SuperColliderとPure Dataの連携
Interactive Music II SuperCollider応用 2 - SuperColliderとPure Dataの連携Interactive Music II SuperCollider応用 2 - SuperColliderとPure Dataの連携
Interactive Music II SuperCollider応用 2 - SuperColliderとPure Dataの連携Atsushi Tadokoro
 
Media Art II openFrameworks アプリ間の通信とタンジブルなインターフェイス
Media Art II openFrameworks  アプリ間の通信とタンジブルなインターフェイス Media Art II openFrameworks  アプリ間の通信とタンジブルなインターフェイス
Media Art II openFrameworks アプリ間の通信とタンジブルなインターフェイス Atsushi Tadokoro
 
Interactive Music II SuperCollider応用 - SuperColliderと OSC (Open Sound Control)
Interactive Music II SuperCollider応用 - SuperColliderと OSC (Open Sound Control)Interactive Music II SuperCollider応用 - SuperColliderと OSC (Open Sound Control)
Interactive Music II SuperCollider応用 - SuperColliderと OSC (Open Sound Control)Atsushi Tadokoro
 
iTamabi 13 ARTSAT API 実践 5 - 衛星の軌道を描く
iTamabi 13 ARTSAT API 実践 5 - 衛星の軌道を描くiTamabi 13 ARTSAT API 実践 5 - 衛星の軌道を描く
iTamabi 13 ARTSAT API 実践 5 - 衛星の軌道を描くAtsushi Tadokoro
 
メディア芸術基礎 II 第11回:HTML5実践 表現のための様々なJavaScriptライブラリ
メディア芸術基礎 II 第11回:HTML5実践 表現のための様々なJavaScriptライブラリメディア芸術基礎 II 第11回:HTML5実践 表現のための様々なJavaScriptライブラリ
メディア芸術基礎 II 第11回:HTML5実践 表現のための様々なJavaScriptライブラリAtsushi Tadokoro
 
芸術情報演習デザイン(Web) 第8回: CSSフレームワークを使う
芸術情報演習デザイン(Web)  第8回: CSSフレームワークを使う芸術情報演習デザイン(Web)  第8回: CSSフレームワークを使う
芸術情報演習デザイン(Web) 第8回: CSSフレームワークを使うAtsushi Tadokoro
 
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 2
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 2Interactive Music II SuperCollider応用 JITLib - ライブコーディング 2
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 2Atsushi Tadokoro
 
iTamabi 13 第9回:ARTSAT API 実践 3 ジオコーディングで衛星の位置を取得
iTamabi 13 第9回:ARTSAT API 実践 3 ジオコーディングで衛星の位置を取得iTamabi 13 第9回:ARTSAT API 実践 3 ジオコーディングで衛星の位置を取得
iTamabi 13 第9回:ARTSAT API 実践 3 ジオコーディングで衛星の位置を取得Atsushi Tadokoro
 
Webデザイン 第10回:HTML5実践 Three.jsで3Dプログラミング
Webデザイン 第10回:HTML5実践 Three.jsで3DプログラミングWebデザイン 第10回:HTML5実践 Three.jsで3Dプログラミング
Webデザイン 第10回:HTML5実践 Three.jsで3DプログラミングAtsushi Tadokoro
 
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 1
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 1Interactive Music II SuperCollider応用 JITLib - ライブコーディング 1
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 1Atsushi Tadokoro
 
iTamabi 13 第8回:ARTSAT API 実践 2 衛星アプリを企画する
iTamabi 13 第8回:ARTSAT API 実践 2 衛星アプリを企画するiTamabi 13 第8回:ARTSAT API 実践 2 衛星アプリを企画する
iTamabi 13 第8回:ARTSAT API 実践 2 衛星アプリを企画するAtsushi Tadokoro
 
Media Art II openFrameworks 複数のシーンの管理・切替え
Media Art II openFrameworks 複数のシーンの管理・切替えMedia Art II openFrameworks 複数のシーンの管理・切替え
Media Art II openFrameworks 複数のシーンの管理・切替えAtsushi Tadokoro
 

More from Atsushi Tadokoro (20)

「クリエイティブ・ミュージック・コーディング」- オーディオ・ビジュアル作品のための、オープンソースなソフトウエア・フレームワークの現状と展望
「クリエイティブ・ミュージック・コーディング」- オーディオ・ビジュアル作品のための、オープンソースなソフトウエア・フレームワークの現状と展望「クリエイティブ・ミュージック・コーディング」- オーディオ・ビジュアル作品のための、オープンソースなソフトウエア・フレームワークの現状と展望
「クリエイティブ・ミュージック・コーディング」- オーディオ・ビジュアル作品のための、オープンソースなソフトウエア・フレームワークの現状と展望
 
プログラム初級講座 - メディア芸術をはじめよう
プログラム初級講座 - メディア芸術をはじめようプログラム初級講座 - メディア芸術をはじめよう
プログラム初級講座 - メディア芸術をはじめよう
 
Interactive Music II ProcessingとSuperColliderの連携 -2
Interactive Music II ProcessingとSuperColliderの連携 -2Interactive Music II ProcessingとSuperColliderの連携 -2
Interactive Music II ProcessingとSuperColliderの連携 -2
 
coma Creators session vol.2
coma Creators session vol.2coma Creators session vol.2
coma Creators session vol.2
 
Interactive Music II ProcessingとSuperColliderの連携1
Interactive Music II ProcessingとSuperColliderの連携1Interactive Music II ProcessingとSuperColliderの連携1
Interactive Music II ProcessingとSuperColliderの連携1
 
Interactive Music II Processingによるアニメーション
Interactive Music II ProcessingによるアニメーションInteractive Music II Processingによるアニメーション
Interactive Music II Processingによるアニメーション
 
Interactive Music II Processing基本
Interactive Music II Processing基本Interactive Music II Processing基本
Interactive Music II Processing基本
 
Interactive Music II SuperCollider応用 2 - SuperColliderとPure Dataの連携
Interactive Music II SuperCollider応用 2 - SuperColliderとPure Dataの連携Interactive Music II SuperCollider応用 2 - SuperColliderとPure Dataの連携
Interactive Music II SuperCollider応用 2 - SuperColliderとPure Dataの連携
 
Media Art II openFrameworks アプリ間の通信とタンジブルなインターフェイス
Media Art II openFrameworks  アプリ間の通信とタンジブルなインターフェイス Media Art II openFrameworks  アプリ間の通信とタンジブルなインターフェイス
Media Art II openFrameworks アプリ間の通信とタンジブルなインターフェイス
 
Interactive Music II SuperCollider応用 - SuperColliderと OSC (Open Sound Control)
Interactive Music II SuperCollider応用 - SuperColliderと OSC (Open Sound Control)Interactive Music II SuperCollider応用 - SuperColliderと OSC (Open Sound Control)
Interactive Music II SuperCollider応用 - SuperColliderと OSC (Open Sound Control)
 
iTamabi 13 ARTSAT API 実践 5 - 衛星の軌道を描く
iTamabi 13 ARTSAT API 実践 5 - 衛星の軌道を描くiTamabi 13 ARTSAT API 実践 5 - 衛星の軌道を描く
iTamabi 13 ARTSAT API 実践 5 - 衛星の軌道を描く
 
メディア芸術基礎 II 第11回:HTML5実践 表現のための様々なJavaScriptライブラリ
メディア芸術基礎 II 第11回:HTML5実践 表現のための様々なJavaScriptライブラリメディア芸術基礎 II 第11回:HTML5実践 表現のための様々なJavaScriptライブラリ
メディア芸術基礎 II 第11回:HTML5実践 表現のための様々なJavaScriptライブラリ
 
芸術情報演習デザイン(Web) 第8回: CSSフレームワークを使う
芸術情報演習デザイン(Web)  第8回: CSSフレームワークを使う芸術情報演習デザイン(Web)  第8回: CSSフレームワークを使う
芸術情報演習デザイン(Web) 第8回: CSSフレームワークを使う
 
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 2
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 2Interactive Music II SuperCollider応用 JITLib - ライブコーディング 2
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 2
 
iTamabi 13 第9回:ARTSAT API 実践 3 ジオコーディングで衛星の位置を取得
iTamabi 13 第9回:ARTSAT API 実践 3 ジオコーディングで衛星の位置を取得iTamabi 13 第9回:ARTSAT API 実践 3 ジオコーディングで衛星の位置を取得
iTamabi 13 第9回:ARTSAT API 実践 3 ジオコーディングで衛星の位置を取得
 
Tamabi media131118
Tamabi media131118Tamabi media131118
Tamabi media131118
 
Webデザイン 第10回:HTML5実践 Three.jsで3Dプログラミング
Webデザイン 第10回:HTML5実践 Three.jsで3DプログラミングWebデザイン 第10回:HTML5実践 Three.jsで3Dプログラミング
Webデザイン 第10回:HTML5実践 Three.jsで3Dプログラミング
 
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 1
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 1Interactive Music II SuperCollider応用 JITLib - ライブコーディング 1
Interactive Music II SuperCollider応用 JITLib - ライブコーディング 1
 
iTamabi 13 第8回:ARTSAT API 実践 2 衛星アプリを企画する
iTamabi 13 第8回:ARTSAT API 実践 2 衛星アプリを企画するiTamabi 13 第8回:ARTSAT API 実践 2 衛星アプリを企画する
iTamabi 13 第8回:ARTSAT API 実践 2 衛星アプリを企画する
 
Media Art II openFrameworks 複数のシーンの管理・切替え
Media Art II openFrameworks 複数のシーンの管理・切替えMedia Art II openFrameworks 複数のシーンの管理・切替え
Media Art II openFrameworks 複数のシーンの管理・切替え
 

Processing Interactive Circles and Ellipses

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11. // boolean pressed = false; int count; void setup() { size(400,400); noStroke(); colorMode(HSB,360,100,100,100); background(0); } void draw() { if(pressed){ fill(0,0,0,0.4); rect(0,0,width,height); fill(count%360,80,80,20); ellipse(mouseX, mouseY, 40, 40); ellipse(width-mouseX, mouseY, 40, 40); ellipse(mouseX, height-mouseY, 40, 40); ellipse(width-mouseX, height-mouseY, 40, 40); } count = count + 1; }
  • 12. void mousePressed() { pressed = true; } void mouseReleased() { pressed = false; }
  • 13.
  • 14. // void setup() { size(400, 400); noStroke(); smooth(); } void draw() { background(0,0,0); fill(31,127,255,200); ellipse(mouseX, height/2, mouseY/3, mouseY/3); ellipse(width-mouseX,height/2,((height-mouseY)/3),((height-mouseY)/3)); }
  • 15.
  • 16. // boolean pressed = false; int count; void setup() { size(400, 400); noStroke(); colorMode(HSB,360,100,100,100); background(0); rectMode(CENTER); } void draw() { if(pressed){ fill(count%360,100,100,5); rect(mouseX, height/2, random(10,20), height); } count = count+1; }
  • 17. void mousePressed(){ pressed = true; } void mouseReleased(){ pressed = false; }
  • 18.
  • 19. // float x, y; float targetX, targetY; float easing = 0.05; boolean pressed = false; void setup() { size(400, 400); smooth(); noStroke(); background(0,0,0); } void draw() { fill(0,0,0,10); rect(0,0,width,height); if(pressed){ targetX = mouseX; targetY = mouseY; }
  • 20. float dx = targetX - x; x += dx * easing; float dy = targetY - y; y += dy * easing; fill(31,127,255); ellipse(x, y, 33, 33); } void mousePressed() { pressed = true; } void mouseReleased() { pressed = false; }
  • 21.
  • 22. // int NUM = 400; float[] x = new float[NUM]; float[] y = new float[NUM]; float[] targetX = new float[NUM]; float[] targetY = new float[NUM]; float easing = 0.05; boolean pressed = false; void setup() { size(400, 400); smooth(); noStroke(); background(0,0,0); for(int i=0; i<NUM; i++){ x[i] = targetX[i] = random(width); y[i] = targetY[i] = random(height); } } void draw() { fill(0,0,0,10);
  • 23. for(int i=0; i<NUM; i++){ if(pressed){ targetX[i] = mouseX; targetY[i] = mouseY; } float dx = targetX[i] - x[i]; x[i] += dx * easing; float dy = targetY[i] - y[i]; y[i] += dy * easing; fill(31,127,255,40); ellipse(x[i], y[i], 20, 20); } } void mousePressed() { pressed = true; } void mouseReleased() { pressed = false; for(int i=0; i<NUM; i++){
  • 24. void mouseReleased() { pressed = false; for(int i=0; i<NUM; i++){ targetX[i] = random(width); targetY[i] = random(height); } }