how do i test the color of a pixel in p5.js

35 Views Asked by At

i am making a simple raycaster in p5.js(making my own 3d) and i cannot find how to make it read the pixels color.

i tried to do

for (let m = 0; m < 30; m++) {
    for (let i = 0; i < 100; i++) {
        sx += 1*sin(sdir);
        sy += 1*cos(sdir);
        let e = get(sx, sy, 1, 1);
        print(e);
    }
    line(sx, sy, x, y);
    sdir+=1;
}

sx, xy are defined and making the ray part, but i cant figure out how to make it read colors. i looked for a while in the docs, but there was nothing i could find. is it possible in p5.js to read pixel colors, or do i have to manually input areas for the ray to bounce on? the raycaster

0

There are 0 best solutions below