p5.js icon indicating copy to clipboard operation
p5.js copied to clipboard

p5 image scaling(resize func) screw up image quality

Open EnginKARATAS opened this issue 4 years ago • 4 comments

p5 image scaling screw up image quality

image(dogeplayer, this.x- 25, this.y - 25);
dogeplayer.resize(this.r + 40, this.r + 40);

Most appropriate sub-area of p5.js?

  • [*] Image
  • [*] IO (Input/Output)

Screenshot_37 Screenshot_38

EnginKARATAS avatar Jun 11 '21 20:06 EnginKARATAS

Hi @EnginKARATAS, can you share a more complete example? Even better if it is running on https://editor.p5js.org. I can't tell where the problem could be with the two lines of code you provided. Thanks.

limzykenneth avatar Jun 13 '21 13:06 limzykenneth

Hi @limzykenneth , the resize function causing this. I have project like this example. When other tab opens, both tabs, all images bluring. Im working to dynamic size with socket. I wouldnt share more example.

EnginKARATAS avatar Jun 14 '21 20:06 EnginKARATAS

@EnginKARATAS You don't have to share the code you are working on, just a minimal example that isolate and shows the problem. I can't help otherwise.

limzykenneth avatar Jun 14 '21 20:06 limzykenneth

//ignore translate, zoom, scale show() {
translate(width / 2, height / 2);
let newzoom = 128 / player.r;
zoom = lerp(zoom, newzoom, 0.1); scale(zoom*0.5);
translate(-player.x, -player.y);
image(dogeplayer, this.x- 25, this.y - 25);
dogeplayer.resize(this.r + 40, this.r + 40); }

in sketch.js

if (frameCount % 60 == 0) { if (player.r > 10 && player.r < 64) { player.r -= 1; } else if (player.r > 64) { player.r -= 3 } }}

how I solve(but there is no re-sizing with my solve. I want to re-sizing)

player.js show function Screenshot_44

and I make a comment line for variable that growing the size Screenshot_45

EnginKARATAS avatar Jun 14 '21 21:06 EnginKARATAS