FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Syntax
(Moderators: fry, REAS)
   Drawing transparant (and large but smooth) text
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: Drawing transparant (and large but smooth) text  (Read 3962 times)
Aiko


Drawing transparant (and large but smooth) text
« on: Mar 29th, 2005, 2:05pm »

I want to draw a text that animates its fill from 0 (black) to transparancy. I have used a variable to set the value for its fill as in this example:  
 
  fill(SetFillValue);
  text(sTest, 200, 200);
 
Using the value of the variable it draws the value of the string in a loop, the value of SetFillValue changes from 0 (black) to 255 (white). With a white background that's okay. But I do not want a white background. In that case the string is drawn over the non-background in either black, white or a shade in between but always being visible.
 
How can I set the value of the fill of the text ranging from black to transparancy?
« Last Edit: Mar 31st, 2005, 2:31pm by Aiko »  
st33d

WWW Email
Re: Drawing text with transparancy / alpha
« Reply #1 on: Mar 29th, 2005, 8:03pm »

Have you tried setting a fourth value for the color?
Code:

BFont GillSans;
GillSans = loadFont("GillSans.vlw.gz");
size(200,100);
background(255);
noStroke();
fill(30,0,60,100);
rect(40,10,90,90);
textFont(GillSans, 40);
fill(25,25,20,100);
text("Transparency",15,60);
fill(255,25,20,100);
text("Transparency",10,55);
 

I could murder a pint.
Aiko


Re: Drawing text with transparancy / alpha
« Reply #2 on: Mar 30th, 2005, 1:32pm »

Hey, that's great! It worked and was just what I needed!
Thank you very much.
 
Aiko


Re: Drawing transparant (and large but smooth) tex
« Reply #3 on: Mar 31st, 2005, 2:36pm »

Yet another text related question with a probable simple answer (if available): for my project I am needing 'a very large' font size of my text, getting its imput from a string variable. Say, a textsize of over about 200 pixels at least.  
 
I have used different fonts, but all seem to enlarge the anti-aliasing in the same proportion too, making my text blurry when greatly increased in size. Using the smooth() option seeems not to apply to text (or I am doing something silly and wrong), searching the archive was not very helpfull in this case too.
 
Does anyone have an idea how to get crispy but large letters (without using images and such, offcourse)?
 
Ricard


Re: Drawing transparant (and large but smooth) tex
« Reply #4 on: Mar 31st, 2005, 4:04pm »

I'm having the same problem.
 
I have done some (very little) research in a way to get vector fonts working in Processing, but I didn't have any succes.
 
Does anyone have any ideas?
 
Aiko


Re: Drawing transparant (and large but smooth) tex
« Reply #5 on: Apr 5th, 2005, 12:42pm »

I have done a bit more research, but was not very succesfull. If anyone can help us out that would really be, euh, well, helpfull...
 
fry


WWW
Re: Drawing transparant (and large but smooth) tex
« Reply #6 on: Apr 5th, 2005, 4:24pm »

you need to use "create font" to create a font of the size you need (use rev 69 because its font stuff is improved), and then use textSpace(SCREEEN_SPACE).  
 
unfortunately processing is just not that great with huge text and isn't made for it. it's possible that you'll get an outofmemoryerror when creating a font that big, or that its file size will be too enormous to run over the web. hopefully we can figure something out for a vector font library too, but i think we'll have to wait and see if someone contributes one. with 70+ it may be easier to do a vector font library, so maybe that's a possibility too.
 
Ricard


Re: Drawing transparant (and large but smooth) tex
« Reply #7 on: Apr 5th, 2005, 6:32pm »

Hi fry,
 
It's good to know that in version 70+ it might be easier to do a vector font library.
 
I would like to try to contribute with this.  I've been learning a little bit about vector fonts, going through the Freetype sourcecode and the FTGL (Freetype binding library for OpenGL).  I have some knowledge of programming in Java and C++.
 
I also understand that the main goal behind Processing is to make technology (and in this case a media programming environement) accesible to the vast public.
 
But I don't see myself capable of starting a library from scratch and on my own, I would like to know if anybody else out there wants to participate and if anybody has some kind of template for P5 libraries.
 
Another thing I would need to know is how will I be able to use the openGL functions in 70+ to tesselate the vector structures I read.
 
thanks
ricard
 
fry


WWW
Re: Drawing transparant (and large but smooth) tex
« Reply #8 on: Apr 5th, 2005, 11:00pm »

generally speaking, it's a different problem in 2D versus 3D. freetype is a scanline renderer, meaning 2D, which just draws a bunch of shapes based on paths, and draws them according to a winding rule (i.e "even/odd"). the rendering works top to bottom, and for each row, as soon as a line/curve is hit, filling starts, when another is hit, filling stops.
 
gl, as you know, is more complicated, and has to get things broken into triangles, a very different problem. actually, i'm curious how ftgl does this myself. i think it's not at all impossible, but no doubt tricky.
 
there's also gltt. i don't quite understand the differences between the two projects, though.
 
as for api things, casey and i are cramming for beta right now, and part of that is documenting the api.. so i should have more info by the end of the month.
 
Ricard


Re: Drawing transparant (and large but smooth) tex
« Reply #9 on: Apr 6th, 2005, 1:02am »

you're right, that the 2D and 3D renderings of fonts are very different.  I think it would be nice to be able to do both with one only library.
 
I tried having a look at the FTGL source code which builds the polygon from the font outline (SEG_TO, MOVE_TO,...), but haven't understood it yet, I'm quite a beginer in OpenGL (but eager to learn!!).
Although from what I understand, it uses OpenGL's "gluTessBeginPolygon" method in order to create a non-convex polygon (it can have multiple contours, and therefore, holes).  So it's really OpenGL who handles the tricky part.
 
This is the documentation for the method that FTGL uses:
http://pyopengl.sourceforge.net/documentation/manual/gluTessBeginPolygon .3G.html
 
About the difference between FTGL and GLTT, is that GLTT uses FreeType libs and API (as in FreeType1), and FTGL uses the new FreeType2 libs and API.
They also have different authors:
http://gltt.sourceforge.net/20010819_000000.html
 
Thanks for the status about the new API.  I would really like to participate in this project, and I think the vector font library something I could help out with.
BTW, I'm right now doing a master in digital arts in Barcelona, and a possibility would be to focus my final project in new creative ways for vector font rendering.  I would very much like to use Processing and it could be a good excuse to work on the library.
 
cheers mate!
ricard
http://www.tecn.upf.es/master/mad04/~rmarxer/
 
Pages: 1 

« Previous topic | Next topic »