rectMode CENTER/RADIUS causing text to disappear

Hello,

I am trying to learn Processing for Android and it seems like I’m stuck on quite simple task - rendering text and square at the same time. If I don’t use rectMode(CENTER) everything seems to be working normally, but after trying to center it - the text disappears. The code:

void setup() {
  fullScreen();
  noStroke();
  fill(0);
  textFont(createFont("SansSerif", 30 * displayDensity));
}

void draw() {
  background(0);
  textAlign(CENTER);
  fill(255);
  text("Hello world", 0, displayDensity * 50, width, height);
  fill(150);
  rectMode(CENTER);
  square(width/2, height/2, displayDensity * 100);
}

I find it quite weird, because if I use rectMode CORNER or CORNERS text is still visible, and the issue is only with CENTER and RADIUS modes.

//edit: I found what’s causing the issue - I was trying to make text “box” (last two parameters) size of the screen, which was then overridden by using rectMode and square. After deleting these two parameters it works perfectly fine. Not deleting the topic, as it could be useful.

2 Likes

Hello @Zibee,

I observed the same with Processing 4.0.1

A workaround:

  //rectMode(CENTER);
  //square(width/2, height/2, 1 * 100);
  rect(width/2-100/2, height/2-100/2, 1*100, 1*100);

:)