Processing für Geeks: Unterschied zwischen den Versionen

Zur Navigation springen Zur Suche springen
better plugin
(geshi!)
(better plugin)
 
=== Code des gezeigten Processing Audio Visualizers ===
Datei[[File: '''particle.pde''']]:
<geshisyntaxhighlight lang="python">
public class Particle {
float x, y, z;
float vx, vy, vz;
alive = true;
}
 
public Particle( float x, float y, float z, float vx, float vy, float vz, PImage tex ) {
this( x, y, z, vx, vy, vz, tex, color( 255, 255, 255 ));
return alive;
}
}
</syntaxhighlight >
</geshi>
 
Datei[[File: '''particledemo.pde''']]:
<geshisyntaxhighlight lang="python">
/**
a 3d particle audio vizualizer by Guru
<a href="http://www.local-guru.net/blog">Guru</a>
 
press any key to emit a new burst of particles
*/
 
import processing.opengl.*;
import javax.mediaprocessing.opengl.*;
import ddfjavax.minimmedia.opengl.*;
import ddf.minim.analysis.*;
import ddf.minim.analysis.*;
//Particle[] p;
ArrayList p = new ArrayList();
Particle[] burst;
PImage tex;
boolean present = false;
Minim minim;
AudioInput in;
FFT fft;
 
void setup() {
for ( int i = 0; i < args.length; i ++ ) {
if ("--present".equals(args[i])) {
in = minim.getLineIn( Minim.MONO, 512 );
fft = new FFT( in.bufferSize(), in.sampleRate());
}
 
float alph = 0;
 
void draw() {
background(0);
 
alph += 0.01f;
PGraphicsOpenGL pgl = (PGraphicsOpenGL) g;
gl.glEnable(GL.GL_BLEND);
gl.glBlendFunc(GL.GL_SRC_ALPHA,GL.GL_ONE);
pushMatrix();
translate( width, 0, -300 );
scale( min( width, height) /150 );
 
rotateY( alph );
 
fft.forward( in.mix );
p.remove( i.next());
}
 
for( int i = 0; i < burst.length; i ++ ) {
if ( burst[i] != null && burst[i].isAlive()) {
pgl.endGL();
popMatrix();
}
 
 
PGraphics makeTexture( int r ) {
PGraphics res = createGraphics( r * 6, r * 6, P2D);
res.beginDraw();
return res;
}
</syntaxhighlight >
</geshi>
 
[[Category:Workshops]]

Navigationsmenü