setup()
setup() runs once when the sketch loads. It's the perfect place to initialize your canvas, set styling options, and prepare data like the words array that will be used by draw() and keyPressed().
function setup() {
createCanvas(windowWidth, windowHeight);
textFont("monospace");
textSize(18);
fill(0,255,70);
words = code.split(/\s+/);
}
Line-by-line explanation (5 lines)
createCanvas(windowWidth, windowHeight);- Creates a canvas that fills the entire browser window, making the terminal feel immersive and full-screen
textFont("monospace");- Sets the font to monospace, which is the classic teletype font used in real terminals and makes code look authentic
textSize(18);- Sets the size of all text to 18 pixels tall—large enough to read clearly but small enough to fit many lines
fill(0,255,70);- Sets the text color using RGB values: 0 red, 255 green, 70 blue creates the iconic neon green glow
words = code.split(/\s+/);- Splits the code string by whitespace using a regex pattern, creating an array where each element is a single word or line break