Home / π Schedule / π Examples / π« Guides / π Resources
β¨ Conditionals are the key way we can make a program do different things based on the current situation! β¨
if-statementsVimeo playlist for Conditionals
(Inline links below are for YuJa)
loadImage() and image() πrandom() and probability (Loot drops!)We can store text in variables (or object properties) by using quotation marks:
let myName = "Gladiolus";
We can display text by using p5βs text() function along with some text-styling functions:
let myName = "Gladiolus";
function setup() {
createCanvas(400, 400);
}
function draw() {
background(0);
push();
// Set text colour with fill
fill(255, 0, 0);
// Set text size with textSize()
textSize(64);
// Set text align with textAlign()
textAlign(CENTER, CENTER);
// Set text styling with textStyle()
textStyle(BOLD);
// We can display text by just putting it directly in quotes
text("Hi, my name is:", 200, 180);
// We can display text inside a variable
text(myName, 200, 220)
pop();
}
π Read the Typography documentation in the reference for more information. π