Processing rectMode()

I think there is a bug with rectMode() in processing 3.4

rectMode() is affecting the way text gets drawn on the screen.

background(0);

text("Text 1", 0, 0, 100, 100);
rectMode(CENTER);
text("Text 2", 0, 30, 100, 100);
rectMode(CORNER);
text("Text 3", 0, 60, 100, 100);

Sin%20t%C3%ADtulo

In this example all 3 texts should get drawn inside the screen, but when changing the rectMode(), the text gets drawn outside of the screen.
If you comment out or delete the rectMode() lines, all 3 texts gets drawn inside the screen as they should.

pls see text

The x2 and y2 parameters define a rectangular area to display within and may only be used with string data. When these parameters are specified, they are interpreted based on the current rectMode() setting. Text that does not fit completely within the rectangle specified will not be drawn to the screen.

and try:

background(0);

text("Text 1", 0, 0, 100, 100);
rectMode(CENTER);
text("Text 2", 0, 30);
//text("Text 2", 0, 30, 100, 100);
rectMode(CORNER);
text("Text 3", 0, 60, 100, 100);

and

//text("Text 2", 0, 30);
//text("Text 2", 0, 30, 100, 100);
text("Text 2", 50, 80, 100, 100);

3 Likes

Ok, I’ll better read the documentation next time

1 Like