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

160
Views
How to leave trail in my sketch without deleting the background in p5js?

I would like to leave line trails at each of the corners of the rectangles. I have tried createGraphics to add an extra canvas where I want to leave the trails but it's just doesn't work.

I purposefully rotate the rectangle with cosine. My assignment forbids to use the rotate function.

I followed this tutorial: https://www.youtube.com/watch?v=TaluaAD9MKA

The Sketch:

Without createGraphics: https://editor.p5js.org/plaszlo/sketches/W6Bq6zAI3

With createGraphics: https://editor.p5js.org/plaszlo/sketches/WQhPN5e7F

Thank you

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I found some problems with your code. You can check here the solutions I found.

The fixes I needed to do where:

  1. To create a Graphic you should use createGraphics (you were using createCanvas instead).
  2. As you are translating the shape you draw on the canvas, you should also translate the trails themselves in the trails layer graphic.
  3. As you draw the trails, you should also use push() and pop() to save the settings of the graphic at each frame, so the translation doesn't accumulate from one frame to the others.
about 4 years ago · Juan Pablo Isaza 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!