idpw/sketch.js
2021-02-07 01:45:44 -05:00

122 lines
4.7 KiB
JavaScript

//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')
}
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);