The alignment is working, but some fonts won't say how many pixels they increase in size correctly, so the alignment is not adjusting properly. You can get the textAscent, apply a calc on it, then use this as the start position for your Y. Also note this behaviour changes if you use P2D, P3D or OPENGL.
textAscent(). http://processing.org/reference/textAscent_.html
Here is my suggestion to start fixing this:
textAscent(). http://processing.org/reference/textAscent_.html
Here is my suggestion to start fixing this:
- void draw(){
- calculateFFT();
- background(0);
- smooth(8);
- textFont(Header, Channel[4]);
- fill(255);
- textAlign(CENTER,CENTER);
- float yStartPos = calculateAscent(Channel[4]);
- text("H", (width/2), yStartPos);
- }
- float calculateAscent(float value) {
- float base = height / 2;
- float scalar = 0.1; // Different for each font, change this until you get the result you want
- float a = textAscent() * scalar; // Calc ascent
- stroke(100); // for the reference line
- line(0,base-a,width,base-a); // ref purposes
- return base-a;
- }