xxxxxxxxxx
89
//I used code below Okazz_ on Open processing as the base for this generator
//https://www.openprocessing.org/sketch/825210
// Exports a high-resolution image when 'e' key is pressed.
let outputScale =5 ;
let currentScale;
let myScaledCanvas;
let canvas;
//r palette = ["#dcdcdc","d3d3d3","808080","696969"]
palette = ["#957dad",
"#d291bc",
"#d90368",
"#820263",
"#f3de2c"];
function setup() {
canvas=createCanvas(800, 800);
myScaledCanvas = createGraphics(800, 800);
currentScale = 1;
noLoop();
rectMode(CENTER);
}
function draw() {
myScaledCanvas.clear();
myScaledCanvas.push();
myScaledCanvas.scale(currentScale);
drawMyDesign();
myScaledCanvas.pop();
image(myScaledCanvas, 0, 0); // Show on the main canvas
noLoop();
}
function exportHighResolution() {
currentScale = outputScale; // High-Res Export
myScaledCanvas = createGraphics(currentScale * 800, currentScale * 800);
draw();
save(myScaledCanvas, "highResImage", 'png');
currentScale = 1; // Reset to default scale 1:1
myScaledCanvas = createGraphics(800, 800);
draw();
}
function keyReleased() {
if (key == 'e') exportHighResolution();
}
function drawMyDesign() {
grid();
}
// This is where the grid of dots is placed
function grid() {
myScaledCanvas.background(0);
let c = 100;
let w = width / 50;
for (let i = 0; i <= c; i++) {
for (let j = 0; j <= c; j++) {
let x = i * w;
let y = j * w;
col = random(palette);
myScaledCanvas.noStroke();
myScaledCanvas.fill(col);
myScaledCanvas.arc(x, y, 10, 10, random(radians(270)), PI + QUARTER_PI, PIE);
myScaledCanvas.strokeWeight(0.5);
myScaledCanvas.stroke(col);
noiseLine(x, y);
}
}
}
//noise line is making each and every little line segment and finding out its angle
function noiseLine(x, y) {
let c = 50;
let px = x;
let py = y;
for (let i = 0; i < c; i++) {
let ns = 0.00025;
let n = 10;
let angle = int(noise(x * ns, y * ns, i * 0.0001) * 500) * PI /10 ;
myScaledCanvas.line(x, y, px, py);
px = x;
py = y;
x += sin(angle) * 4;
y += cos(angle) * 4;
}
}