Processing code to p5.js

I wonder how to translate this
PImage magnified, normal; to p5.js.
My guess is
let magnified= new p5.Image();
let normal= new p5.Image(); but that didn’t make it work. I am trying to do make a magnifying glass like the sketch from Tande Campos https://www.openprocessing.org/sketch/132623/ but in p5.js

Check out the P5.js reference for handy functions:

https://p5js.org/reference/

I have checked everywhere I could before I ask a question here. P5.js references do not include an answer to my question.

The best advice I can give you is to start simpler. Can you get a simple P5.js sketch working that shows a single image?

My question is how to translate PImage magnified, normal to P5.js.
I dont need patronizing advices

I’m sorry if you think I’m coming across as patronizing; that’s not my intention.

I am trying to guide you to the way I would approach the problem: by understanding what the original program does, and then looking for functions that help me achieve that in the target language.

In other words, I wouldn’t try to translate a program line-by-line. Instead, I would look at the program as a whole and try to reproduce that.

The best way I know how to do that is to start with smaller programs that test things out. If I wasn’t sure how to show an image in P5.js, I would start by trying to show a single hard-coded image. Then I’d work my way up from there.

Good luck.

1 Like