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

[p5.js 2.0 Beta Bug Report]: p5.Image.copy throws ReferenceError: fn is not defined in p5.js v2 beta 5 #7659

Open
1 of 17 tasks
nakednous opened this issue Mar 23, 2025 · 4 comments

Comments

@nakednous
Copy link
Contributor

nakednous commented Mar 23, 2025

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
  • Internationalization
  • Friendly errors
  • Other (specify if possible)

p5.js version

beta5

Web browser and version

Firefox 136.0.2

Operating system

Linux

Steps to reproduce this

Description:

Calling image.copy(src, ...) on an image or p5.Graphics source throws:

ReferenceError: fn is not defined

This did not happen in p5.js v1.x and appears to be a regression introduced in v2 betas.

Steps to Reproduce:

function setup() {
  createCanvas(100, 100)
  let src = createGraphics(50, 50)
  let image = new p5.Image(src.width, src.height)
  image.copy(src, 0, 0, src.width, src.height, 0, 0, src.width, src.height)
}

Error:

Uncaught (in promise) ReferenceError: fn is not defined

Expected Behavior:
Image should copy content from src without throwing.

@VANSH3104
Copy link
Contributor

@limzykenneth can i give it a try

@limzykenneth
Copy link
Member

@VANSH3104 Feel free to have a look as I have limited availability in the next couple of days. It is related to the new refactoring of the renderer portion of the 2.0 codebase though and it is not very thoroughly documented at this point so no worries if you can't figure it out.

@VANSH3104
Copy link
Contributor

VANSH3104 commented Mar 27, 2025

Hi @limzykenneth, I noticed that in the dev-2.0 branch, the copy() function in p5.Image is implemented as:

copy(...args) {
    fn.copy.apply(this, args);
}

but this throws "ReferenceError: fn is not defined" in p5.js v2 beta 5
n main, it used:

copy(...args) {
    p5.prototype.copy.apply(this, args);
}

Was fn meant to replace p5.prototype.copy, or is it missing a reference/import? where fn should be coming from.

@limzykenneth
Copy link
Member

fn is meant to replace p5.prototype although functionally the two should be interchangeable. @ksen0 @davepagurek I'll have a closer look at this later next week when I'm back but we'll likely want to fix this before release.

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

No branches or pull requests

3 participants