Restoring colour without losing position

A Processing Java-mode sketch should draw an orange equipment block with its upper-left corner at (180,80) px(180,80)\ \text{px} and a blue circular indicator centred at (60,50) px(60,50)\ \text{px}. It uses this code:


Java
void setup() {
  size(420, 240);
  colorMode(RGB, 255);
  noStroke();
  rectMode(CORNER);
  ellipseMode(CENTER);

  fill(30, 90, 180);       // blue
  pushMatrix();
  translate(180, 80);
  fill(230, 120, 20);      // orange
  rect(0, 0, 60, 30);
  popMatrix();

  ellipse(60, 50, 20, 20);
}


The indicator appears orange. Which single edit produces both intended colours and both intended positions? A matrix pair means pushMatrix() with its matching popMatrix(); a style pair means pushStyle() with its matching popStyle().

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Processing Language Programming Questions: