[docs] Fix a minor bug in binding tutorial (#6698)

To calculate y coordinate of `imageData`, we should divide the index with
`canvas.width` not with `canvas.height`. The current code works because the
shape of canvas is square.
pull/6700/head
gunggmee 3 years ago committed by GitHub
parent 4d30ef34e3
commit dc11e4487e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -15,7 +15,7 @@
for (let p = 0; p < imageData.data.length; p += 4) {
const i = p / 4;
const x = i % canvas.width;
const y = i / canvas.height >>> 0;
const y = i / canvas.width >>> 0;
const r = 64 + (128 * x / canvas.width) + (64 * Math.sin(t / 1000));
const g = 64 + (128 * y / canvas.height) + (64 * Math.cos(t / 1000));

@ -15,7 +15,7 @@
for (let p = 0; p < imageData.data.length; p += 4) {
const i = p / 4;
const x = i % canvas.width;
const y = i / canvas.height >>> 0;
const y = i / canvas.width >>> 0;
const r = 64 + (128 * x / canvas.width) + (64 * Math.sin(t / 1000));
const g = 64 + (128 * y / canvas.height) + (64 * Math.cos(t / 1000));

Loading…
Cancel
Save