processing / processing/p5.js

[p5.js 2.0+ Bug Report]:save() not working on graphics

Open
#8,881 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area:Core Area:Image p5.js 2.0+
Dominant language
JavaScript
Stars
24k
Forks
3.8k
Avg merge
3d 16h
Merged PRs (30d)
25

Description

Most appropriate sub-area of p5.js?
  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • WebGPU
  • p5.strands
  • Build process
  • Unit testing
  • Internationalization
  • Friendly errors
  • Other (specify if possible)
p5.js version

2.0 and above

Web browser and version

all

Operating system

win

Steps to reproduce this

Save isn't working on graphic, in this example on event mouseRelease (or any other), throws error "TypeError: pg.save is not a function".

let pg;

function setup() {
	createCanvas(windowWidth, windowHeight);
	pg = createGraphics(width, height);

   for (let i=0; i<100; i++){
	  pg.circle(random(0,width),random(0,height), 20);
	}
	
	background(100);
}

function draw() {
	image(pg, 0, 0);
}

function mouseReleased() {
	pg.save("test.png");
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the provided sketch using the createGraphics() and pg.save() entry points, then trace how saving is exposed for graphics objects. Check the existing image and rendering tests for a suitable regression-test location. Done means pg.save("test.png") works from mouseReleased without the reported TypeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
computer-graphics
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
62/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.