xxxxxxxxxx
59
let drinkChoice
let milkOption
let sugarOption
let togoOption
function setup() {
createCanvas(400, 400);
// note: look in style.css for layout options
drinkChoice = createRadio()
drinkChoice.option("Coffee")
drinkChoice.option("Tea")
drinkChoice.option("Matcha")
drinkChoice.position(100, 50)
drinkChoice.selected("Tea")
milkOption = createCheckbox("Milk", true)
milkOption.position(100,125)
sugarOption = createCheckbox("Sugar")
sugarOption.position(100,150)
togoOption = createCheckbox("To Go")
togoOption.position(100,175)
}
function draw() {
background(220);
let drink = drinkChoice.value()
let milk = milkOption.checked()
let sugar = sugarOption.checked()
let togo = togoOption.checked()
fill(0)
textSize(24)
text("One cup of " + drink.toLowerCase(), 100, 250)
fill(120)
if (milk){
text("with milk", 100, 275)
}else{
text("no milk", 100, 275)
}
if (sugar){
text("with sugar", 100, 300)
}else{
text("no sugar", 100, 300)
}
if (togo){
text("to go", 100, 325)
}else{
text("for here", 100, 325)
}
}