|
14 | 14 | </head>
|
15 | 15 | <body>
|
16 | 16 | <div id="app" v-cloak>
|
17 |
| - <b-field label="Number of bubbles" label-position="inside"> |
| 17 | + <b-field label="Number of bubbles" label-position="inside"> |
18 | 18 | <b-input v-model="bubbles" placeholder="Integer or expression returning integer"></b-input>
|
19 | 19 | </b-field>
|
20 | 20 | <b-field label="Composite Type" label-position="inside">
|
|
25 | 25 | placeholder="Choose an option"
|
26 | 26 | ></b-autocomplete>
|
27 | 27 | </b-field>
|
28 |
| - <b-field label="Shadow blur" label-position="inside"> |
29 |
| - <b-input v-model="shadowBlur" placeholder="Integer or expression returning integer"></b-input> |
30 |
| - </b-field> |
31 |
| - <b-field label="Shadow color" label-position="inside"> |
32 |
| - <b-input v-model="shadowColor" placeholder="Any type of color value"></b-input> |
33 |
| - </b-field> |
34 | 28 | <div class="side-by-side">
|
35 |
| - <b-field label="Grad start color" label-position="inside"> |
36 |
| - <b-input v-model="gradientStart" placeholder="Any type of color value"></b-input> |
| 29 | + <b-field label="Shadow color" label-position="inside"> |
| 30 | + <b-input v-model="shadowColor" placeholder="Any type of color value"></b-input> |
37 | 31 | </b-field>
|
38 |
| - <b-field label="Grad stop color" label-position="inside"> |
39 |
| - <b-input v-model="gradientStop" placeholder="Any type of color value"></b-input> |
40 |
| - </b-field> |
41 |
| - <b-field label="Grad angle" label-position="inside"> |
42 |
| - <b-input v-model="gradientAngle" placeholder="Any number" type="text"></b-input> |
| 32 | + <b-field label="Shadow blur" label-position="inside"> |
| 33 | + <b-input v-model="shadowBlur" placeholder="Integer or expression returning integer"></b-input> |
43 | 34 | </b-field>
|
44 | 35 | </div>
|
| 36 | + <b-field label="Gradient function" label-position="inside"> |
| 37 | + <b-input v-model="gradientFunc" type="textarea" placeholder="Function for drawing gradient"></b-input> |
| 38 | + </b-field> |
45 | 39 | <b-field label="Radius function" label-position="inside">
|
46 | 40 | <b-input v-model="radiusFunc" placeholder="Function for calculating radius"></b-input>
|
47 | 41 | </b-field>
|
|
72 | 66 | selectedCompositeType: "lighter",
|
73 | 67 | shadowBlur: "1",
|
74 | 68 | shadowColor: "#fff",
|
75 |
| - gradientStart: "#2AE", |
76 |
| - gradientStop: "#17B", |
77 |
| - gradientAngle: 45, |
78 | 69 | radiusFunc: "4 + Math.random() * window.innerWidth / 25",
|
79 | 70 | fillFunc: "`hsla(0, 0%, 100%, ${Math.random() * 0.1})`",
|
80 | 71 | angleFunc: "Math.random() * Math.PI * 2",
|
81 | 72 | velocityFunc: "0.1 + Math.random() * 0.5",
|
| 73 | + gradientFunc: ` |
| 74 | +(ctx) => { |
| 75 | + const gradient = ctx.createLinearGradient(0, 0, ctx.canvas.width, ctx.canvas.height); |
| 76 | + gradient.addColorStop(0, "#2AE"); |
| 77 | + gradient.addColorStop(1, "#17B"); |
| 78 | + return gradient; |
| 79 | +}`.trim(), |
82 | 80 | animate: true,
|
83 | 81 | compositeTypes: [
|
84 | 82 | "source-over",
|
|
120 | 118 | compose: this.selectedCompositeType,
|
121 | 119 | shadowBlur: eval(this.shadowBlur),
|
122 | 120 | shadowColor: this.shadowColor,
|
123 |
| - gradientStart: this.gradientStart, |
124 |
| - gradientStop: this.gradientStop, |
125 |
| - gradientAngle: this.gradientAngle, |
| 121 | + gradientFunc: eval(this.gradientFunc), |
126 | 122 | radiusFunc: eval("() => " + this.radiusFunc),
|
127 | 123 | fillFunc: eval("() => " + this.fillFunc),
|
128 | 124 | angleFunc: eval("() => " + this.angleFunc),
|
|
0 commit comments