Commit cb5a52b55aa645ec97e69005be26cc9ecb027e87
test
Michael Williams committed on 2/7/2019, 8:21:48 PMParent: 029395cd787e08e84642683dd7e4b839cfb1a979
Files changed
index.js | changed |
package.json | changed |
package-lock.json | added |
index.js | ||
---|---|---|
@@ -25,17 +25,17 @@ | ||
25 | 25 … | fill: purple; |
26 | 26 … | } |
27 | 27 … | </style> |
28 | 28 … | <g class="gear"> |
29 | - ${range({ start: 0, stop: 1, step: 1/8 }) | |
30 | - .map(index => gearTooth({ | |
31 | - angle: (1/16 + index) * 2 * Math.PI, | |
32 | - offset: offsetRadius, | |
33 | - length: toothLength, | |
34 | - width: toothWidth | |
35 | - })) | |
36 | - .join('\n') | |
37 | - } | |
29 … | + ${range({ start: 0, stop: 1, step: 1 / 8 }) | |
30 … | + .map(index => gearTooth({ | |
31 … | + angle: (1 / 16 + index) * 2 * Math.PI, | |
32 … | + offset: offsetRadius, | |
33 … | + length: toothLength, | |
34 … | + width: toothWidth | |
35 … | + })) | |
36 … | + .join('\n') | |
37 … | +} | |
38 | 38 … | </g> |
39 | 39 … | ` |
40 | 40 … | } |
41 | 41 … | |
@@ -63,16 +63,16 @@ | ||
63 | 63 … | .plant-leaf { |
64 | 64 … | fill: green; |
65 | 65 … | } |
66 | 66 … | </style> |
67 | - ${range({ start: 0, stop: 1, step: 1/8 }) | |
68 | - .map(index => plant({ | |
69 | - size, | |
70 | - angle: index * 2 * Math.PI, | |
71 | - offsetRadius | |
72 | - })) | |
73 | - .join('\n') | |
74 | - } | |
67 … | + ${range({ start: 0, stop: 1, step: 1 / 8 }) | |
68 … | + .map(index => plant({ | |
69 … | + size, | |
70 … | + angle: index * 2 * Math.PI, | |
71 … | + offsetRadius | |
72 … | + })) | |
73 … | + .join('\n') | |
74 … | +} | |
75 | 75 … | ` |
76 | 76 … | } |
77 | 77 … | |
78 | 78 … | function plant ({ size, angle, offsetRadius }) { |
@@ -134,16 +134,16 @@ | ||
134 | 134 … | .moon-back { |
135 | 135 … | fill: purple; |
136 | 136 … | } |
137 | 137 … | </style> |
138 | - ${range({ start: 0, stop: 1, step: 1/8 }) | |
139 | - .map(index => moon({ | |
140 | - radius: moonRadius, | |
141 | - center: rotate({ angle: index * 2 * Math.PI, point: { x: 0, y: offsetRadius } }), | |
142 | - phase: index | |
143 | - })) | |
144 | - .join('\n') | |
145 | - } | |
138 … | + ${range({ start: 0, stop: 1, step: 1 / 8 }) | |
139 … | + .map(index => moon({ | |
140 … | + radius: moonRadius, | |
141 … | + center: rotate({ angle: index * 2 * Math.PI, point: { x: 0, y: offsetRadius } }), | |
142 … | + phase: index | |
143 … | + })) | |
144 … | + .join('\n') | |
145 … | +} | |
146 | 146 … | ` |
147 | 147 … | } |
148 | 148 … | |
149 | 149 … | // inspired by https://github.com/tingletech/moon-phase |
@@ -155,18 +155,18 @@ | ||
155 | 155 … | // zero and one are both new moon; 0.50 is full moon |
156 | 156 … | if (phase <= 0.25) { |
157 | 157 … | sweep = [ 1, 0 ] |
158 | 158 … | mag = 1 - phase * 4 |
159 | - } else if (phase <= 0.50) { | |
159 … | + } else if (phase <= 0.50) { | |
160 | 160 … | sweep = [ 0, 0 ] |
161 | 161 … | mag = (phase - 0.25) * 4 |
162 | 162 … | } else if (phase <= 0.75) { |
163 | 163 … | sweep = [ 1, 1 ] |
164 | 164 … | mag = 1 - (phase - 0.50) * 4 |
165 | 165 … | } else if (phase <= 1) { |
166 | 166 … | sweep = [ 0, 1 ] |
167 | 167 … | mag = (phase - 0.75) * 4 |
168 | - } else { | |
168 … | + } else { | |
169 | 169 … | throw new Error(`unexpected moon phase: ${phase}`) |
170 | 170 … | } |
171 | 171 … | |
172 | 172 … | // http://www.w3.org/TR/SVG/paths.html#PathDataEllipticalArcCommands |
@@ -191,18 +191,17 @@ | ||
191 | 191 … | </g> |
192 | 192 … | ` |
193 | 193 … | } |
194 | 194 … | |
195 | -function rotate ({ center = { x: 0, y: 0}, angle, point }) { | |
195 … | +function rotate ({ center = { x: 0, y: 0 }, angle, point }) { | |
196 | 196 … | const a = Math.atan2(point.y - center.y, point.x - center.x) |
197 | 197 … | const r = Math.sqrt(Math.pow(point.x - center.x, 2) + Math.pow(point.y - center.y, 2)) |
198 | 198 … | return { |
199 | 199 … | x: r * Math.cos(a + angle), |
200 | 200 … | y: r * Math.sin(a + angle) |
201 | 201 … | } |
202 | 202 … | } |
203 | 203 … | |
204 | - | |
205 | 204 … | // https://stackoverflow.com/a/44957114 |
206 | 205 … | function range ({ start = 0, stop, step = 1 }) { |
207 | 206 … | return Array(Math.ceil((stop - start) / step)) |
208 | 207 … | .fill(start).map((x, y) => x + y * step) |
package.json | ||
---|---|---|
@@ -27,10 +27,9 @@ | ||
27 | 27 … | ] |
28 | 28 … | } |
29 | 29 … | }, |
30 | 30 … | "standard": { |
31 | - "globals": [ | |
32 | - ] | |
31 … | + "globals": [] | |
33 | 32 … | }, |
34 | 33 … | "repository": { |
35 | 34 … | "type": "git", |
36 | 35 … | "url": "git+https://github.com/ahdinosaur/solarpunk-icon.git" |
package-lock.json | ||
---|---|---|
The diff is too large to show. Use a local git client to view these changes. Old file size: 0 bytes New file size: 355228 bytes |
Built with git-ssb-web