xxxxxxxxxx
function preload() {
overlay=loadImage("toRecolor.png");
fills=loadImage("spriteSheet.png");
palette=loadImage("palette.png");
}
let im;
function setup() {
createCanvas(windowHeight*overlay.width/overlay.height, windowHeight);
im=createImage(fills.width,fills.height);
//console.log(im);
noSmooth();
//colorP=createColorPicker('#FFFFFF').position(0,0).size(33,23).style('border:-1').style('background-color',color(0,0,0,200)).style('color',color(255));
}
function draw() {
background(50);
im.loadPixels();
for (let y=0;y<overlay.height;y++) {
for (let x=0;x<overlay.width;x++) {
if (alpha(overlay.get(x,y))==0) {im.set(x,y,fills.get(x,y));continue;}
c=palette.get(map(red(fills.get(x,y)),0,256,0,palette.width),0);
//map(red(fills.get(x,y)),0,255,0,palette.width)
//c=color(5,5,5);
//im.set(x,y,color(red(c)*red(colorP.value())/255,green(c)*green(colorP.value())/255,blue(c)*blue(colorP.value())/255));
n=map(mouseX,0,width,0,0.05);
im.set(x,y,color(noise(red(c)*n)*255,noise(green(c)*n+1000)*255,noise(blue(c)*n+2000)*255));
}
}
im.updatePixels();
image(im,0,0,width,height);
}
function mousePressed() {
noiseSeed(random(1000));
}
function keyPressed() {
im.save("sprites");
}