xxxxxxxxxx
83
// M_1_2_01
//
// Generative Gestaltung – Creative Coding im Web
// ISBN: 978-3-87439-902-9, First Edition, Hermann Schmidt, Mainz, 2018
// Benedikt Groß, Hartmut Bohnacker, Julia Laub, Claudius Lazzeroni
// with contributions by Joey Lee and Niels Poldervaart
// Copyright 2018
//
// http://www.generative-gestaltung.de
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* order vs random!
* how to interpolate beetween a free composition (random) and a circle shape (order)
*
* MOUSE
* position x : fade between random and circle shape
*
* KEYS
* s : save png
*/
var actRandomSeed = 0;
// nombre d'ellipse dans la page
var count = 10000;
function setup() {
createCanvas(windowWidth, windowHeight);
// pas de contour sur les ellipses
noStroke();
// couleurs des ellipses
fill( 255, 255);
}
function draw(){
// remplit de blanc le fond
//background(0);
fill(0, 100);
rect(0, 0, width, height);
fill(255);
var faderX = mouseX / width;
randomSeed(actRandomSeed);
var angle = radians(360 / count);
for (var i = 0; i < count; i++) {
// positions
var randomX = random(0,width);
var randomY = random(0,height);
var circleX = width / 2 + cos(angle * i) * 300;
var circleY = height / 2 + sin(angle * i) * 300;
var x = lerp(randomX,circleX,faderX);
var y = lerp(randomY,circleY,faderX);
// dessiner l'ellipse
// changer 11 par un autre chiffre pour changer la taille des ellipses
circle(x,y,random(1, 4));
}
}
function mousePressed(){
actRandomSeed = random(100000);
}
function keyReleased(){
if (key == 's' || key == 'S') {
saveCanvas(gd.timestamp(), 'png');
}
}