xxxxxxxxxx
61
/**
* Random Points
*
* GIT:
* Author: mark webster 2020
* https://dpmanual.bitbucket.io
* https://designingprograms.bitbucket.io
*
* LICENCE
* This software is part of a package of pedagogical tools used
* with the online website, Computational Graphic Design Manual :
* https://dpmanual.bitbucket.io
*
* Copyright ©2020 mark webster
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see https://www.gnu.org/licenses/gpl-3.0.html.
*
*/
let randSeed = 1;
/////////////////////////// SETUP ////////////////////////////
function setup() {
createCanvas(500, 500);
background(0);
stroke(255);
}
/////////////////////////// DRAW ////////////////////////////
function draw() {
background(0);
randomSeed(randSeed);
let numPoints = map(mouseX, 0, width, 1, 500);
let cutOffVal = map(mouseY, 0, height, 1, 125);
for(let i=0; i<numPoints; i++){
let pntSize = random(1, cutOffVal);
strokeWeight(pntSize);
let x = random(width);
let y = random(height);
point(x, y);
}
}
/////////////////////////// FUNCTIONS ////////////////////////////
function keyPressed() {
if (key == 'r') {
randSeed = random(1000);
}
}