Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

saveGif() sometimes leaves trails of antialiasing artifacts #5882

Closed
1 of 17 tasks
davepagurek opened this issue Dec 3, 2022 · 1 comment · Fixed by #5883
Closed
1 of 17 tasks

saveGif() sometimes leaves trails of antialiasing artifacts #5882

davepagurek opened this issue Dec 3, 2022 · 1 comment · Fixed by #5883
Assignees

Comments

@davepagurek
Copy link
Contributor

Most appropriate sub-area of p5.js?

  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • Build Process
  • Unit Testing
  • Internalization
  • Friendly Errors
  • Other (specify if possible)

p5.js version

1.5.0

Web browser and version

Firefox 107.0

Operating System

macOS 12.5.1

Steps to reproduce this

It seems like occasionally, when colors are similar, the gif encoder doesn't always write over pixels of the previous frame, leaving trails. This seems most noticeable when drawing similar colors on top of each other (e.g. in the example below, I don't see any artifacts if I make the moving circles black.)

function setup() {
  createCanvas(400, 400);
}

function draw() {
  const gradient = drawingContext.createLinearGradient(0, 0, 0, height)
  gradient.addColorStop(0, '#42f5e6')
  gradient.addColorStop(1, '#d62bb4')
  noStroke()
  push()
  drawingContext.fillStyle = gradient
  rect(0, 0, width, height)
  pop()
  
  for (let i = 0; i < 20; i++) {
    push()
    fill('#a836a8')
    circle(
      (noise(i * 100, 0) * 2 * width + (frameCount / 60) * width) % width,
      noise(i * 100, 1000) * height,
      20
    )
    pop()
  }
}

function mousePressed() {
  saveGif('test', 2)
}

Live: https://editor.p5js.org/davepagurek/sketches/aQPkuFJEM

Exported gif:

test(5)

@davepagurek davepagurek added the Bug label Dec 3, 2022
@davepagurek davepagurek self-assigned this Dec 3, 2022
@davepagurek
Copy link
Contributor Author

It looks like this is something with the applyPalette function in the gif encoding library we use. I made an issue for that upstream (mattdesl/gifenc#13) and wrote a workaround in p5 that doesn't rely on that function. I'll add it to a PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant