-
Notifications
You must be signed in to change notification settings - Fork 52
/
index.html
597 lines (518 loc) · 22 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
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Colorify.js</title>
<link rel="stylesheet" href="styles/main.css">
<link rel="stylesheet" href="styles/prism.css">
<link rel="icon" type="image/png" href="favicon.png" />
<link rel="shortcut icon" type="image/png" href="favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="description" content="Colorify is a script written in Javascript, that allows you to extract colors from images, and manipulates them."/>
<meta property="fb:app_id" content="966242223397117">
<meta property="og:locale" content="en_US" />
<meta property="og:type" content="website" />
<meta property="og:title" content="Colorify.js - The simple, customizable, tiny javascript color extractor" />
<meta property="og:description" content="Colorify is a script written in Javascript, that allows you to extract colors from images, and manipulates them." />
<meta property="og:url" content="http://colorify.rocks" />
<meta property="og:site_name" content="colorify.js" />
<meta property="og:image" content="http://colorify.rocks/images/og_image.png">
</head>
<!--
Cover photos by order :
https://www.flickr.com/photos/50122097@N00/4236749844
https://www.flickr.com/photos/67961268@N00/283994079
https://www.flickr.com/photos/80547277@N00/365570308
https://www.flickr.com/photos/34409164@N06/3618324994
https://www.flickr.com/photos/56053592@N00/6166620122
-->
<body id="body">
<div id="minHeader">
<header class="hero-header">
<h2><span>C</span><span>o</span><span>l</span><span>o</span><span>r</span><span>i</span><span>f</span><span>y</span><span>.</span><span>j</span><span>s</span></h2>
</header>
<div class="colors"></div>
</div>
<nav>
<div class="control">
<a href="#" id="closeNav"><span class="icon -close"><<</span></a>
</div>
<div class="menu">
<header class="hero-header">
<h1><span>C</span><span>o</span><span>l</span><span>o</span><span>r</span><span>i</span><span>f</span><span>y</span><span>.</span><span>j</span><span>s</span></h1>
</header>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="#documentation">Documentation</a>
<ul class="doc">
<li><a href="#installation">Installation</a></li>
<li><a href="#defaultConfig">Default config</a></li>
<li><a href="#loadImagesDynamically">Load images dynamically</a></li>
<li><a href="#getMainColor">Get main color</a></li>
<li><a href="#getGradient">Get Gradient</a></li>
<li><a href="#lazyReveal">Lazy-reveal</a></li>
<li><a href="#displayOnEvent">Display on event</a></li>
<li><a href="#manipulatesColor">Manipulates color</a></li>
</ul>
</li>
<li><a href="index.html#api">API</a></li>
<li><a href="demo.html">Demo</a></li>
<li class="bottom">
<li><a href="https://github.com/LukyVj/Colorify.js">Github</a></li>
<li><a href="about.html">About</a></li>
</li>
</ul>
<footer>
<div class="share">
<a href="https://twitter.com/share" class="twitter-share-button"{count} data-via="lukyvj" data-size="large" data-hashtags="colorifyJs">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
</div>
<span class="icon -tools">Made</span> with <span class="icon -love">♥</span> by <a href="http://twitter.com/lukyvj"><strong><span>@</span><span>L</span><span>u</span><span>k</span><span>y</span><span>V</span><span>j</span></strong></a>
</footer>
</div>
</nav>
<header id="header" class="">
<span class="orange-block"></span>
<span class="red-block"></span>
<span class="purple-block"></span>
<span class="blue-block"></span>
<span class="green-block"></span>
<div class="hero-header">
<div class="hero-title">
<h1>Colorify.js</h1>
<h2>The simple, customizable, tiny javascript color extractor</span></h2>
<a href="demo.html" class="btn btn-info">Demo</a>
</div>
</div>
</header>
<div class="content">
<div id="home">
<h2>Colorify wtf ?</h2>
<p>Colorify is a script written in Javascript, that allows you to extract colors from images, and manipulates them. From a simple plain color, based on the dominant color, to a beautiful gradient based on the image edges colors, colorify.js will spice up your designs!<p>
<p>In summary, with <strong>Colorify.js</strong>, you can :</p>
<ul>
<li>- Extract the dominant color from an image</li>
<li>- Generate gradients based on the images colors</li>
<li>- Isolate colors and manipulates them everywhere in the page</li>
<li>- Create a <strong>Lazy-revealer</strong> system for your images</li>
<li>- Load image dynamically</li>
<li>- Create any <strong><code>colorify({});</code></strong> instances you want</li>
</ul>
</div>
<div class="alert">
<p>The script works with ANY images format : <strong>png</strong>, <strong>jpeg</strong>, <strong>jpg</strong>, <strong>gif</strong></p>
</div>
<div id="documentation">
<header>
<h2>Documentation</h2>
</header>
<ul>
<li><a href="#installation">Installation</a></li>
<li><a href="#defaultConfig">Default config</a></li>
<li><a href="#loadImagesDynamically">Load images dynamically</a></li>
<li><a href="#getMainColor">Get main color</a></li>
<li><a href="#getGradient">Get Gradient</a></li>
<li><a href="#lazyReveal">Lazy-reveal</a></li>
<li><a href="#displayOnEvent">Display on event</a></li>
<li><a href="#manipulatesColor">Manipulates color</a></li>
</ul>
<section id="installation">
<header class="header">
<h2>Installation</h2>
</header>
<header>
<h3>With Bower</h3>
</header>
<pre class="language-bash"><code class="language-bash">$ bower install colorifyjs</code></pre>
<header>
<h3>Regular install</h3>
</header>
<p>To install colorify, just <a href="https://raw.githubusercontent.com/LukyVj/Colorify.js/master/scripts/colorify.min.js" target="_blank">download</a> the script and load it at the end of your page</p>
<pre><code class="language-markup"> <script src="path/to/colorify.js"></script>
</body></code></pre>
<p>And add the <a href="https://github.com/LukyVj/Colorify.js/tree/master/styles">colorify.css</a> to the head :
<pre><code class="language-markup"><link rel="stylesheet" href="colorify.css"></code></pre>
</p>
</section>
<section id="defaultConfig">
<header class="header">
<h2>Basic config</h2>
</header>
<div class="alert">
<p>Keep in mind that you have to host the images on your server in order to avoid CORS restrictions</p>
</div>
<p>If your page contains only one section where you want to use colorify, you can use the basic config, to do so, you just need to load colorify like this :</p>
<pre><code class="language-javascript">
colorify({});
</code></pre>
<p>Which is the equivalent to :</p>
<pre><code class="language-javascript">colorify({
id: 1,
attr: 'colorify',
container: 'scene',
images: false,
accuracy: 100,
gradient: false,
gradientDirection: 'to bottom right',
padding: 4,
lazyReveal: {
transition: 1,
delay: 1,
steps: false
},
giveTo: false,
revealOn: false
});
</code></pre>
</section>
<section id="loadImagesDynamically">
<header class="header">
<h2>Load image dynamically</h2>
</header>
<p>Sometimes you don't want to bother yourself writing too much code, you may want to load your images dynamically, there is a param for this in colorify.js, the <code>images:</code> parameter, you can pass an array of images to add them on your selected container</p>
<pre class="language-javascript"><code class="language-javascript">colorify({
container: 'dynamic-images',
images: [
'path/to/image1.png',
'path/to/image2.jpg',
'path/to/image3.gif'
]
});
</code></pre>
</section>
<section id="getMainColor">
<header class="header">
<h2>Get main color</h2>
</header>
<p>The main value of colorify is the ability to extract the average color of an image, to do so, call the function like this</p>
<pre class="language-javascript"><code class="language-javascript">colorify({
container: 'colorify-main-color',
accuracy: 10
});
</code></pre>
<p>And for example you've got this markup</p>
<pre><code class="language-markup"><div colorify-main-color>
<img colorify src="image1.jpg">
<img colorify src="image2.jpg">
<img colorify src="image3.jpg">
</div>
</code></pre>
<p>It will result in </p>
<pre class="language-markup"><code class="language-markup"><div colorify-main-color>
<div class="image-container" style="padding: 4px; background-color: rgb(221, 89, 80);">
<img colorify="" src="image1.jpg" class="colorify visible all-loaded" style="transition: all 1000ms ease 1000ms;">
</div>
<div class="image-container" style="padding: 4px; background-color: rgb(63, 147, 220);">
<img colorify="" src="image2.jpg" class="colorify visible all-loaded" style="transition: all 1000ms ease 1000ms;">
</div>
<div class="image-container" style="padding: 4px; background-color: rgb(22, 196, 102);">
<img colorify="" src="image3.jpg" class="colorify visible all-loaded" style="transition: all 1000ms ease 1000ms;">
</div>
</div></code></pre>
<p>Or visually, like this :</p>
<div class="demo-scene" colorify-main-color>
<img colorify src="images/headers/red.jpg">
<img colorify src="images/headers/blue.jpg">
<img colorify src="images/headers/green.jpg">
</div>
</section>
<section id="getGradient">
<header class="header">
<h2>Get a gradient</h2>
</header>
<p>To get a gradient from an image, you write the colorify script with the following parameters and values </p>
<pre class="language-javascript"><code class="language-javascript">colorify({
container: 'colorify-gradient-color',
accuracy: 10,
gradient: true,
gradientDirection: 'to bottom right'
});</code></pre>
<p>With the following markup</p>
<pre><code class="language-markup"><div colorify-gradient-color>
<img colorify src="image1.jpg">
<img colorify src="image2.jpg">
<img colorify src="image3.jpg">
</div></code></pre>
<p>It will result in </p>
<pre class="language-markup"><code class="language-markup"><div colorify-gradient-color>
<div class="image-container" style="padding: 4px; background-image: linear-gradient(to right bottom, rgb(233, 117, 104), rgb(224, 86, 77)); background-color: rgb(221, 89, 80);">
<img src="image1.jpg" colorify="" class="colorify visible all-loaded" style="transition: all 1000ms ease 1000ms;">
</div>
<div class="image-container" style="padding: 4px; background-image: linear-gradient(to right bottom, rgb(61, 157, 220), rgb(75, 152, 222)); background-color: rgb(63, 147, 220);">
<img src="image2.jpg" colorify="" class="colorify visible all-loaded" style="transition: all 1000ms ease 1000ms;">
</div>
<div class="image-container" style="padding: 4px; background-image: linear-gradient(to right bottom, rgb(29, 208, 118), rgb(22, 163, 75)); background-color: rgb(22, 196, 102);">
<img src="image3.jpg" colorify="" class="colorify visible all-loaded" style="transition: all 1000ms ease 1000ms;">
</div>
</div></code></pre>
<p>Or visually, like this :</p>
<div class="demo-scene" colorify-gradient-color>
<img colorifyDemo src="images/headers/purple.jpg">
<img colorifyDemo src="images/headers/blue.jpg">
<img colorifyDemo src="images/headers/green.jpg">
</div>
</section>
<section id="lazyReveal">
<header class="header">
<h2>Lazy reveal</h2>
</header>
<p>This is an interesting aspect of Colorify, and kindof the reason of it's existence. It will allow you to <strong>Lazy-reveal</strong> your images. </p>
<p>We use the term <strong>Lazy-reveal</strong> because it's not "lazy-loading" them per say. Because Colorify is a 100% client script, the only way colorify can process your images is when they are loaded and so, when they are loaded, the script hide them directly, process them and reveal them.</p>
<p>You can set the time you want, and it will reveal each images based on this time.</p>
<header>
<h3>All at once without transition</h3>
</header>
<p>To reveal the images all at once without any transition but a delay</p>
<pre class="language-javascript"><code class="language-javascript">colorify({
container: 'colorify-lazy-reveal',
lazyReveal: {
delay: 3 // 3 second before revealing
}
});</code></pre>
<p>Or visually, like this :</p>
<a href="index.html#rv1" id="rv1" onclick="window.location.reload()" class="btn btn-info">reload</a>
<div class="demo-scene nothover" colorify-lazy-reveal>
<img src="images/headers/purple.jpg">
<img src="images/headers/blue.jpg">
<img src="images/headers/green.jpg">
</div>
<header>
<h3>All at once with transition</h3>
</header>
<p>To reveal the images all at once but with a delay</p>
<pre class="language-javascript"><code class="language-javascript">colorify({
container: 'colorify-lazy-reveal-2',
lazyReveal: {
transition: 2, // The transition occurs for 2 seconds
delay: 3
}
});</code></pre>
<p>Or visually, like this :</p>
<a href="index.html#rv2" id="rv2" onclick="window.location.reload()" class="btn btn-info">reload</a>
<div class="demo-scene nothover" colorify-lazy-reveal-2>
<img src="images/headers/purple.jpg">
<img src="images/headers/blue.jpg">
<img src="images/headers/green.jpg">
</div>
<header>
<h3>All at once with transition steps</h3>
</header>
<p>To reveal the images all at once but with a delay and stepped</p>
<pre class="language-javascript"><code class="language-javascript">colorify({
container: 'colorify-lazy-reveal-3',
lazyReveal: {
transition: 2, // The transition occurs for 2 seconds
delay: 1,
steps: true
}
});</code></pre>
<p>Or visually, like this :</p>
<a href="index.html#rv3" id="rv3" onclick="window.location.reload()" class="btn btn-info">reload</a>
<div class="demo-scene nothover" colorify-lazy-reveal-3>
<img src="images/headers/purple.jpg">
<img src="images/headers/blue.jpg">
<img src="images/headers/green.jpg">
</div>
</section>
<section id="displayOnEvent">
<header class="header">
<h2>Display on event</h2>
</header>
<p>You may want to display the image when a certain element is clicked ? from the body to an ID, you can display the images on any event, with any trigger !</p>
<pre class="language-javascript"><code class="language-javascript">colorify({
container: 'colorify-reveal-on-event',
revealOn: {
event: 'mouseOver',
trigger: '#hover'
}
});</code></pre>
<p>Or visually, like this :</p>
<a href="#event1" id="event1" class="btn btn-info">Hover me</a>
<div class="demo-scene nothover" colorify-reveal-on-event>
<img src="images/headers/purple.jpg">
<img src="images/headers/blue.jpg">
<img src="images/headers/green.jpg">
</div>
</section>
<section id="manipulatesColor">
<header class="header">
<h2>Manipulates color</h2>
</header>
<p>This is a cool aspect of Colorify, you can extract the color from a picture, and give it's value to any element on the page</p>
<p>The <code>property</code> parameter accepts : </p>
<ul>
<li><code>background / background-color </code></li>
<li><code>color</code></li>
<li><code>outline-color</code></li>
<li><code>border-color</code></li>
<li><code>fill</code></li>
<li><code>box-shadow</code></li>
</ul>
<header>
<h3>Give it to the parent</h3>
</header>
<pre class="language-javascript"><code class="language-javascript">colorify({
container: 'colorify-reveal-on-event',
give: {
property: 'background',
target: 'parent'
}
});</code></pre>
<header>
<h3>Give it to children</h3>
</header>
<pre class="language-javascript"><code class="language-javascript">colorify({
container: 'colorify-reveal-on-event',
give: {
property: 'background',
target: 'child'
}
});</code></pre>
<header>
<h3>Give it to the exact element</h3>
</header>
<pre class="language-javascript"><code class="language-javascript">colorify({
container: 'colorify-reveal-on-event',
give: {
property: 'background',
target: '.cover'
}
});</code></pre>
</section>
<section id="api">
<header class="header">
<h2>API</h2>
</header>
<div class="table-api">
<div>
<header>
<h3>Config</h3>
</header>
<pre><code class="language-javascript">colorify({
id: <span class="numeric">numeric</span>,
container: <span class="string">string</span>,
attr: <span class="string">string</span>,
images: <span class="array">array</span>,
accuracy: <span class="numeric">numeric</span>,
color: <span class="boolean">boolean</span>,
gradient: <span class="boolean">boolean</span>,
gradientDirection: <span class="string">string</span>,
padding: <span class="numeric">numeric</span>,
lazyReveal: {
transition: <span class="numeric">numeric</span>,
delay: <span class="numeric">numeric</span>,
steps: <span class="boolean">boolean</span>
},
give: {
property: <span class="string">string</span>,
target: <span class="string">string</span>
},
revealOn: {
trigger: <span class="string">string</span>
event: <span class="string">string</span>
}
});</code></pre>
</div>
<div>
<header>
<h3>Example</h3>
</header>
<pre><code class="language-javascript">colorify({
id: 1,
container: 'colorify-container',
attr: 'colorify',
images: [
'image1.png',
'image2.jpg',
'image3.gif'
],
accuracy: 20,
color: false,
gradient: true,
gradientDirection: 'to top left',
padding: 10,
lazyReveal: {
transition: 1,
delay: 1,
steps: true
},
give: {
property: 'color',
target: '.header h1'
},
revealOn: {
trigger: '#start'
event: 'click'
}
});</code></pre>
</div>
<div>
<header>
<h3>default</h3>
</header>
<pre><code class="language-javascript">colorify({
id: 1,
container: 'colorify',
attr: 'colorify',
images: false,
accuracy: 100,
color: boolean,
gradient: false,
gradientDirection: false,
padding: 4,
lazyReveal: false,
give: false,
revealOn: false
});</code></pre>
</div>
</div>
<span class="cf"></span>
<header>
<h3>Parameters</h3>
</header>
<ul>
<li><code>id</code> : The id of the colorify instance</li>
<li><code>container</code> : The class or id of the container</li>
<li><code>attr</code> : The attribute to use on the images to process, by default, the attribute is the same value as <code>container</code></li>
<li><code>images</code> : Pass an array to it if you need to dynamically add images</li>
<li><code>accuracy</code> : Each visited pixels, the more high the value is, faster the rendering will be.</li>
<li><code>color</code> : Set to true if you want colorify to give you the main color of the image, by default the value is <code>true</code></li>
<li><code>gradient</code> : Set to true if you want colorify to return a gradient instead of a color, by default the value is <code>false</code> </li>
<li><code>gradientDirection</code> : If the <code>gradient</code> value is set to true, use this parameter to define de gradient direction </li>
<li><code>padding</code> : If you want to have padding around your images and fake a colored border effect, give it a value or false, by default the value is <code>4</code></li>
<li><code>lazyReveal</code> :
<ul>
<li><code>transition</code>: Set the time a transition should length, by default, the value is <code>0</code></li>
<li><code>delay</code>: Define the time before the animation should start, by default, the value is <code>0</code></li>
<li><code>steps</code>: Set to true if you want the images to reveal one after an other, by default the value is <code>false</code></li>
</ul>
</li>
<li><code>give</code> :
<ul>
<li><code>property</code>: Define wich property should use the image extracted color, by default the value is <code>false</code></li>
<li><code>target</code>: Give the selector class, id, name or attribute that should use the color with the defined <code>property</code></li>
</ul>
</li>
<li><code>revealOn</code> :
<ul>
<li><code>trigger</code>: The selector class, id, name or attribute that should trigger the reveal, by default the value is <code>false</code></li>
<li><code>event</code>: The event to use to make the animation occur, of course the <code>event</code> will be attached to the <code>trigger</code></li>
</ul>
</li>
</ul>
</section>
</div>
</div>
<script src="scripts/app.js"></script>
<script src="src/colorify.js"></script>
<script src="src/init.js"></script>
<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-42634383-4', 'auto');
ga('send', 'pageview');
</script>
</body>
</html>