-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathindex.html
348 lines (292 loc) · 18.7 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>draGGradients -- create custom css radial-gradients dragging your mouse</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="dist/css/style.css">
<link href='http://fonts.googleapis.com/css?family=Lato:100,300,400' rel='stylesheet' type='text/css'>
</head>
<body>
<header class="header">
<a href="#" class="main-logo">dra<small><sup>G</sup><sub>G</sub></small>radients</a>
</header>
<div id="canvas">
<!-- <span draggable="true" class="dragme" id="d1" data-colour="#ffffff" data-deep="50%"></span> -->
<!-- Nodes -->
<a href="#" onclick="return false" id="export_code">
<svg viewBox="0 0 32 32">
<path d="M17.063 0l-.031.156-5 22-.188.844h3.094l.031-.156 5-22 .188-.844h-3.094zm-7.063 3l-.406.313-9 7-.594.469v1.438l.594.469 9 7 .406.313v-3.781l-6.063-4.719 6.063-4.719v-3.781zm12 0v3.781l6.063 4.719-6.063 4.719v3.781l.406-.313 9-7 .594-.469v-1.438l-.594-.469-9-7-.406-.313z"
transform="translate(0 4)" />
</svg>
</a>
<input type="checkbox" id="open_config">
<label for="open_config" class="conf-opener">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" >
<defs>
<path id="cog" d="M507.592,232.111c0,0-9.296-3.496-36.19-5.977c-32.884-3.04-42.804-15.365-53.742-30.709h-0.22 c-1.362-3.647-2.821-7.248-4.427-10.776l0.127-0.127c-3.122-18.58-4.812-34.316,16.292-59.719 c17.25-20.766,21.365-29.818,21.365-29.818c-4.048-10.273-13.781-20.004-13.781-20.004s-9.736-9.734-20.004-13.776 c0,0-9.052,4.104-29.818,21.361c-25.403,21.102-41.14,19.407-59.719,16.292l-0.128,0.126c-3.524-1.605-7.12-3.058-10.775-4.427 v-0.214c-15.345-10.934-27.669-20.865-30.71-53.749c-2.485-26.881-5.976-36.189-5.976-36.189C269.757,0,255.997,0,255.997,0 s-13.766,0-23.887,4.405c0,0-3.498,9.309-5.979,36.189c-3.041,32.884-15.372,42.815-30.709,53.749v0.214 c-3.647,1.369-7.25,2.821-10.776,4.421l-0.122-0.12c-18.579,3.127-34.316,4.815-59.719-16.285 C104.041,65.322,94.977,61.21,94.977,61.21c-10.273,4.053-19.992,13.771-19.992,13.771S65.25,84.724,61.208,94.99 c0,0,4.099,9.053,21.362,29.813c21.1,25.402,19.389,41.139,16.284,59.719l0.128,0.127c-1.607,3.528-3.059,7.129-4.429,10.776H94.34 c-10.927,15.35-20.859,27.669-53.741,30.709c-26.883,2.486-36.202,5.989-36.202,5.989C0.003,242.254,0.003,256,0.003,256 s0,13.771,4.405,23.887c0,0,9.297,3.503,36.185,5.978c32.883,3.041,42.803,15.38,53.747,30.71h0.214 c1.37,3.655,2.821,7.251,4.429,10.776l-0.128,0.127c3.128,18.582,4.815,34.316-16.284,59.719 c-17.252,20.765-21.368,29.829-21.368,29.829c4.059,10.268,13.775,19.993,13.775,19.993s9.742,9.736,20.01,13.771 c0,0,9.047-4.094,29.813-21.357c25.402-21.1,41.145-19.389,59.718-16.288l0.128-0.128c3.526,1.605,7.129,3.052,10.776,4.427v0.22 c15.349,10.928,27.668,20.859,30.709,53.743c2.485,26.881,5.983,36.2,5.983,36.2C242.25,512,255.997,512,255.997,512 s13.771,0,23.889-4.405c0,0,3.504-9.298,5.976-36.189c3.041-32.884,15.379-42.805,30.71-53.743v-0.22 c3.655-1.375,7.251-2.821,10.775-4.427l0.128,0.128c18.579-3.122,34.315-4.812,59.719,16.288 c20.767,17.253,29.832,21.369,29.832,21.369c10.267-4.06,19.99-13.782,19.99-13.782s9.733-9.736,13.781-20.004 c0,0-4.104-9.054-21.365-29.818c-21.104-25.402-19.403-41.137-16.292-59.719l-0.127-0.127c1.605-3.525,3.064-7.121,4.427-10.776 h0.22c10.928-15.341,20.858-27.669,53.742-30.71c26.881-2.485,36.201-5.978,36.201-5.978c4.395-10.127,4.395-23.887,4.395-23.887 S511.997,242.229,507.592,232.111z M255.997,375.727c-66.125,0-119.728-53.602-119.728-119.727s53.603-119.727,119.728-119.727 c66.124,0,119.727,53.602,119.727,119.727S322.121,375.727,255.997,375.727z" fill="#7F7F7F"/>
</defs>
<use xlink:href="#cog" />
</svg>
</label>
<div id="points" class="points">
<table id="coords">
</table>
<div class="add">
<form onsubmit="return false;">
<button id="add_point">+</button>
<input type="text" id="set_colour" class="color {adjust:false,hash:true,caps:false,pickerFaceColor:'transparent',pickerFace:3,pickerBorder:0,pickerInsetColor:'black'}" placeholder="Color (all valid html)">
</form>
</div>
</div>
<div class="other-controls">
<div id="points-op">
</div>
<input id="bg-color" type="text" class="color {hash:true,caps:false,pickerFaceColor:'transparent',pickerFace:3,pickerBorder:0,pickerInsetColor:'black'}" value="#000">
<div id="random">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
<defs>
<path id="shuffle" fill="white" d="M26.125.219c-.075.037-.125.131-.125.281v2.5h-2.5c-1.1 0-1.996.371-2.75 1.125l-4.813 4.813 2.125 2.125 4.813-4.813.031-.031c.091-.061.5-.219.594-.219h2.5v2.5c0 .3.206.387.406.188l5.188-3.875c.2-.2.2-.425 0-.625l-5.188-3.875c-.1-.1-.206-.131-.281-.094zm-26.125 2.781v3h5.5c.1 0 .579.204.625.25l14.625 14.625c.754.754 1.65 1.125 2.75 1.125h2.5v2.5c0 .3.206.387.406.188l5.188-3.875c.2-.2.2-.425 0-.625l-5.188-3.875c-.2-.2-.406-.113-.406.188v2.5h-2.5c-.1 0-.579-.204-.625-.25l-14.625-14.625c-.754-.754-1.65-1.125-2.75-1.125h-5.5zm10.938 10.938l-4.813 4.813c.042-.042-.725.25-.625.25h-5.5v3h5.5c1.085 0 1.889-.279 2.719-1.094l.031-.031 4.813-4.813-2.125-2.125z" />
</defs>
<use xlink:href="#shuffle" />
</svg>
</div>
<select id="presets" onchange="changePreset()">
<option value="" disabled selected >Presets form uigradients</option>
</select>
</div>
<ul class="social">
<li>
<a href="https://github.com/elrumordelaluz/draGGradients" class="link github">
<svg viewBox="0 0 32.6 31.8"><path fill="rgba(255,255,255,0.5)" style="fill-rule:evenodd;clip-rule:evenodd;" d="M16.3,0C7.3,0,0,7.3,0,16.3c0,7.2,4.7,13.3,11.1,15.5c0.8,0.1,1.1-0.4,1.1-0.8c0-0.4,0-1.4,0-2.8c-4.5,1-5.5-2.2-5.5-2.2c-0.7-1.9-1.8-2.4-1.8-2.4c-1.5-1,0.1-1,0.1-1c1.6,0.1,2.5,1.7,2.5,1.7c1.5,2.5,3.8,1.8,4.7,1.4c0.1-1.1,0.6-1.8,1-2.2c-3.6-0.4-7.4-1.8-7.4-8.1c0-1.8,0.6-3.2,1.7-4.4C7.4,10.7,6.8,9,7.7,6.8c0,0,1.4-0.4,4.5,1.7c1.3-0.4,2.7-0.5,4.1-0.5c1.4,0,2.8,0.2,4.1,0.5c3.1-2.1,4.5-1.7,4.5-1.7c0.9,2.2,0.3,3.9,0.2,4.3c1,1.1,1.7,2.6,1.7,4.4c0,6.3-3.8,7.6-7.4,8c0.6,0.5,1.1,1.5,1.1,3c0,2.2,0,3.9,0,4.5c0,0.4,0.3,0.9,1.1,0.8c6.5-2.2,11.1-8.3,11.1-15.5C32.6,7.3,25.3,0,16.3,0z"/></svg>
</a>
</li>
<li>
<form action="http://codepen.io/pen/define" method="POST" target="_blank">
<input type="hidden" id="cdpn-data" name="data">
<input type="submit" id="codepen">
<label onclick="ga('send','event', 'codepen', 'publish');" for="codepen" href="http://github.com/elrumordelaluz/" class="link codepen">
<svg viewBox="0 0 120 120">
<defs>
<g id="cdpn">
<path fill="rgba(255,255,255,0.5)" class="outer-ring" d="M60.048 0C26.884 0 0 26.9 0 60.048s26.884 60 60 60.047c33.163 0 60.047-26.883 60.047-60.047 S93.211 0 60 0z M60.048 110.233c-27.673 0-50.186-22.514-50.186-50.186S32.375 9.9 60 9.9 c27.672 0 50.2 22.5 50.2 50.186S87.72 110.2 60 110.233z"/><path fill="rgba(255,255,255,0.5)" class="inner-box" d="M97.147 48.319c-0.007-0.047-0.019-0.092-0.026-0.139c-0.016-0.09-0.032-0.18-0.056-0.268 c-0.014-0.053-0.033-0.104-0.05-0.154c-0.025-0.078-0.051-0.156-0.082-0.232c-0.021-0.053-0.047-0.105-0.071-0.156 c-0.033-0.072-0.068-0.143-0.108-0.211c-0.029-0.051-0.061-0.1-0.091-0.148c-0.043-0.066-0.087-0.131-0.135-0.193 c-0.035-0.047-0.072-0.094-0.109-0.139c-0.051-0.059-0.104-0.117-0.159-0.172c-0.042-0.043-0.083-0.086-0.127-0.125 c-0.059-0.053-0.119-0.104-0.181-0.152c-0.048-0.037-0.095-0.074-0.145-0.109c-0.019-0.012-0.035-0.027-0.053-0.039L61.817 23.5 c-1.072-0.715-2.468-0.715-3.54 0L24.34 46.081c-0.018 0.012-0.034 0.027-0.053 0.039c-0.05 0.035-0.097 0.072-0.144 0.1 c-0.062 0.049-0.123 0.1-0.181 0.152c-0.045 0.039-0.086 0.082-0.128 0.125c-0.056 0.055-0.108 0.113-0.158 0.2 c-0.038 0.045-0.075 0.092-0.11 0.139c-0.047 0.062-0.092 0.127-0.134 0.193c-0.032 0.049-0.062 0.098-0.092 0.1 c-0.039 0.068-0.074 0.139-0.108 0.211c-0.024 0.051-0.05 0.104-0.071 0.156c-0.031 0.076-0.057 0.154-0.082 0.2 c-0.017 0.051-0.035 0.102-0.05 0.154c-0.023 0.088-0.039 0.178-0.056 0.268c-0.008 0.047-0.02 0.092-0.025 0.1 c-0.019 0.137-0.029 0.275-0.029 0.416V71.36c0 0.1 0 0.3 0 0.418c0.006 0 0 0.1 0 0.1 c0.017 0.1 0 0.2 0.1 0.268c0.015 0.1 0 0.1 0.1 0.154c0.025 0.1 0.1 0.2 0.1 0.2 c0.021 0.1 0 0.1 0.1 0.154c0.034 0.1 0.1 0.1 0.1 0.213c0.029 0 0.1 0.1 0.1 0.1 c0.042 0.1 0.1 0.1 0.1 0.193c0.035 0 0.1 0.1 0.1 0.139c0.05 0.1 0.1 0.1 0.2 0.2 c0.042 0 0.1 0.1 0.1 0.125c0.058 0.1 0.1 0.1 0.2 0.152c0.047 0 0.1 0.1 0.1 0.1 c0.019 0 0 0 0.1 0.039L58.277 96.64c0.536 0.4 1.2 0.5 1.8 0.537c0.616 0 1.233-0.18 1.77-0.537 l33.938-22.625c0.018-0.012 0.034-0.027 0.053-0.039c0.05-0.035 0.097-0.072 0.145-0.109c0.062-0.049 0.122-0.1 0.181-0.152 c0.044-0.039 0.085-0.082 0.127-0.125c0.056-0.055 0.108-0.113 0.159-0.172c0.037-0.045 0.074-0.09 0.109-0.139 c0.048-0.062 0.092-0.127 0.135-0.193c0.03-0.049 0.062-0.098 0.091-0.146c0.04-0.07 0.075-0.141 0.108-0.213 c0.024-0.051 0.05-0.102 0.071-0.154c0.031-0.078 0.057-0.156 0.082-0.234c0.017-0.051 0.036-0.102 0.05-0.154 c0.023-0.088 0.04-0.178 0.056-0.268c0.008-0.045 0.02-0.092 0.026-0.137c0.018-0.139 0.028-0.277 0.028-0.418V48.735 C97.176 48.6 97.2 48.5 97.1 48.319z M63.238 32.073l25.001 16.666L77.072 56.21l-13.834-9.254V32.073z M56.856 32.1 v14.883L43.023 56.21l-11.168-7.471L56.856 32.073z M29.301 54.708l7.983 5.34l-7.983 5.34V54.708z M56.856 88.022L31.855 71.4 l11.168-7.469l13.833 9.252V88.022z M60.048 67.597l-11.286-7.549l11.286-7.549l11.285 7.549L60.048 67.597z M63.238 88.022V73.14 l13.834-9.252l11.167 7.469L63.238 88.022z M90.794 65.388l-7.982-5.34l7.982-5.34V65.388z"/></g>
</defs>
<use xlink:href="#cdpn" />
</svg>
</labela>
</form>
</li>
<li>
<script type="text/javascript" async src="//platform.twitter.com/widgets.js"></script>
<a href="https://twitter.com/intent/tweet?text=draGGradients%20--%20create%20custom%20css%20radial-gradients%20dragging%20your%20mouse.&via=elrumordelaluz&url=http://elrumordelaluz.github.io/draGGradients" class="link twitter">
<svg viewBox="0 0 273.4 222.2"><path fill="rgba(255,255,255,0.5)" d="M273.4,26.3c-10.1,4.5-20.9,7.5-32.2,8.8c11.6-6.9,20.5-17.9,24.7-31C255,10.5,243,15.2,230.2,17.7
C220,6.8,205.4,0,189.3,0c-31,0-56.1,25.1-56.1,56.1c0,4.4,0.5,8.7,1.5,12.8C88,66.5,46.7,44.2,19,10.3c-4.8,8.3-7.6,17.9-7.6,28.2
c0,19.5,9.9,36.6,25,46.7c-9.2-0.3-17.8-2.8-25.4-7c0,0.2,0,0.5,0,0.7c0,27.2,19.3,49.8,45,55c-4.7,1.3-9.7,2-14.8,2c-3.6,0-7.1-0.4-10.6-1c7.1,22.3,27.9,38.5,52.4,39c-19.2,15-43.4,24-69.7,24c-4.5,0-9-0.3-13.4-0.8c24.8,15.9,54.3,25.2,86,25.2c103.2,0,159.6-85.5,159.6-159.6c0-2.4-0.1-4.9-0.2-7.3C256.4,47.4,265.9,37.5,273.4,26.3z"/></svg>
</a>
</li>
<li>
<a href="#" class="link help" id="q-opener">
<svg viewBox="0 0 100 100"><path fill="rgba(255,255,255,0.5)" d="M49.541,0C22.198-0.019,0.027,22.376,0,49.978C0.027,77.621,22.198,100.01,49.541,100c27.353,0.011,49.523-22.379,49.544-50.021C99.064,22.376,76.894-0.019,49.541,0z M54.484,77.194h-9.159v-9.291h9.159V77.194zM57.685,52.033c-2.379,1.557-3.266,3.359-3.242,5.261v7.015l-9.073,0.041V53.876c0.007-3.104,1.024-5.223,3.983-7.142l5.09-3.465c3.264-2.226,3.246-6.714,1.222-8.722c-1.792-1.727-4.796-2.734-8.018-2.103c-5.854,1.202-6.326,5.537-6.312,9.64v1.799h-9.07c0.014-7.711,0.864-11.207,4.905-15.603c4.496-4.957,10.845-5.752,16.699-4.561c5.861,1.236,12.832,6.95,12.842,15.251C66.701,47.308,60.065,50.469,57.685,52.033z"/></svg>
</a>
</li>
</ul>
<pre class="popup" id="popup-code"><code class="code" id="generated_code" data-clipboard-target="generated_code"></code></pre>
<div class="popup" id="popup-q">
<p>
<span href="#" class="main-logo">
dra<small><sup>G</sup><sub>G</sub></small>radients
</span> is as a simple tool to generate and customize multiple css3 radial gradients.
</p>
<p>I get back an old project that uses a multiple gradient jpg image as a background and started to generate the same image in css-only.<br>
Instead of code only this image I finished doing this little stuff. Hope you enjoy it!</p>
<hr>
<p>
<svg xmlns="http://www.w3.org/2000/svg" class="popup-icon" viewBox="0 0 512 512" >
<use xlink:href="#cog" />
</svg>
Toggle main controls (also pressing ESC key) to customize, add and arrange each point generator.
</p>
<p>
Basically the tool works generating radial-gradients from each draggable point, and you could control:<br>
- <strong>The main color.</strong> Wrinting any valid (rgba, rgb, hex, html, etc) color type or picking one from the colorPicker.<br>
- <strong>The position.</strong> Dragging each point in the canvas.<br>
- <strong>The deep.</strong> Sliding or changing the value, you could set the percentage of each radial-gradient.<br>
<p>
<p>
You could also add, delete and arrange each point from the same section.
</p>
<p>
In the bottom left menu, you could:<br>
- <strong>Toggle points.</strong> Switch on/off the points from the main view.<br>
- <strong>Change background.</strong> It modifies the last child of the gradient that works as background.<br>
<svg xmlns="http://www.w3.org/2000/svg" class="popup-icon" viewBox="0 0 32 32" >
<use xlink:href="#shuffle" />
</svg> <strong>Generate random.</strong> Clicking on this button.<br>
- <strong>Presets</strong> from <a href="https://github.com/Ghosh/uiGradients/blob/master/gradients.json">uigradients</a> by Indrashish Ghosh.
</p>
<p>
<svg xmlns="http://www.w3.org/2000/svg" class="popup-icon" viewBox="0 0 120 120" >
<use xlink:href="#cdpn" />
</svg>
You could also create a pen with the generated gradient, clicking on the Codepen logo.
</p>
<hr>
<p class="center">
This simple and little tool was made with ❤ by <a href="http://www.twitter.com/elrumordelaluz">@elrumordelaluz</a>
</p>
</div>
</div>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-55167683-1', 'auto');
ga('send', 'pageview');
</script>
<script type="text/javascript" src="dist/js/main.js"></script>
<script type="text/javascript">
/*
*
* init Gradient
*
*/
// new RadialGradients(2,{
// d1:{ color: '#54a4ff', left: '94%', top: '88%' },
// d2:{ color: '#ff94fb', left: '7%', top: '16%' },
// bg: '#000'
// });
/*
new RadialGradients(5,{
d1:{ color: '#7e75ff', left: '90%', top: '8%', deep: '67%' },
d2:{ color: '#73ffab', left: '52%', top: '43%', deep: '61%' },
d4:{ color: '#ff94fb', left: '4%', top: '90%', deep: '67%' },
d3:{ color: '#ffff4a', left: '9%', top: '17.5%', deep: '58%' },
d5:{ color: '#ff722b', left: '93%', top: '92%', deep: '61%' },
bg: '#fff'
});
*/
function randomInit(num){
switch(num){
case 1:
return new RadialGradients(5,{
d1:{ color: '#7e75ff', left: '90%', top: '8%', deep: '67%' },
d2:{ color: '#73ffab', left: '52%', top: '43%', deep: '61%' },
d4:{ color: '#ff94fb', left: '4%', top: '90%', deep: '67%' },
d3:{ color: '#ffff4a', left: '9%', top: '17.5%', deep: '58%' },
d5:{ color: '#ff722b', left: '93%', top: '92%', deep: '61%' },
bg: '#fff'
});
break;
case 2:
return new RadialGradients(2,{
d1:{ color: '#54a4ff', left: '94%', top: '88%' },
d2:{ color: '#ff94fb', left: '7%', top: '16%' },
bg: '#000'
});
break;
case 3:
return new RadialGradients(2,{
d1:{ color: '#f7ffad', left: '94%', top: '88%' },
d2:{ color: '#73ffab', left: '7%', top: '16%' },
bg: 'rgb(218, 255, 194)'
});
break;
default:
return new RadialGradients(5,{
d1:{ color: '#7e75ff', left: '90%', top: '8%', deep: '67%' },
d2:{ color: '#73ffab', left: '52%', top: '43%', deep: '61%' },
d4:{ color: '#ff94fb', left: '4%', top: '90%', deep: '67%' },
d3:{ color: '#ffff4a', left: '9%', top: '17.5%', deep: '58%' },
d5:{ color: '#ff722b', left: '93%', top: '92%', deep: '61%' },
bg: '#fff'
});
}
}
/*
*
* localStorage Stuff
*
*/
var storage = window['localStorage'];
if (window.localStorage && window.localStorage.getItem('value') /*&& window.localStorage.getItem('value') !== "{}" */) {
stored = JSON.parse(window.localStorage.getItem('value'));
var size = 0;
var storedOptions = {};
if(Object.getOwnPropertyNames(stored).length === 1){
randomInit(Math.floor(Math.random() * 3) + 1);
} else {
for(key in stored){
if (stored.hasOwnProperty(key)) size++;
storedOptions[stored[key].name] = {
left: stored[key].posX,
top: stored[key].posY,
color: stored[key].colour,
deep: stored[key].deep,
}
}
console.log(stored)
storedOptions.bg = stored.bg;
new RadialGradients(size-1, storedOptions);
}
} else {
randomInit(Math.floor(Math.random() * 3) + 1);
}
/*
*
* Random stuff
*
*/
var random = document.getElementById('random');
var genOpt = function(){
var q = Math.floor(Math.random() * 5) + 1;
var opt = {};
for (var i = 1; i <= q; i++) {
opt["d" + i] = {
color: '#'+Math.floor(Math.random()*16777215).toString(16), // http://www.paulirish.com/2009/random-hex-color-code-snippets/
left: (Math.floor(Math.random() * 97) + 1) + "%",
top: (Math.floor(Math.random() * 97) + 1) + "%",
deep: (Math.floor(Math.random() * 97) + 1) + "%"
}
};
opt.bg = '#'+Math.floor(Math.random()*16777215).toString(16);
return new RadialGradients(q, opt);
}
random.onclick = genOpt;
/*
*
* Presets -- Stuff from uigradients
*
*/
var presets = document.getElementById("presets");
function setPreset(name, colour1, colour2){
this.name = name;
this.d1 = {
color: colour1,
left: '2%',
top: (Math.floor(Math.random() * 99) + 1) + "%"
};
this.d2 = {
color: colour2,
left: '98%',
top: (Math.floor(Math.random() * 99) + 1) + "%"
}
}
var request = new XMLHttpRequest();
request.open("GET", "uiGradients.json", false);
request.send(null)
var uiGradients = JSON.parse(request.responseText);
var uiG = {};
for(key in uiGradients){
uiG[uiGradients[key].name] = new setPreset(uiGradients[key].name, uiGradients[key].colour1, uiGradients[key].colour2);
var opt = document.createElement('option');
opt.value = 2;
opt.innerHTML = uiGradients[key].name;
presets.appendChild(opt);
}
function changePreset(){
new RadialGradients(presets.options[presets.selectedIndex].value, uiG[presets.options[presets.selectedIndex].innerHTML])
}
</script>
</body>
</html>