Skip to content

Commit c40b36e

Browse files
authored
Merge pull request #170 from generative-design/dev-updates
Dev updates
2 parents df73cc6 + fec8bdf commit c40b36e

File tree

125 files changed

+57050
-46280
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+57050
-46280
lines changed

.eslintignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
libraries/*
2+
styles/*
3+
p5.js
4+
*.min.js

.eslintrc

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"env": {
3+
"browser": true
4+
},
5+
"rules": {
6+
"semi": "error",
7+
"no-eval": "error",
8+
"indent": [
9+
"error",
10+
2
11+
],
12+
"quotes": [
13+
"error",
14+
"single"
15+
],
16+
"no-multiple-empty-lines": [
17+
"error",
18+
{
19+
"max": 1,
20+
"maxEOF": 1,
21+
"maxBOF": 0
22+
}
23+
],
24+
"no-mixed-spaces-and-tabs": "error",
25+
"no-tabs": "error",
26+
"no-trailing-spaces": "error",
27+
"semi-style": [
28+
"error",
29+
"last"
30+
],
31+
"spaced-comment": "error",
32+
"switch-colon-spacing": [
33+
"error",
34+
{
35+
"after": true,
36+
"before": false
37+
}
38+
],
39+
"space-infix-ops": "error",
40+
"no-multi-spaces": "error",
41+
"space-in-parens": [
42+
"error",
43+
"never"
44+
],
45+
"space-unary-ops": "error",
46+
"brace-style": "error",
47+
"eol-last": "error",
48+
"comma-dangle": [
49+
"error",
50+
"never"
51+
],
52+
"func-call-spacing": "error",
53+
"key-spacing": "error",
54+
"keyword-spacing": "error"
55+
}
56+
}

01_P/P_1_2_1_01/sketch.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
var tileCountX = 2;
3636
var tileCountY = 10;
3737

38-
var colorsLeft = []
38+
var colorsLeft = [];
3939
var colorsRight = [];
4040
var colors = [];
4141

@@ -97,7 +97,7 @@ function mouseReleased() {
9797
}
9898

9999
function keyPressed() {
100-
if (key == 'c' || key == 'C') writeFile([gd.ase.encode( colors )], gd.timestamp(), 'ase');
100+
if (key == 'c' || key == 'C') writeFile([gd.ase.encode(colors)], gd.timestamp(), 'ase');
101101
if (key == 's' || key == 'S') saveCanvas(gd.timestamp(), 'png');
102102
if (key == '1') interpolateShortest = true;
103103
if (key == '2') interpolateShortest = false;

01_P/P_1_2_2_01/sketch.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ var colors = [];
4040
var sortMode = null;
4141

4242
function preload() {
43-
img = loadImage('data/pic1.jpg');
43+
loadImage('data/pic1.jpg', setImage);
4444
}
4545

4646
function setup() {
@@ -82,14 +82,18 @@ function keyReleased() {
8282
if (key == 'c' || key == 'C') writeFile([gd.ase.encode(colors)], gd.timestamp(), 'ase');
8383
if (key == 's' || key == 'S') saveCanvas(gd.timestamp(), 'png');
8484

85-
if (key == '1') img = loadImage('data/pic1.jpg');
86-
if (key == '2') img = loadImage('data/pic2.jpg');
87-
if (key == '3') img = loadImage('data/pic3.jpg');
88-
if (key == '4') img = loadImage('data/pic4.jpg');
85+
if (key == '1') loadImage('data/pic1.jpg', setImage);
86+
if (key == '2') loadImage('data/pic2.jpg', setImage);
87+
if (key == '3') loadImage('data/pic3.jpg', setImage);
88+
if (key == '4') loadImage('data/pic4.jpg', setImage);
8989

9090
if (key == '5') sortMode = null;
9191
if (key == '6') sortMode = gd.HUE;
9292
if (key == '7') sortMode = gd.SATURATION;
9393
if (key == '8') sortMode = gd.BRIGHTNESS;
9494
if (key == '9') sortMode = gd.GRAYSCALE;
9595
}
96+
97+
function setImage(loadedImageFile) {
98+
img = loadedImageFile;
99+
}

01_P/P_1_2_3_03/sketch.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ var hueValues = [];
3434
var saturationValues = [];
3535
var brightnessValues = [];
3636
var actRandomSeed = 0;
37-
var alphaValue = 27;
37+
var alphaValue = 75;
3838

3939
function setup() {
4040
createCanvas(windowWidth, windowHeight);
@@ -119,8 +119,8 @@ function gradient(x, y, w, h, c1, c2) {
119119
var grd = ctx.createLinearGradient(x, y, x, y + h);
120120
grd.addColorStop(0, c1.toString());
121121
grd.addColorStop(1, c2.toString());
122-
ctx.fillStyle = grd;
123-
ctx.fillRect(x, y, w, h);
122+
ctx.fillStyle = grd;
123+
ctx.fillRect(x, y, w, h);
124124
}
125125

126126
function mouseReleased() {

01_P/P_1_2_3_04/sketch.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ var hueValues = [];
3434
var saturationValues = [];
3535
var brightnessValues = [];
3636
var actRandomSeed = 0;
37-
var alphaValue = 27;
37+
var alphaValue = 75;
3838

3939
function setup() {
4040
createCanvas(windowWidth, windowHeight);
@@ -121,8 +121,8 @@ function gradient(x, y, w, h, c1, c2) {
121121
var grd = ctx.createLinearGradient(x, y, x, y + h);
122122
grd.addColorStop(0, c1.toString());
123123
grd.addColorStop(1, c2.toString());
124-
ctx.fillStyle = grd;
125-
ctx.fillRect(x, y, w, h);
124+
ctx.fillStyle = grd;
125+
ctx.fillRect(x, y, w, h);
126126
}
127127

128128
function mouseReleased() {

01_P/P_1_2_3_05/sketch.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ function draw() {
101101

102102
if (random() < 0.45) {
103103
var w = map(parts[ii], 0, sumPartsTotal, 0, width);
104-
var h = rowHeight * 1.5
104+
var h = rowHeight * 1.5;
105105
var px1 = map(sumPartsNow, 0, sumPartsTotal, 0, width);
106106
var px2 = px1 + w;
107107
var py1 = rowHeight * i;
@@ -126,8 +126,8 @@ function centerGradient(x1, y1, r1, x2, y2, r2, c1, c2) {
126126
var grd = ctx.createRadialGradient(cx, cy, r1, cx, cy, r2);
127127
grd.addColorStop(0, c1.toString());
128128
grd.addColorStop(1, c2.toString());
129-
ctx.fillStyle = grd;
130-
ctx.fillRect(x1, y1, x2 - x1, y2 - y1);
129+
ctx.fillStyle = grd;
130+
ctx.fillRect(x1, y1, x2 - x1, y2 - y1);
131131
}
132132

133133
function mouseReleased() {

01_P/P_2_0_01/sketch.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,14 @@
3232
function setup() {
3333
createCanvas(550, 550);
3434
strokeCap(SQUARE);
35-
noFill();
3635
}
3736

3837
function draw() {
3938
background(255);
4039
translate(width / 2, height / 2);
4140

42-
var circleResolution = map(mouseY, 0, height, 2, 80);
43-
var radius = mouseX - width / 2 + 0.5;
41+
var circleResolution = int(map(mouseY, 0, height, 2, 80));
42+
var radius = mouseX - width / 2;
4443
var angle = TAU / circleResolution;
4544

4645
strokeWeight(mouseY / 20);

01_P/P_2_0_02/sketch.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function draw() {
4545
translate(width / 2, height / 2);
4646

4747
var circleResolution = int(map(mouseY + 100, 0, height, 2, 10));
48-
var radius = mouseX - width / 2 + 0.5;
48+
var radius = mouseX - width / 2;
4949
var angle = TAU / circleResolution;
5050

5151
beginShape();
@@ -55,6 +55,7 @@ function draw() {
5555
vertex(x, y);
5656
}
5757
endShape();
58+
5859
pop();
5960
}
6061
}

01_P/P_2_0_03/sketch.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function keyReleased() {
6969
if (keyCode == DELETE || keyCode == BACKSPACE) background(0, 0, 100);
7070
if (key == 's' || key == 'S') saveCanvas(gd.timestamp(), 'png');
7171

72-
if (key == '1') strokeColor = color(0, 0, 0, 10);
72+
if (key == '1') strokeColor = color(0, 10);
7373
if (key == '2') strokeColor = color(192, 100, 64, 10);
7474
if (key == '3') strokeColor = color(52, 100, 71, 10);
7575
}

01_P/P_2_1_1_04/data/module_2.svg

+1-1
Loading

01_P/P_2_1_1_04/sketch.js

+10-9
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ var tileCount = 10;
3737

3838
var tileWidth;
3939
var tileHeight;
40-
var shapeSize = 50.0;
40+
var shapeSize = 50;
4141
var newShapeSize = shapeSize;
42-
var shapeAngle = 0.0;
42+
var shapeAngle = 0;
4343
var maxDist;
4444
var currentShape;
4545
var shapes;
@@ -48,17 +48,18 @@ var sizeMode = 0;
4848

4949
function preload() {
5050
shapes = [];
51-
shapes.push(loadImage("data/module_1.svg"));
52-
shapes.push(loadImage("data/module_2.svg"));
53-
shapes.push(loadImage("data/module_3.svg"));
54-
shapes.push(loadImage("data/module_4.svg"));
55-
shapes.push(loadImage("data/module_5.svg"));
56-
shapes.push(loadImage("data/module_6.svg"));
57-
shapes.push(loadImage("data/module_7.svg"));
51+
shapes.push(loadImage('data/module_1.svg'));
52+
shapes.push(loadImage('data/module_2.svg'));
53+
shapes.push(loadImage('data/module_3.svg'));
54+
shapes.push(loadImage('data/module_4.svg'));
55+
shapes.push(loadImage('data/module_5.svg'));
56+
shapes.push(loadImage('data/module_6.svg'));
57+
shapes.push(loadImage('data/module_7.svg'));
5858
}
5959

6060
function setup() {
6161
createCanvas(600, 600);
62+
imageMode(CENTER);
6263
// set the current shape to the first in the array
6364
currentShape = shapes[0];
6465
tileWidth = width / tileCount;

01_P/P_2_1_2_02/sketch.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ function draw() {
7171
var posX = width / tileCount * gridX;
7272
var posY = height / tileCount * gridY;
7373

74-
var shiftX = random(-1, 1) * mouseX / 20;
75-
var shiftY = random(-1, 1) * mouseY / 20;
74+
var shiftX = random(-1, 1) * mouseX / 20;
75+
var shiftY = random(-1, 1) * mouseY / 20;
7676

7777
fill(moduleColorBackground);
7878
ellipse(posX + shiftX, posY + shiftY, moduleRadiusBackground, moduleRadiusBackground);
@@ -139,8 +139,8 @@ function keyReleased() {
139139
}
140140

141141
if (key == '0') {
142-
moduleRadiusBackground = 20;
143-
moduleRadiusForeground = 10;
142+
moduleRadiusBackground = 30;
143+
moduleRadiusForeground = 15;
144144
moduleAlphaBackground = 100;
145145
moduleAlphaForeground = 100;
146146
moduleColorBackground = color(0, 0, 0, moduleAlphaBackground);

01_P/P_2_1_2_03/sketch.js

+1-8
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
'use strict';
3030

3131
var tileCount = 20;
32-
var actRandomSeed = 0;
3332

3433
var moduleColor;
3534
var moduleAlpha = 180;
@@ -45,8 +44,6 @@ function setup() {
4544
function draw() {
4645
clear();
4746

48-
randomSeed(actRandomSeed);
49-
5047
stroke(moduleColor);
5148

5249
for (var gridY = 0; gridY < width; gridY += 25) {
@@ -55,16 +52,12 @@ function draw() {
5552
diameter = diameter / maxDistance * 40;
5653
push();
5754
translate(gridX, gridY, diameter * 5);
58-
rect(0, 0, diameter, diameter); // also nice: ellipse(...)
55+
rect(0, 0, diameter, diameter); // also nice: ellipse(...)
5956
pop();
6057
}
6158
}
6259
}
6360

64-
function mousePressed() {
65-
actRandomSeed = random(100000);
66-
}
67-
6861
function keyReleased() {
6962
if (key == 's' || key == 'S') saveCanvas(gd.timestamp(), 'png');
7063
}

01_P/P_2_1_3_01/sketch.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
var count = 0;
3434
var tileCountX = 10;
3535
var tileCountY = 10;
36-
var tileWidth = 0;
36+
var tileWidth = 0;
3737
var tileHeight = 0;
3838

3939
var colorStep = 15;

0 commit comments

Comments
 (0)