-
Notifications
You must be signed in to change notification settings - Fork 9
/
sketch.js
113 lines (82 loc) · 2.27 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// Daily Sketch for 2021-08-25
// Ram Narasimhan
/*
Domain Warping
Layers - Single color
*/
const cnv = {
xMargin: 30,
yMargin: 30,
}
let palette = []
const params = {
// bgColor: "#F1E0EA",
//bgColor:"#EAB6AB"
bgColor: "#0f0f0f", //black
// bgColor: '#ab3977', //black
}
function setup() {
createCanvas(660, 660);
colorMode(HSB);
background(0, 0, 0);
cnv.height = height - 2 * cnv.yMargin // usable height
cnv.width = width - 2 * cnv.yMargin //usable width
print(cnv)
xstart = cnv.xMargin
ystart = cnv.yMargin
xend = cnv.xMargin + cnv.width
yend = cnv.yMargin + cnv.height
midX = width / 2
midY = height / 2
palette2 = red_brown_orange; //colors.js
palette = flame;
//palette = replicate(palette, 100)
//Custom Tiling
colSplit = [1]
rowSplit = [3]
pgrid = new PanelGrid(cnv, colSplit, rowSplit)
//pgrid.renderPanelGrid(10);
for (p of pgrid.panels) {
domainWarpInsidepanel(p)
}
draw_border(clr = params.bgColor, sw = 50); //rn_utils.js
}
numLayers = 3
cutoff = [0.4, 0.5, 0.4]
function domainWarpInsidepanel(panel, dw_properties) {
push();
translate(panel.x, panel.y);
for (layer = 0; layer < numLayers; layer++) {
noisebase = layer * 0.01 * int(random(1, 7))
distortion_strength = layer * 0.001 * int(random(1, 7));
for (x = 0; x <= panel.pw; x++) {
for (y = 0; y <= panel.ph; y++) {
noise_scale = noisebase + (panel.x) * 0.0001
domain_warp(x, y, noise_scale, layer)
}
}
}
pop();
}
function distort(x, y) {
wiggle = 0.02
return noise(x * wiggle, y * wiggle)
}
function domain_warp(x, y, noise_scale, layer) {
dw_value = noise((x + 100 * layer) * 0.01, (y + layer * 233) * 0.01)
if (color_mapping(dw_value, layer)) {
point(x, y)
}
}
startColrs = [180, 344, 22]
function color_mapping(dw_value, layer) {
offset = layer * 20
startColr = startColrs[layer]
endColr = startColr //same color
colr = map(dw_value, 0, 1, startColr + offset, endColr + offset) % 360
if (dw_value < cutoff[layer]) {
stroke(colr, 50 + 10 * layer, 60 + 10 * layer)
return 1
}
return 0 // don't draw the point
}