hyejinim / draw2code

https://hyejinim.github.io/draw2code
0 stars 1 forks source link

Fix the laggy animation when the system runs code #8

Closed hyejinim closed 3 years ago

hyejinim commented 3 years ago

Revert the framerate and find another way to show animations (do not change every frame)

hyejinim commented 3 years ago

Try p5js play library https://creative-coding.decontextualize.com/making-games-with-p5-play/

hyejinim commented 3 years ago
  1. Add interpolation --> Not sure
  2. Create two canvas so apply different frameRates for webcam and animation --> Not recommended
  3. Apply different frameRates for webcam --> Not possible
  4. Apply different frameRates for animation --> Can use animation.frameDelay from p5.play https://stackoverflow.com/questions/59823610/animated-png-frame-rate-in-p5js
  5. Use frameCount
hyejinim commented 3 years ago

two options: InvokeRepeating() or Coroutines with yield WaitForSeconds.

hyejinim commented 3 years ago

https://stackoverflow.com/questions/36505178/processing-how-can-i-draw-only-every-x-frames

hyejinim commented 3 years ago

if (frameCount % 20 == 0) { // update every 20 frames spr.position.x = frames[frameNum].x; spr.position.y = frames[frameNum].y; spr.scale = frames[frameNum].scale; frameNum++; }