//////////////////////////////////////////////////////////////////////////////// // // Project: ProcessingNoiseFields // File: NoiseField01.java // Created by: julapy, 2 Jun 2007 // //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// // Package //////////////////////////////////////////////////////////////////////////////// package com.julapy.processing.noise; //////////////////////////////////////////////////////////////////////////////// // Imports //////////////////////////////////////////////////////////////////////////////// import processing.core.*; import processing.opengl.*; import javax.media.opengl.*; //////////////////////////////////////////////////////////////////////////////// // // // Class: NoiseField01.java // // //////////////////////////////////////////////////////////////////////////////// public class NoiseField01 extends PApplet { boolean lines = false; float xCount, yCount; float xSpeed, ySpeed; Particle[] particles; int particleCount = 1000; float noiseCount = 0.0f; float noiseSpeed = 0.01f; float noiseScale = 0.005f; float speed = 10.0f; int noiseRes = 10; int decayRadius; //////////////////////////////////////////////////////////////////////////// // // Group: Event Handlers // //////////////////////////////////////////////////////////////////////////// public void keyPressed() { if (key == ' ') { if (lines) { lines = false; } else { lines = true; } } } //////////////////////////////////////////////////////////////////////////// // // Group: Public Methods // //////////////////////////////////////////////////////////////////////////// /** * initialises the processing applet. */ public void setup() { // processing 3D - not as fast. // size(800,600,P3D); // OpenGL - much better! size(800,600,OPENGL); smooth(); frameRate(30); // noiseDetail(8, 1.0f); // this creates absolute havoc on the screen, interesting effect. // noiseDetail(8, 0.80f); // swarm like. noiseDetail(4, 0.95f); // my favourite result so far. very erratic. // noiseDetail(4, 0.5f); // smooth motion although the particles tend to clump together. // noiseDetail(2, 3.0f); // less ocataves + more overload = great effect! decayRadius = width/2; particles = new Particle[particleCount]; for(int i=0; i=width/2) { cx = -cr*cos((float)decayAngle); cy = -cr*sin((float)decayAngle); } float nx = nr*cos(radians(g)); float ny = nr*sin(radians(g)); float vx = (cx + nx)*speed; float vy = (cy + ny)*speed; if(lines) { stroke(255,255,255); line (x, y, x+vx, y+vy); } } } } noiseCount += noiseSpeed; // update particles. for(int p=0; p=width/2) { cx = -cr*cos((float)decayAngle); cy = -cr*sin((float)decayAngle); } float nx = nr*cos(radians(angle)); float ny = nr*sin(radians(angle)); float vx = (cx + nx)*vel; float vy = (cy + ny)*vel; x += vx; y += vy; // draw particles. noStroke(); fill(255, 255-vel*10, 0); float d = max(vx*2, vy*2) + 2; ellipse(x,y,d,d); } } }