Subscribed unsubscribe Subscribe Subscribe

Ex_01_04_PVector_mult

vectorA.mult(value) void setup(){ size(600,600); } void draw(){ background(255); PVector mouse = new PVector(mouseX,mouseY); PVector center = new PVector(width/2,height/2); mouse.sub(center); mouse.mult(0.5); translate(width/2,height/2); s…

Ex_01_03_PVector_sub

vectorA.sub(vectorB) void setup(){ size(600,600); } void draw(){ background(255); PVector mouse = new PVector(mouseX,mouseY); PVector center = new PVector(width/2,height/2); mouse.sub(center); translate(width/2,height/2); line(0,0,mouse.x,…

Ex_01_02_Ball

Ball PVector PVector location; PVector velocity; void setup(){ size(600,600); background(255); location = new PVector(100,100); velocity = new PVector(2.1,3.9); } void draw(){ location.add(velocity); if ((location.x < 0)||(width < location…

Ex_01_01_Ball

not use PVector float x = 100; float y = 100; float xSpeed = 2.1; float ySpeed = 3.9; void setup(){ size(600,600); background(255); } void draw(){ x = x + xSpeed; y = y + ySpeed; if ((x<0)||(width

Ex_00_06_PerlinNoise_2D

perlin noise 2D // perlin noise size(600,600); loadPixels(); float xoff = 0.0; for (int x=0; x

Ex_00_05_RandomWalker_PerlinNoise

random walker perlin noiseperlin noise is noise() class Walker{ float x,y; float tx,ty; Walker(){ tx = 0; ty = 10000; } void step(){ x = map(noise(tx), 0,1, 0,width); y = map(noise(ty), 0,1, 0,height); tx += 0.01; ty += 0.01; noStroke(); f…

Ex_00_04_Gaussian

gaussian distribution import java.util.Random; Random generator; void setup(){ size(649,360); background(255); generator = new Random(); } void draw(){ float num = (float) generator.nextGaussian(); // next Gaussian return ""double"" float …

Ex_00_03_RandomWalker_Lopsidedly

random walker lopsided class Walker { int x; int y; int w = 1; Walker(){ x = width/4; y = height/2; } void display() { stroke(0); point(x, y); } void step() { float choice = random(1); // 0.0 to 3.9 // int() if (choice < 0.4) { x = x+w; } …

Ex_00_02_Random_XXX

XXX int[] randomCounts; void setup(){ size(640,240); randomCounts = new int[20]; } void draw(){ background(255); int index = int(random(randomCounts.length)); randomCounts[index] = randomCounts[index]+5; stroke(0); fill(175); int w = width…

Ex_00_01_RandomWalker_OOP_Basic

random walker OOP basic class Walker { int x; int y; int w = 1; Walker(){ x = width/2; y = height/2; } void display() { stroke(0); point(x, y); } void step() { int choice = int(random(4)); // 0.0 to 3.9 // int() if (choice == 0) { x = x+w;…