|
85 | 85 | {width: 500, height: 50, spread: 30, borderRadius: "1px 1px 49px 49px"},
|
86 | 86 | {width: 500, height: 50, spread: 30, borderRadius: "50%"},
|
87 | 87 | {width: 500, height: 50, spread: 30, borderRadius: "50% 50% 1px 50%"},
|
| 88 | + {width: 0, height: 0, spread: 30, borderRadius: "50px 0px 0px 0px"}, |
88 | 89 | ];
|
89 | 90 |
|
90 | 91 | function show({incremental = false} = {}) {
|
|
134 | 135 | outer.style.width = "max-content";
|
135 | 136 | container.appendChild(outer);
|
136 | 137 | outer.style.borderRadius = resolve(testCase, inner);
|
| 138 | + if (!outer.style.borderRadius) { |
| 139 | + outer.style.outline = "solid red"; |
| 140 | + } |
137 | 141 | }
|
138 | 142 | }
|
139 | 143 | }
|
|
169 | 173 | };
|
170 | 174 |
|
171 | 175 | // Normalize radii that add up to > 100%
|
172 |
| - const f = Math.min( |
| 176 | + let f = Math.min( |
173 | 177 | testCase.width / (radii.topLeft[0] + radii.topRight[0]),
|
174 | 178 | testCase.width / (radii.bottomLeft[0] + radii.bottomRight[0]),
|
175 | 179 | testCase.height / (radii.topLeft[1] + radii.bottomLeft[1]),
|
176 | 180 | testCase.height / (radii.topRight[1] + radii.bottomRight[1])
|
177 | 181 | );
|
| 182 | + if (Number.isNaN(f)) { |
| 183 | + f = 0; |
| 184 | + } |
178 | 185 | if (f < 1) {
|
179 | 186 | for (let corner in radii) {
|
180 | 187 | radii[corner] = radii[corner].map(v => v * f);
|
181 | 188 | }
|
182 | 189 | }
|
183 | 190 |
|
184 | 191 | let r = {
|
185 |
| - topLeft: radii.topLeft, |
186 |
| - topRight: radii.topRight, |
187 |
| - bottomLeft: radii.bottomLeft, |
188 |
| - bottomRight: radii.bottomRight, |
| 192 | + topLeft: [], |
| 193 | + topRight: [], |
| 194 | + bottomLeft: [], |
| 195 | + bottomRight: [], |
189 | 196 | };
|
190 | 197 | const algorithm = document.forms[0].elements.algorithm.value;
|
191 | 198 |
|
|
195 | 202 |
|
196 | 203 | let percentageSameAxis = {};
|
197 | 204 |
|
198 |
| - for (let corner in r) { |
199 |
| - let c = r[corner]; |
| 205 | + for (let corner in radii) { |
| 206 | + let c = radii[corner]; |
200 | 207 | let [rx, ry] = c;
|
201 | 208 |
|
202 | 209 | let px = rx / width;
|
|
207 | 214 |
|
208 | 215 | let currentSpec = {};
|
209 | 216 |
|
210 |
| - for (let corner in r) { |
211 |
| - currentSpec[corner] = r[corner].map(value => { |
| 217 | + for (let corner in radii) { |
| 218 | + currentSpec[corner] = radii[corner].map(value => { |
212 | 219 | if (value >= testCase.spread) {
|
213 | 220 | return value + testCase.spread;
|
214 | 221 | }
|
|
218 | 225 | }
|
219 | 226 |
|
220 | 227 | if (algorithm === "increase-by-spread") {
|
221 |
| - for (let corner in r) { |
222 |
| - r[corner] = r[corner].map(v => v + testCase.spread); |
| 228 | + for (let corner in radii) { |
| 229 | + r[corner] = radii[corner].map(v => v + testCase.spread); |
223 | 230 | }
|
224 | 231 | }
|
225 | 232 | else if (algorithm === "old-spec") {
|
226 |
| - for (let corner in r) { |
227 |
| - let c = r[corner]; |
| 233 | + for (let corner in radii) { |
| 234 | + let c = radii[corner]; |
228 | 235 | r[corner] = c[0] + c[1] === 0 ? [0, 0] : [c[0] + testCase.spread, c[1] + testCase.spread];
|
229 | 236 | }
|
230 | 237 | }
|
|
240 | 247 | let spreadHeight = height + testCase.spread * 2;
|
241 | 248 |
|
242 | 249 | let straights = {
|
243 |
| - top: width - r.topLeft[0] - r.topRight[0], |
244 |
| - bottom: width - r.bottomLeft[0] - r.bottomRight[0], |
245 |
| - left: height - r.topLeft[1] - r.bottomLeft[1], |
246 |
| - right: height - r.topRight[1] - r.bottomRight[1], |
| 250 | + top: width - radii.topLeft[0] - radii.topRight[0], |
| 251 | + bottom: width - radii.bottomLeft[0] - radii.bottomRight[0], |
| 252 | + left: height - radii.topLeft[1] - radii.bottomLeft[1], |
| 253 | + right: height - radii.topRight[1] - radii.bottomRight[1], |
247 | 254 | }
|
248 | 255 |
|
249 | 256 | function getStraightSegment(corner, axis) {
|
|
259 | 266 | return straights[parts[axis]];
|
260 | 267 | }
|
261 | 268 |
|
262 |
| - for (let corner in r) { |
263 |
| - r[corner] = r[corner].map((value, axis) => { |
| 269 | + for (let corner in radii) { |
| 270 | + r[corner] = radii[corner].map((value, axis) => { |
264 | 271 | let straight = getStraightSegment(corner, axis);
|
265 | 272 | let ratio = straight / value;
|
266 | 273 | ratio = Math.min(ratio, 1);
|
|
0 commit comments