Indexes
An index is a number which points to the element that you want to reference in an array.
Processing
String[] cities = {
"Amsterdam",
"Paris",
"Berlin",
"Münster",
"Lisbon"
};
PFont font;
void setup() {
size(900, 900);
font = createFont("sans.otf",900);
}
void draw() {
background(#f1f1f1);
fill(0);
textAlign(CENTER,CENTER);
textFont(font);
textSize(150);
text(cities[0],width/2,height/2);
}
P5.js
let cities = [
"Amsterdam",
"Paris",
"Berlin",
"Münster",
"Lisbon"
];
let font;
function preload() {
font=("arial");
}
function setup() {
createCanvas(900, 900);
}
function draw() {
background("#f1f1f1");
fill(0);
textAlign(CENTER,CENTER);
textFont(font,150);
textSize(150);
text(cities[4],width/2,height/2);
}
Related
Published by Tim on Friday February 19, 2021