Here's the code I had to use to get text placed in a 30 x 22 rectangle. From the documentation I expected th using the diagonal coordinates of the rectangle to properly place the text, but it was WAY off. I had to multiply the coordinates by 2 and then fudge it a bit to get things to line up. There are over 50 of these controls all over the screen. Thankfully it worked for all of them. I'm using v4.2. Is this a problem with this beta version? If so I'll replace it with v3.
{ fill(green); rect (lever[i][xPos], lever[i][yPos], 30, 22); fill(black); } text(leverID[i],lever[i][xPos]*2+8, lever[i][yPos]*2-18,lever[i][xPos]*2+30, lever[i][yPos]*2-22);
Here's the code I had to use to get text placed in a 30 x 22 rectangle.
[snipt]
I'm using v4.2.
Version 4.2 of what ?
Experience is what you get when you don't get what you want.
I should have mentioned that... Processing 4.0b2
I am using the same version, Processing 4.0b2
It might help if you provide a runnable code example that displays your issues.
PFont f; // Declare PFont variable void setup() { size(200,200); f = createFont("Arial",16,true); // Create Font } void draw() { background(255); fill(255); rect(8,80,100,32); // draw rectangle textFont(f,16); // Specify font to be used fill(0); // Specify font color text("Hello Strings!",10,100); // Display Text }
Checking the documentation for some predesigned solution.
size(640, 480); background(255); loadPixels(); for (int j = 0;j<480;j=j+8){ for (int i= 0;i<640;i=i+8){ pixels[i+j*640] = color(0,0,0); } } updatePixels(); //update the content of the display window int x=100; int y=50; int w=200; int h=32; int txtSize = 16; rect(x,y,w,h); fill(0); textSize(txtSize); textAlign(CENTER, CENTER); text("hello world",x+w/2,y+h/2);
Your responses showed some functions I've never seen before and sent me looking around. I have things sorted out now so no need to show those 1100 lines of code to illustrate a simple problem.
Thanks