Hi,
Sorry for my english, i’m french.
I’d like to check each pixel from image by step of 5 and write coordinates into an array of each pixel whose value is under 150.
I used a loops to check pixels and a « if » to verify its values but it doesn’t work.
Do someone know why ?
Here is my code.
let bugs = ;
let xpos = ;
let ypos = ;let pix;
let img;
let ry = 0;
let rx = 0;
let ba;
function preload() {
img = loadImage(‘assets/pomme.jpg’);
}function ecriture(){
for (let rx = 0 ; rx < 225 ; rx = rx+5){
if (img.get(rx, ry) < 150){
xpos.push(rx);
ypos.push(ry);
ellipse(rx, ry, 2, 2);
}
}
}function setup() {
createCanvas(225, 225);
image(img, 0, 0);for (let ry = 0 ; ry < 225 ; ry = ry+5){
ecriture(); } textSize(45); text(ypos[55], 100, 130); for (let i = 0; i < 100; i++){ bugs.push(new Jitter(xpos[i], ypos[i])); }
}
function draw() {
for (let i = 0; i < bugs.length; i++){ bugs[i].display(); }
}
class Jitter {
constructor (x, y) {
this.x = 50;
this.y = 50;
}display(){
fill (0);
ellipse(this.x, this.y, 5, 5);
}
}
thank you