Video thumbnail

Swarm 3D GUI – with a tail

I wrote this short swarm script with GUI interface in Processing about 4 years ago (When I began to code)… Now I figure out lots of code from this script should be improved! For instance, we can implement KDTree later… Hope this code from the previous version will help people who needs or interested in it. Processing Source Code: drawLineFish3DUI.pde //============================================================================ // Name : drawLineFish3DUI.pde // Author : Gene Ting-Chun Kao // Version : 2012-7-19 // Copyright : GNU General Public License // Description : Swarm 3D with Tail GUI //============================================================================ import toxi.geom.*; import processing.opengl.*; import peasy.*; import controlP5.*; import java.util.Calendar; Manage man; PeasyCam jCam; ControlP5 jControl; ArrayList fishes; PMatrix3D currCameraMatrix; PGraphics3D g3; int c1 = 0; int c2 = 0; int c3 = 0; boolean attractor = false; boolean stop = false; void setup() { size(1200, 800, OPENGL); smooth(); g3 = (PGraphics3D)g; jCam = new PeasyCam(this, 100); Slider(); man = new Manage(400, 50); man.createFish(); } void draw() { if (jControl.window(this).isMouseOver()) { jCam.setActive(false); } else { jCam.setActive(true); } background(0); man.display(); gui(); } void keyReleased() { if (key == 's' || key == 'S') saveFrame(timestamp()+"_##.png"); } String timestamp() { Calendar now = Calendar.getInstance(); return String.format("%1$ty%1$tm%1$td_%1$tH%1$tM%1$tS", now); } void Slider() { jControl = new ControlP5(this); //mousePosistion jControl.addSlider("c1",-200,200,10,610,100,10); jControl.addSlider("c2",-200,200,10,630,100,10); jControl.addSlider("c3",-200,200,10,650,100,10); jControl.addToggle("attractor", false, 10, 680, 100, 10).setMode(ControlP5.SWITCH); jControl.addToggle("stop", false, 10, 715, 45, 10); jControl.setAutoDraw(false); } void gui() { currCameraMatrix = new PMatrix3D(g3.camera); camera(); jControl.draw(); g3.camera = currCameraMatrix; } Fish.pde ...

May 2, 2016 · 5 min · Gene Ting-Chun Kao
Processing 101

Processing 101

My Processing 101 creative coding experiments. 00 Kamehameha Simple 01 Attractor2DSimple 02 BouncingBallSimple 03 Wave 05 waterPipe 06 TwoPlayersGA Processing 101 – 00 Kamehameha Simple Kamehameha かめはめ波 龜派氣功 instruction Press you mouse left button. Drag it in the opposite direction. And you will find out it open fire automatically. Dictionary: Kamehameha かめはめ波 龜派氣功 Code Inspired From: Processing.js learning Sample float radius = 50; int X, Y; void setup() { size( 650, 200 ); strokeWeight(10); fill( 198, 81, 10); stroke(255); X = width/2; Y = height/2; } void draw() { background(100); radius += sin(frameCount/10); ellipse(X+=(X-pmouseX)/16, Y+=(Y-pmouseY)/16, radius, radius); } void mouseMoved() { X = mouseX; Y = mouseY; } Processing 101 – 01 Attractor2DSimple Attractor Each circle on the grid points change its diameters, which based on distance between mouse position and point’s location. Dictionary: Attractor 吸引子,原本為複雜科學裡的一個專有名詞,近期廣被用來描述於Parametricism。 最先被運用在Grasshopper裡頭。 ...

July 25, 2014 · 9 min · Gene Ting-Chun Kao
Clock Design

Clock Design

Clock Design using Processing ClockDesign_001_Basic ClockDesign_002_Mondaine ClockDesign_001_Basic Clock Design through code. Minimalism 時間設計 — 極簡風 float h, m, s; void setup() { size(650, 650); smooth(); } void draw() { background(200); pushMatrix(); translate(width/2, height/2); strokeWeight(1); stroke(100); noFill(); ellipse(0, 0, 400, 400); s = 6*second()*(TWO_PI)/360 - PI/2; m = 6*minute()*(TWO_PI)/360 - PI/2; h = 30*hour()*(TWO_PI)/360 - PI/2; fill(255); for (int i = 0; i <= 60; i++) { strokeWeight(1); line(cos(i*6*(TWO_PI)/360)*203, sin(i*6*(TWO_PI)/360)*203, cos(i*6*(TWO_PI)/360)*190, sin(i*6*(TWO_PI)/360)*190); ellipse(cos(i*6*(TWO_PI)/360)*200, sin(i*6*(TWO_PI)/360)*200, 5, 5); if (i % 5 == 0) { strokeWeight(2); line(cos(i*6*(TWO_PI)/360)*203, sin(i*6*(TWO_PI)/360)*203, cos(i*6*(TWO_PI)/360)*180, sin(i*6*(TWO_PI)/360)*180); ellipse(cos(i/5*30*(TWO_PI)/360)*200, sin(i/5*30*(TWO_PI)/360)*200, 10, 10); } } noStroke(); fill(255); ellipse(0, 0, 10, 10); //ellipse(cos(s)*200, sin(s)*200, 10, 10); //text(s + ", "+ second(), cos(s)*200, sin(s)*200); ellipse(cos(m)*200, sin(m)*200, 20, 20); //text(m + ", "+ minute(), cos(m)*200, sin(m)*200); ellipse(cos(h)*200, sin(h)*200, 20, 20); strokeWeight(5); stroke(100); line(cos(s)*180, sin(s)*180, cos(s)*10, sin(s)*10); strokeWeight(8); line(cos(m)*150, sin(m)*150, cos(m)*10, sin(m)*10); strokeWeight(10); line(cos(h)*100, sin(h)*100, cos(h)*10, sin(h)*10); popMatrix(); } ClockDesign_002_Mondaine Clock Design through code. Mondaine 時間設計 — 瑞士國鐵表 ...

December 12, 2013 · 2 min · Gene Ting-Chun Kao