-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsketch.js
73 lines (56 loc) · 1.7 KB
/
sketch.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
const CRYSTAL_SIZE = 150;
const padding = 16;
const canvasPadding = 19;
const SIZE = 6;
const stepOut = 8;
const thinStroke = 1;
const thickStroke = 3;
let PALETTE = [];
var w = window.innerWidth;
var h = window.innerHeight;
const row = Math.floor(w/CRYSTAL_SIZE)-1;
const col = Math.floor(h/CRYSTAL_SIZE);
function setup() {
createCanvas((CRYSTAL_SIZE+canvasPadding)*row,(CRYSTAL_SIZE+canvasPadding)*col, SVG);
PALETTE = [
color('#ED6360'), //coral
color('#2a237d'), //purple
];
angleMode(DEGREES);
rectMode(CENTER);
noLoop();
}
function draw() {
for (let i = 0; i < row; i++){
for (let j = 0; j < col; j++){
let crystal = new Crystal(CRYSTAL_SIZE/2+(i*(CRYSTAL_SIZE+padding)), CRYSTAL_SIZE/2+(j*(CRYSTAL_SIZE+padding)), SIZE, CRYSTAL_SIZE, stepOut, thinStroke, thickStroke);
crystal.render();
}
}
}
function simpleLines (){
const stepsOutwards = 8;
const numOfSteps = randomBinaryChoice() ? stepsOutwards : stepsOutwards * 1.25;
const step = (CRYSTAL_SIZE/2) / numOfSteps;
const start = floor(random(0, numOfSteps));
const stop = floor(random(0, numOfSteps + 1));
let numShapes = randomBinaryChoice() ? SIZE : SIZE*2;
let strokeColor = getPalette();
let weight = randomBinaryChoice() ? 1 : 3;
console.log(weight);
noFill();
push();
translate(width/2,height/2);
stroke(strokeColor);
strokeWeight(weight);
ellipse(0,0,CRYSTAL_SIZE,CRYSTAL_SIZE);
for(let i = 0; i < numShapes; i++){
rotate(360/numShapes);
line(0,0,CRYSTAL_SIZE/2,0);
}
pop();
}
function mouseClicked() {
clear();
redraw();
}