Skip to content

Commit e889868

Browse files
committed
Added ability for custom functions
1 parent ce37e6c commit e889868

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

css-backgrounds/spread-radius.html

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,19 @@ <h1>box-shadow spread rounding</h1>
5959

6060
<label>
6161
Algorithm:
62-
<select id="algorithm" size="4">
62+
<select id="algorithm" size="6">
6363
<option value="old">Old</option>
6464
<option value="arc">Arc</option>
6565
<option value="hyp">Hyperbolic</option>
6666
<option value="cubic" selected>Cubic</option>
67+
<option value="linear">Linear</option>
68+
<option value="custom">Custom</option>
6769
</select>
6870
</label>
71+
72+
<label>f(x) =
73+
<input id="custom" value="x < 1? 1-(x-1)*(x-1) : 1" />
74+
</label>
6975
</form>
7076

7177
<div class="box">
@@ -134,6 +140,19 @@ <h1>box-shadow spread rounding</h1>
134140

135141
cubic: function(x) {
136142
return x < 1? 1 + Math.pow(x-1, 3) : 1;
143+
},
144+
145+
linear: function(x) {
146+
return x < 1? x : 1;
147+
},
148+
149+
custom: function (x) {
150+
try {
151+
return eval(custom.value);
152+
} catch(e) {
153+
console.log(e);
154+
return 0;
155+
}
137156
}
138157
};
139158

@@ -172,11 +191,15 @@ <h1>box-shadow spread rounding</h1>
172191
algorithm.onchange = function () {
173192
Box.ratio = Box.ratios[this.value];
174193

194+
custom.parentNode.style.visibility = this.value == 'custom'? '' : 'hidden';
195+
175196
Box.redrawAll();
176197
};
177198

178199
algorithm.onchange();
179200

201+
custom.oninput = Box.redrawAll;
202+
180203
//constant.oninput = function() {
181204
// Box.constant = +this.value;
182205
//

0 commit comments

Comments
 (0)