xxxxxxxxxx
// Arrays 3: Our first array
// Creating a basic array with 1000 elements
// In this sketch we have 1000 instances of the same thing.
// We can't write each one out one at a time.
// Let's make an array.
// Create a new array.
// The name of the array is 'x'
// The number of elements in the array is 1000.
let x = new Array(1000);
// Hit play and see what happens...
// ... For now we're going to move to the next couple of sketches
// and then come back to this one in sketch 4.6_arrays_6
function setup() {
createCanvas(650, 650);
noStroke();
fill(255, 100);
for (let i = 0; i < 1000; i++) {
x[i] = random(-1000, 650);
}
}
function draw() {
background(255, 175, 0);
for (let i = 0; i < 1000; i++) {
x[i] += 0.5;
let y = i;
arc(x[i], y, 12, 12, 0.52, 5.76); // arc(x, y, w, h, start, stop)
}
}