We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
Text Blur (Read 2429 times)
Text Blur
Feb 14th, 2007, 12:02am
 
Hi Guys
Just making a program and im taking in keyboard input.I have that working fine and stored in a variable.
I have a slider type thing set up and what i want to do is, as the amount on the slider increases the text becomes more blurred. Any ideas?
Does blur only work on Images?
Any help would be great
Thanks a million guys
(Sorry if this is in the wrong section)
Re: Text Blur
Reply #1 - Feb 14th, 2007, 2:25pm
 
you can draw the text and blur right over it.

pseudocode:
Code:

text(mytext,x,y);
blur();


If you just wanted the text itself be blurred and not waste cpu time blurring the entire screen then you might want to pre-render the text on an image buffer, blur that, then paste it.

pseudocode:
Code:

PGraphics p = new PgraphicsOPENGL(300,80);
p.text(mytext,x,y);
p.blur();

//copy the image buffer p to the applet, g
g.copy(p,0,0,p.width,p.height,0,0,p.width,p.height);


something like that. It's not exact, but I hope these ideas help you out.
Re: Text Blur
Reply #2 - Feb 14th, 2007, 4:39pm
 
PERFECT!!!
Thanks a million
Re: Text Blur
Reply #3 - Feb 14th, 2007, 7:52pm
 
I think this will be a bit faster if you use the accurate size of your text for the offscreenbuffer. The height of the text is your textSize() and the width can you get by calling textWidth("your Text"), So you can write:
Code:
 PGraphics p = new PgraphicsOPENGL(textWidth("your Text"),yourTextSize); 

Re: Text Blur
Reply #4 - Feb 14th, 2007, 9:48pm
 
I haven't tried it, but I imagine that a perfectly sized fit around the text area will be bad for blurring, because by blurring it the pixels go outwards and it will reveal your rectangle.

You can probably get around this by coding some kind of buffer area that's a multiple of what your absolute text space is, though.
Re: Text Blur
Reply #5 - Mar 6th, 2007, 1:13am
 
Guys i REALLY REALLY REALLY appreciated the help but im still working on this and im still stuck,it will run fine, loading the font and everything but if i use the line
//p = new PGraphicsOpenGL(80,80, g); it gives me an error
can anyone PLEASE PLEASE help.... ive tried taking out the g argument, ive tried everything and spent so long trying to get it to work.

heres what i have...(taking out the stuff that isnt relevant),

import processing.core.*;

import processing.opengl.*;

public class effects extends PApplet {
.
.

PFont font;

PApplet g;

PGraphics p;



public void setup()

{


p = new PGraphicsOpenGL(80,80, g);




font = loadFont("data/Tahoma-48.vlw");


size(800, 700,OPENGL);

}



public void draw()

{



background(80);


drawText();


drawToolbar();


drawSlider();


createBlur();

}

       ......
       ......
       ....
       ..


public void createBlur()

{






p.text(buff, 315, 170);


p.filter(BLUR, blurAmount);


g.copy(p, 0, 0, p.width, p.height, 0,0,p.width, p.height);

}

}



So thankfull for ur time
Re: Text Blur
Reply #6 - Mar 6th, 2007, 9:27am
 
Re: Text Blur
Reply #7 - Mar 6th, 2007, 10:09pm
 
Thanks for the reply fjen, v.much appreciated.
ive tried using the createGraphics() and its throwing an error in Eclipse telling me to import processing.core.Pgraphics3 to my sketch folder, but i already have
import processing.core.*; and the core.jar is already in the sketch folder????
Any ideas????
thanks a million for ur time
Re: Text Blur
Reply #8 - Mar 7th, 2007, 8:04am
 
sorry. i don't use eclipse. i have no clue what's wrong there ...
Re: Text Blur
Reply #9 - Mar 7th, 2007, 8:03pm
 
Cheers fjen, ive ditched the eclipse part and just using processing, ive the code running now with no errors, but nothing is happening for me..... =(
here's what i have.... is this right?
thanks so much for ur time
.
..
.
PGraphics p;
.
..
public void setup()
{
       p = createGraphics(800, 30, P3D);
               ...
               ...

       }
       public void draw()
      {
         createBlur();
      }



public void createBlur()
{
               p. beginDraw();
       p.textFont(font);
p.text(buff, 315, 170);
p.filter(BLUR, 7);
               p. endDraw();
              image(p, 10, 10);

}
Re: Text Blur
Reply #10 - Mar 9th, 2007, 5:31pm
 
you may be running into this problem:
http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Syntax;action=display;num=1171574044
Re: Text Blur
Reply #11 - Mar 10th, 2007, 11:41pm
 
Got it working!!!!
THANK YOU SO MUCH, was just missing:
p.modified = true;
Thanks a gazillion to everyone who helped!!
You've no idea how thankful i am!
Thanks guys
Re: Text Blur
Reply #12 - Jan 30th, 2008, 1:07pm
 
This is also very nice. You make a completly preblured fontset:

Quote:


import processing.opengl.*;

PFont sysfont;

void setup() {
 size(600, 400, OPENGL);
 sysfont = createFont("Courier",24);
 textFont(sysfont, 24);
 for(int i=0;i<sysfont.images.length; i++) sysfont.images[i].filter(BLUR,1);
}

void draw() {
 background(0);
   fill(255);
   text("Ich schreib mal was",30,30);
}



The problem is, that the blur is only whitin the Letterimagesboxes...
maybe someone can optimize this by copying pixels.

greetings ascorbin
Re: Text Blur
Reply #13 - Feb 8th, 2008, 6:00pm
 
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
Page Index Toggle Pages: 1