made new snake and index and liberary improvements

This commit is contained in:
Jürg Hallenbarter
2026-06-01 11:33:23 +02:00
parent 3d21e42d50
commit ee0d819d33
190 changed files with 3553 additions and 65 deletions

View File

@@ -1,13 +1,24 @@
function preload() {
img1 = loadImage('assets/wallpaper/Space-Nebula.png');
}
function setup() {
async function setup() {
img1 = await new Promise(resolve => loadImage('assets/wallpaper/lagrugru.jpg', resolve));
createCanvas(img1.width, img1.height);
background(255, 255, 55)
// performance enhancmend (from LLM)
img1.loadPixels();
for (let y = 0; y < img1.height; y++) {
for (let x = 0; x < img1.width; x++) {
let idx = (x + y * img1.width) * 4;
let r = img1.pixels[idx];
let g = img1.pixels[idx+1];
let b = img1.pixels[idx+2];
let sum = r + g + b;
let threshold = random(0, 255) * 3;
set(x, y, sum < threshold ? color(0) : color(255));
}
}
updatePixels();
//image(img1, 0, 0);
//original code (works to but somettimes not good for bigger images)
/*
for (let col = 0; col < img1.width; col += 1) {
for (let row = 0; row < img1.height; row += 1) {
let c = img1.get(col, row);
@@ -26,6 +37,8 @@ function setup() {
point(col, row);
}
}
console.log('finished');
*/
}