try this:
Quote:
import processing.opengl.*;
Textelement text1;
// ------------------------------------------------------------------
void setup() {
size(600, 400, OPENGL);
text1 = new Textelement("Ich schreib mal was");
}
// ------------------------------------------------------------------
void draw() {
background(0);
float val = mouseX*1.0/width*255;
text1.draw(100, 100, val);
}
the Textelement class:
Quote:
import javax.media.opengl.*;
class Textelement {
PGraphicsOpenGL pgl;
GL gl;
PGraphics pg;
PFont sysfont;
float x, y, a;
String textcontent;
Textelement(String t) {
textcontent = t;
sysfont = createFont("Courier",24);
build_blured_image();
}
void build_blured_image() {
pg = createGraphics(300, 60, JAVA2D);
pg.beginDraw();
pg.textFont(sysfont,24);
pg.fill(255);
pg.text(textcontent,10,30);
pg.filter(BLUR, 2);
pg.endDraw();
}
void draw(float x, float y, float a) {
pushMatrix();
scale( 1+a/5000, 1);
pgl = (PGraphicsOpenGL) g;
gl = pgl.gl;
pgl.beginGL();
gl.glEnable(GL.GL_BLEND);
gl.glBlendFunc(GL.GL_DST_ALPHA, GL.GL_ONE);
pgl.endGL();
if(a<255.0/2) tint(a*2,a*2,a*2,a*2);
else tint(500-a*2,500-a*2,500-a*2,500-a*2);
image(pg, x-10, y-30);
pgl.beginGL();
gl.glEnable(GL.GL_BLEND);
gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
pgl.endGL();
textFont(sysfont,24);
fill(255,255,255,255-a*2);
text(textcontent, x, y);
popMatrix();
}
}
greetings ascorbin