processing/p5.js

setAttributes() invalidates references to earlier canvases

Open

#5.902 geöffnet am 16. Dez. 2022

Auf GitHub ansehen
 (7 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)JavaScript (3.178 Forks)batch import
Area:WebGLBugHelp Wanted

Repository-Metriken

Stars
 (20.784 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 8T 13h) (45 gemergte PRs in 30 T)

Beschreibung

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

107.0.1

Operating System

macOS 12.5.1

Steps to reproduce this

Calling setAttributes in WebGL mode might end up recreating the underlying canvas and renderer object.

Say you're trying to position the element, e.g. like this:

let canvas = createCanvas(100, 100, sketch.WEBGL);
// ...
canvas.position(0,0);

Unfortunately, this stops working after a setAttributes call, because after that call, canvas !== _renderer. Currently, to fix it, one would have to do:

createCanvas(100, 100, sketch.WEBGL);
setAttributes({ alpha: true });
let canvas = _renderer;
// ...
canvas.position(0,0);

Contributor Guide