xxxxxxxxxx
// Digital Migrations 2021 @cheapjack tutorial for making memes
// with p5.js to get the hang of loading in external assets and drawing text
// and images
// setup the variable memeFont
// setup and 'declare' the variable img & myFont to store our image and font
let img;
let myFont;
// make a function to pre-load it before your sketch runs so its good to go
// memes often use Impact.ttf a true-type font
function preload() {
// loadImage called 'they-dont-know-meme-blank.jpg' which is in the same directory as this sketch
// into the variable we 'declared' earlier, img
img = loadImage('they-dont-know-meme-blank.jpg');
//do the same to preload a font
myFont = loadFont('Impact.ttf');
}
// setup as usual
function setup() {
createCanvas(windowWidth, windowHeight);
// make the canvas fit the meme img size
// you use 'dot notation' which means you can access certain
// predefined parameters to certain 'objects'
// so you can also get the screen width of whatever device
// you load the sketch on in a browser window with
// window.screen.width or window.screen.height
createCanvas(img.width, img.height);
background(0);
image(img, 0, 0);
// Make a simple random text generator by making an array of phrases and text
// Then uncomment (remove the leading //) lines 56, 58 & 60 and commenting out 55, 57 & 59 (add 2 // at the start to make text go grey)
// Remember our arrays in the first session? Instead of an array of coordinates we can make
// an array of text 'strings' Like many languages, Processing calls a sequence of text a text string,
// ie a string of alphanumeric chararters enclosed in single of double quotes
// Refer to our DIY dataset and notice the similarity and how many kinds of variable
// https://cheapjack.github.io/DigitalMigrations/Data_As_Art_Material.html#diy-dataset-
myMemeText1 = ['contributed to this processing', 'lost my job at the', 'hate everyone'];
myMemeText2 = ['library',' ','computers'];
partyText = ['BANGIN!', 'THIS SUCKS', 'WOOOAHHHHHH!'];
//stroke(0);
//strokeWeight(4);
fill(0,0,0);
textFont(myFont);
textAlign(LEFT);
textSize(48);
// small point below is that in order to use an apostrophe you have to 'escape' the
// apostrophe character so processing doesn't think it's the end
// of a string, so convention is to surround the special character with a back slash
text('They dont know I ', img.width/4 + 30, 60);
textSize(36);
text('contributed to this processing', img.width/4+35, 110);
//text(random(myMemeText1), img.width/4+35, 110); // Here instead of typing the text, myMemeText1 is randomly chosen when the sketch runs
text('library', img.width/4+35, 160);
//text(random(myMemeText2), img.width/4+35, 160);
text('BANGIN CODE BRUH', img.width/2, img.height-20);
//text(random(partyText), img.width/2, img.height-20);
}
function draw() {
// uncomment the below to allow people to graffitti the sketch
//ellipse(mouseX, mouseY, 20, 20);
}