//hi thanks for taking a look. i really appreciate you.
//
//send me an email lee at leetusman com
//i will try to write back
//
const poems = 50;

//DON'T CHANGE THESE
const items=54; //max image in folder
let chosen = [];
let selection;

function preload(){
  selection = loadSound('assets/select.mp3');
}

function setup(){
  noCanvas();

  blog();
  makePage();

}

function makePage(){
    for (let i = 0; i < poems; i++){
	  let r = round(random(items));
          chosen.push(r);

	  if (r < 10){
	     item = "0" + str(r);
	  } else {
	     item = r;
	  }

	  let img = createImg("assets/cropped/"+item+".png");

	  let _x = random(windowWidth-img.width/2);
          let _y = random(windowHeight*8); //good

	  img.position(_x,_y);
    }
}

function blog(){
  createP("Hi, i'm lee2sman. welcome to my idpw log. it's sunday jan 31 at 3:16pm. it's cold outside but i have a nice warm radiator in here. i live a few blocks from a park so i feel pretty stuck in my studio apartment but lucky to be able to go outside soon. i am listening to zomby witch hunt and eating leftover pasta and eggplant. pour some tea. click around.").position(random(windowWidth),random(windowHeight)).style('background-color','white').style('color','purple')
  createP("no gods no masters").position(random(windowWidth),random(windowHeight)).style('background-color','white').style('color','purple')
  createP("hello, today is mon 2/1 10:48pm. today there was a blizzard. i took a walk and listened to Levar Burton read the short story Mother of Invention by Nnedi Okorafor and enjoyed the snow blanket. i shoveled the neigbors walk and talked to my parents and got a good note from my doctor and listened to ethiopiques and extreme metal workout. i start teaching this week. 50+ emails").position(random(windowWidth),random(windowHeight)).style('background-color','white').style('color','red')
  createP("2/2 exercised while watching a 'hip hop dance fitness' video on youtube. don't know why i'm writing this publicly. talked to a student and a friend about public space online and notions of consent.").position(random(windowWidth),random(windowHeight)).style('background-color','white').style('color','darkblue')
  createP("2/7 01:35am end of a long but satisfying week. finished teaching first week of the semester. lots of students i've had before in past classes. it's my 3rd yr here and it's really nice to have students over the years and see them grow. tried out xin's togethernet project for debugging. went biking sort-of in the snow. made a pizza for dinner with onion, red pepper, mushroom, garlic, egg, meatloaf (leftovers from dinner dan made last night). lately i've been adding a little bit of sesame oil to my pizza too. my parents and i met up on zoom, watched some klezmer videos, tuvan performances, and a documentary on tuareg musicians.").position(random(windowWidth),random(windowHeight)).style('background-color','white').style('color','darkgreen')
  createP("2/17 23:03 it's been a minute. had a long week. coded my own LOGO language and then made some of my own art with it. it was really fun to design a little language. with my students i've tried to get them to start (b)logging about their work as a way to informally share what they are working on. i'll have to show them this site. trying to get a podcast episode finished, keep up biking in the park everyday if i can. at night as it gets late i like to sit and read and code by candlelight. i made some blogging software yesterday for gemini. i was so deep in the flow i worked til late into the night").position(random(windowWidth),random(windowHeight)).style('background-color','white').style('color','coral')
  createP("2/22 13:43 finished List Jam over the weekend, making a speculative list of games i'd like to play and/or make. had some nice responses on mastodon and to the original post. got into a back-and-forth with other artists about nft crap. have been having sleeping problems again. maybe i need to start drinking coffee in the morning again? seems counter-intuitive. last week was the 10 yr anniversary of my friend monte's death. i miss him. lit a candle and listened to music, thinking about him.").position(random(windowWidth),random(windowHeight)).style('background-color','white').style('color','blue')
  createP("2/27 2:39 end of a busy week. classes went well; pretty much all my students did the homework. that never happens! in one of my classes students designed their own algorithmic artificial life. we've been talking about our views on 'collaborating with the machine' vs the programmer-artist as creator, why some people insist on calling themselves painters. stayed up late completing podcast. felt good releasing today. tonight i baked hamantashen cookies and had dinner with dan and fam. looking forward to some warmer weather this weekend but it's supposed to rain. i love wandering under an umbrella in the rain, the city to myself.").position(random(windowWidth),random(windowHeight)).style('background-color','white').style('color','black');
  ;
}

function mousePressed(){
  selection.play();
  blog();
  makePage();
}


// gradient bg - nicked from luis from my spam.cafe site, updated to a p5 stylee ;0
// ------------------------------------------------
var colors = new Array(
  [62,35,255],
  [60,255,60],
  [255,35,98],
  [45,175,230],
  [255,0,255],
  [255,128,0]);

var step = 0;
//color table indices for:
// current color left
// next color left
// current color right
// next color right
var colorIndices = [0,1,2,3];

//transition speed
var gradientSpeed = 0.002;

function updateGradient()
{

var c0_0 = colors[colorIndices[0]];
var c0_1 = colors[colorIndices[1]];
var c1_0 = colors[colorIndices[2]];
var c1_1 = colors[colorIndices[3]];

var istep = 1 - step;
var r1 = Math.round(istep * c0_0[0] + step * c0_1[0]);
var g1 = Math.round(istep * c0_0[1] + step * c0_1[1]);
var b1 = Math.round(istep * c0_0[2] + step * c0_1[2]);
var color1 = "rgb("+r1+","+g1+","+b1+")";

var r2 = Math.round(istep * c1_0[0] + step * c1_1[0]);
var g2 = Math.round(istep * c1_0[1] + step * c1_1[1]);
var b2 = Math.round(istep * c1_0[2] + step * c1_1[2]);
var color2 = "rgb("+r2+","+g2+","+b2+")";

  let grad = select('#gradient');

  grad.style("background","-webkit-gradient(linear, left top, right top, from("+color1+"), to("+color2+"))");
  grad.style("background","-moz-linear-gradient(left, "+color1+" 0%, "+color2+" 100%)");


  step += gradientSpeed;
  if ( step >= 1 )
  {
    step %= 1;
    colorIndices[0] = colorIndices[1];
    colorIndices[2] = colorIndices[3];

    //pick two new target color indices
    //do not pick the same as the current one
    colorIndices[1] = ( colorIndices[1] + Math.floor( 1 + Math.random() * (colors.length - 1))) % colors.length;
    colorIndices[3] = ( colorIndices[3] + Math.floor( 1 + Math.random() * (colors.length - 1))) % colors.length;

  }
}

setInterval(updateGradient,10);
