Skip to content

Sending a p5.Graphics object into image() spams the console with warnings, reducing performance #755

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

Closed
clayheaton opened this issue Jun 17, 2015 · 3 comments

Comments

@clayheaton
Copy link

If you run the createGraphics() example code locally and open your Chrome developer tools, you'll see the following repeated many times:

p5.js says: image was expecting a p5.image for parameter #1, received [object Object] instead. image takes different numbers of parameters depending on what you want to do. Click this link to learn more: [http://p5js.org/reference/#p5/image]

screen shot 2015-06-16 at 9 38 24 pm

This causes serious performance issues on my computer, spinning up the fan, etc...

The code I used to reproduce it is:

var pg;
function setup() {
  createCanvas(100, 100);
  pg = createGraphics(100, 100);
}
function draw() {
  background(200);
  pg.background(100);
  pg.ellipse(pg.width/2, pg.height/2, 50, 50);
  image(pg, 50, 50);
  image(pg, 0, 0, 50, 50);
}
@lmccart
Copy link
Member

lmccart commented Jun 17, 2015

looks like we are missing support for p5.Graphics arg in the validateArguments check, it should be something more like this.

    this._validateParameters('image', arguments, [
      [
        'p5.Graphics',
        'Number',
        'Number'
      ],
      [
        'p5.Image',
        'Number',
        'Number',
        'Number',
        'Number'
      ],
      [
        'p5.Graphics',
        'Number',
        'Number'
      ],
      [
        'p5.Graphics',
        'Number',
        'Number',
        'Number',
        'Number'
      ]
    ]);

however, this still create the warning unless the p5.Image block is removed completely.

@crhallberg any thoughts on what might need to change about the validateArguments function?

@lmccart
Copy link
Member

lmccart commented Jun 17, 2015

@ccheaton in the meantime, you can use p5.min.js file which doesn't have this error checking.

@clayheaton
Copy link
Author

@lmccart Thanks. I've been trying to stick with the unminified version to familiarize myself with the codebase, in hopes of contributing in the future. I'll stick with p5.min.js for anything meant for production.

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

No branches or pull requests

2 participants