Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

167
Views
How does background function work in Processing?

Yo, I hope all is fine for you! As indicated in the title, I would like to know how background function works in Processing. What is the difference between the first program (background called before drawing the circle) and the second program (background called after drawing the circle) which is the one "doesn't working"?

int x = 1;
void setup() {
  size(400, 400);
  background(255);
}

void draw() {
  background(255);
  circle(200 + x, 200, 20);
  x++;
}
int x = 1;
void setup() {
  size(400, 400);
  background(255);
}

void draw() {
  circle(200 + x, 200, 20);
  background(255);
  x++;
}
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

background not only defines the background color, but also fills the window with the background color. Therefore you have to call background before drawing the objects of the scene:

void draw() {
  background(255);
  circle(200 + x, 200, 20);
  x++;
}

background clears the window and thereby all previously drawn objects. background does not change a state. When you call background, every pixel in the window is instantly changed. (Since processing uses OpenGL, glClear is invoked under the hood.)

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!