Skip to content

Commit 5523677

Browse files
committed
made grid of flowers
1 parent 60cc510 commit 5523677

File tree

2 files changed

+38
-38
lines changed

2 files changed

+38
-38
lines changed

js/secrets.js

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,3 @@
1-
// We're making 40 flowers
2-
// each is made of 240 pretty points
3-
var colors = [
4-
'tomato',
5-
'lightsalmon',
6-
'plum',
7-
'mediumslateblue'
8-
];
9-
10-
var resolution = 240;
11-
var radius = 200;
12-
var shapes = [];
13-
// Make the flowers
14-
for (var k = 2; k < 44; k++) {
15-
var points = [];
16-
for (var j = 0; j < resolution; j++) {
17-
points[j] = new Two.Anchor();
18-
roseMath(points[j], k, Math.PI * 2 * j / resolution);
19-
}
20-
// Create shape
21-
var shape = new Two.Path(points, true, true);
22-
23-
// Style the shape
24-
var color = colors[Math.floor(Math.random() * colors.length)];
25-
shape.stroke = color;
26-
shape.noFill();
27-
shape.rotation = Math.floor(Math.random() * 4) * Math.PI / 2 + Math.PI / 4;
28-
shapes.push(shape);
29-
}
30-
// two.add(group)
31-
321
// Setup the canvas
332
var two = new Two({
343
fullscreen: true,
@@ -42,26 +11,56 @@ background.fill = 'black';
4211
background.name = 'background';
4312

4413
var container = two.makeGroup(background);
45-
4614
var rows = Math.floor(two.height / 100);
4715
var cols = Math.floor(two.width / 100);
48-
var width = Math.round(two.height / Math.max(rows, cols));
49-
var height = width;
16+
var radius = Math.floor(Math.max(two.width, two.height) / Math.max(rows, cols)) / 2;
17+
18+
var resolution = 240;
19+
var shapes = [];
20+
// We're making 40 flowers
21+
// each is made of 240 pretty points
22+
var colors = ['tomato', 'lightsalmon', 'floralwhite', 'orangered',
23+
'gold', 'red', 'darkorange'];
24+
// Make the flowers
25+
for (var k = 4; k < 20; k++) {
26+
var points = [];
27+
for (var j = 0; j < resolution; j++) {
28+
points[j] = new Two.Anchor();
29+
roseMath(points[j], k, Math.PI * 2 * j / resolution);
30+
}
31+
// Create shape
32+
var shape = new Two.Path(points, true, true);
33+
// shape.step = (Math.floor(Math.random() * 8) / 8) * Math.PI / 60;
34+
// shape.step *= Math.random() > 0.5 ? - 1 : 1;
35+
36+
shapes.push(shape);
37+
}
5038

5139
for (var r = 0; r < rows; r++) {
5240
// even rows have an offset of 0.5
53-
var even = = !!(r % 2);
41+
var even = !!(r % 2);
5442
var vi = r / (rows - 1);
5543
for (var c = 0; c < cols; c++) {
5644
var k = c;
5745
if (even) {
5846
k += 0.5;
5947
// we skip the final col on even rows to avoid overflow
60-
if (c < cols - 1) {
61-
var hi = k /(cols - 1);
62-
48+
if (c >= cols - 1) {
49+
continue;
6350
}
6451
}
52+
var hi = k /(cols - 1);
53+
var s = Math.floor(Math.random() * shapes.length);
54+
var shape = shapes[s].clone();
55+
// Style the shape
56+
var color = colors[Math.floor(Math.random() * colors.length)];
57+
shape.stroke = color;
58+
shape.fill = color;
59+
shape.linewidth = 4;
60+
shape.cap = 'round';
61+
shape.rotation = Math.floor(Math.random() * 4) * Math.PI / 2 + Math.PI / 4;
62+
shape.translation.set(hi * two.width, vi * two.height);
63+
container.add(shape);
6564
}
6665
}
6766

secrets.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<link href="./css/two.css" rel="stylesheet">
55
<script src="./js/jquery-3.3.1.min.js"></script>
66
<script src="./js/two.js"></script>
7+
<script src="./js/url.js"></script>
78
</head>
89
<body>
910

0 commit comments

Comments
 (0)