homework1/main.js
2025-02-18 11:56:12 +09:00

71 lines
1.2 KiB
JavaScript

/*
DI311 Homework 1
Author: Your name (KAIST ID)
*/
let flags = ['ITALY', 'CUBA', 'KUWAIT', 'LIBERIA', 'USA', 'EUROPE'];
const COLUMNS = 2;
const ROWS = 3;
function drawFlag(flag, x, y, width, height) {
// PLACEHOLDER
}
function italy(x, y, width, height) {
// PLACEHOLDER
}
function simpleTriangle(x, y, width, height) {
// PLACEHOLDER
}
function kuwait(x, y, width, height) {
// PLACEHOLDER
}
function liberia(x, y, width, height) {
// PLACEHOLDER
}
function cuba(x, y, width, height) {
// PLACEHOLDER
}
function europe(x, y, width, height) {
// PLACEHOLDER
}
function usa(x, y, width, height) {
// PLACEHOLDER
}
// DO NOT CHANGE ANY CODE UNDER THIS LINE
function setup() {
createCanvas(600, 600);
flags = shuffle(flags);
}
function draw() {
background(0);
noStroke();
const flagWidth = width / COLUMNS;
const flagHeight = height / ROWS;
let x = 0;
let y = 0;
for (let i = 0; i < flags.length; i += 1) {
x = flagWidth * (i % COLUMNS);
y = flagHeight * parseInt(i / COLUMNS);
drawFlag(flags[i], x, y, flagWidth, flagHeight);
// draw rect
stroke(255);
strokeWeight(2);
noFill();
rect(x, y, width, height);
}
}
const sketch = window;