xxxxxxxxxx
58
/*
Based on Matt Pearson's "Listing i.1 A generative system in 24 lines of code" in the Introduction to Generative Art, 2011, p. xxiii
License:
No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher, with the exception of the Introduction, Chapter 1, Chapter 6, and the source code throughout, which are available under a Creative Commons (Attribution-NonCommercial 3.0) license.
See creativecommons.org/licenses/by-nc/3.0/. Note that Creative Commons distribution of the images in the Introduction and in Chapter 1 is limited to those by Matt Pearson only.
*/
//def setup function
function setup() {
//set canvas to windowWidth and windowHeight
createCanvas(windowWidth, windowHeight);
//set background to white
background(0);
//don't fill shapes
noFill();
stroke(255);
//define xstart and ty to random 0-10
let xstart = random(1);
let ty = random(1);
//move image to center of canvas
translate(width / 2, height / 2);
//start for loop, set y to 1/8 of -height. if y is less than 1/8 of height add 3 to y
for (let y = -height / 2; y <= height / 2; y += 3) {
//add 0.02 to ty
ty += 0.02;
//define tx to xstart
let tx = xstart;
//start for loop, set x to 1/8 of -weight. if x is less than 1/8 of width add 3 to x
for (let x = -width / 2; x <= width / 2; x += 3) {
//add 0.02 to tx
tx += 0.02;
//define noiseFactor as noise tx to ty
let noiseFactor = noise(tx, ty);
//call drawcircle function with x, y, noisefactor variables
drawCircle(x, y, noiseFactor);
}
}
}
//empty draw loop
function draw() {}
//define drawCircle function with x, y, noise inputs
function drawCircle(newX, newY, newNoise) {
//start transform
push();
//move to x times noise times 4, and y times noise times 4
translate(newX * newNoise * 1.5, newY * newNoise * 1.5);
//make a circle at 0, 0 with a size of noise times 10
circle(0, 0, newNoise * 5);
//end transform
pop();
}