xxxxxxxxxx
77
let fotitowo;
function preload() {
fotitowo = loadImage('frogtoad.jpg');
// './' significa que el archivo se cargará aquí mismo
}
function setup() {
createCanvas(800, 650);
}
function draw() {
background(220);
//image(fotitowo, -100, 0);
//image(fotitowo, 0, 0, width, height); la imagen toma las dimensiones del lienzo
image(fotitowo, mouseX, mouseY, 300, 200); //la imagen sigue al. cursor
//filter(GRAY); (INVERT); (OPAQUE); (GRAY); (THRESHOLD); (BLUR, 10);
/*loadPixels();
//console.log(pixels.length);
for(let i = 0; i < pixels.length; i++){
pixels[i] = 0;
pixels[index + 1] = 0;
pixels[index + 2] = 0;
pixels[index + 3] = 255;
}
updatePixels();
}*/
loadPixels();
// Set the dot's coordinates.
let x = 50;
let y = 50;
// Get the pixel density.
let d = pixelDensity();
// Set the pixel(s) at the center of the canvas black.
for (let i = 0; i < d; i += 1) {
for (let j = 0; j < d; j += 1) {
let index = 4 * ((y * d + j) * width * d + (x * d + i));
// Red.
pixels[index] = 0;
// Green.
pixels[index + 1] = 0;
// Blue.
pixels[index + 2] = 0;
// Alpha.
pixels[index + 3] = 255;
}
}
// Update the canvas.
updatePixels();
//condicionales
if (condition1) {
//si es verdadero
console.log('');
} else if (considtion2) {
console.log('');
} else {
console.log('');
}
//wolframalpha.com
// pixel = 24bits = 8bits x rgb con valores de 0-255 o 00-FF c/u