let myImg, currentColor, myInput, myName;
myImg = loadImage('./haars.jpg');
createCanvas(windowWidth, windowHeight);
function mousePressed() {
function displayMyImage(){
let imgRatio = myImg.height / myImg.width;
myImg.resize(width, width * imgRatio);
function drawMyBasicUI(){
text("Type your first name →", width-350, 47);
text("Type a one-word palette name e.g. Kandinsky →", width-350, 77);
myName.position(width-320, 30);
myInput.position(width-320, 60);
let button = createButton('download file');
button.position(width - 120, 50);
button.mousePressed(downloadTheFile);
function myColorPicker() {
currentColor = (color(255));
currentColor = myImg.get(mouseX, mouseY);
function addColorToArray() {
let newColor = ['"#', hex(currentColor[0], 2), hex(currentColor[1], 2), hex(currentColor[2], 2), '"'];
newColor = join(newColor, '');
let myColor = ['#', hex(currentColor[0], 2), hex(currentColor[1], 2), hex(currentColor[2], 2)];
myColor = join(myColor, '');
savedColors.push(newColor);
function downloadTheFile(){
if(myInput.value() && myName.value()){
let paletteName = myInput.value();
let yourName = myName.value();
let readMe = createWriter('readme-'+paletteName+'.txt');
let theRead = `Readme file: just to let you know, the ${paletteName}.css file you just downloaded is not real css, its more like a javascript object notation (not important). What is important is that we can open it in photoshop, yay! To do this, go to Photoshop > Window > Swatches to make sure you have the swatches window open. Click on the three lines on the top right of the swatches pane to see the menu for swatches. Click Import swatches to import the colors and select the ${paletteName}.css you just made. After opening in photoshop you can then click on the swatch or group of swatches and go to the same swatch palette menu and click "Export swatches for exchange" which will produce an Adobe ASE file which you can open in illustrator or figma via the import plugin`;
let thisPalette= "{" + paletteName + ": [" + savedColors + "]}";
let myWriter = createWriter(paletteName+'.css');
myWriter.write(thisPalette);
let albersPalette = '{ name: "' + yourName + '", paletteName: "' + paletteName + '", cols: [' + savedColors + "]}";
let sendText = createWriter(yourName + '-' + paletteName + '.txt');
sendText.write(albersPalette);
throw new Error('Louise’s error: Please enter your name and a name for this palette that describes its mood in the spaces provided😎');