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

Incorrect equation on get() reference page

Open BumbertFiddlesticks opened this issue 3 years ago • 4 comments

Most appropriate sections of the p5.js website?

Reference

What is your operating system?

No response

Web browser and version

No response

Actual Behavior

This page provides an equivalent statement to get(), using the pixels array: https://p5js.org/reference/#/p5/get

I think the line "let off = (y * width + x) * d * 4;" should be replaced with: "let off = (y * d * width + x) * d * 4;" (This works for me at least, with d = 2).

Here's an example with both equations: https://editor.p5js.org/SnoopethDuckDuck/sketches/_0RDGo_zK

Example with code on website: (path colors don't match grid underneath) before

Example with new code: (path colors do match grid underneath) after

It should only be noticeable if d > 1, sorry if I'm wrong and I hope I've posted this correct-ish (wasn't sure if it's a bug or a discussion).

Expected Behavior

e

Steps to reproduce

e

Would you like to work on the issue?

nope

BumbertFiddlesticks avatar Aug 18 '22 15:08 BumbertFiddlesticks

Does your corrected equation work for all values of d or only for d=2?

Divyansh013 avatar Aug 20 '22 10:08 Divyansh013

I've just updated the sketch, it seems to work on all the values I've tried (1 up to 10 at least)

BumbertFiddlesticks avatar Aug 20 '22 12:08 BumbertFiddlesticks

For a possibly clearer equation maybe this one: 4 * ((y * d) * (width * d) + (x * d)) adapted from the pixels reference would help?

limzykenneth avatar Aug 24 '22 12:08 limzykenneth