-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
executable file
·567 lines (550 loc) · 29.8 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Vavr is an object-functional library for Java 8+">
<meta name="author" content="Daniel Dietrich">
<title>Vavr</title>
<link rel="shortcut icon" href="img/favicon.ico" />
<link rel="apple-touch-icon" href="img/apple-touch-icon-precomposed.png">
<link rel="apple-touch-icon" sizes="72x72" href="img/apple-touch-icon-72x72-precomposed.png">
<link rel="apple-touch-icon" sizes="114x114" href="img/apple-touch-icon-114x114-precomposed.png">
<link rel="apple-touch-icon" sizes="144x144" href="img/apple-touch-icon-144x144-precomposed.png">
<!-- Bootstrap Core CSS -->
<link rel="stylesheet" href="css/bootstrap.min.css" type="text/css">
<!-- Custom Fonts -->
<link rel="stylesheet" href="font-awesome/css/font-awesome.min.css" type="text/css">
<link href="http://fonts.googleapis.com/css?family=Montserrat:400,700" rel="stylesheet" type="text/css">
<link href="http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800" rel="stylesheet" type="text/css">
<link href="http://fonts.googleapis.com/css?family=Merriweather:400,300,300italic,400italic,700,700italic,900,900italic" rel="stylesheet" type="text/css">
<!-- Syntax Highlighting -->
<link rel="stylesheet" href="css/prism.css" type="text/css">
<!-- Vavr CSS // IMPORTANT: LAST CSS LOADED BECAUSE OF OVERRIDES -->
<link rel="stylesheet" href="css/vavr.css" type="text/css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<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-62872702-1', 'auto');
ga('send', 'pageview');
</script>
<style>
html, body {
background: #45484d; /* Old browsers */
background: -moz-radial-gradient(center, ellipse cover, #45484d 0%, #000000 100%); /* FF3.6+ */
background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%,#45484d), color-stop(100%,#000000)); /* Chrome,Safari4+ */
background: -webkit-radial-gradient(center, ellipse cover, #45484d 0%,#000000 100%); /* Chrome10+,Safari5.1+ */
background: -o-radial-gradient(center, ellipse cover, #45484d 0%,#000000 100%); /* Opera 12+ */
background: -ms-radial-gradient(center, ellipse cover, #45484d 0%,#000000 100%); /* IE10+ */
background: radial-gradient(ellipse at center, #45484d 0%,#000000 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#45484d', endColorstr='#000000',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */
text-align:center;
}
[class*="BT"]{width:250px;display:block;position:absolute;padding:0;border-color:#0e0e0e;margin:0 0 10px;line-height:6px;border-style:solid;left:50%;margin-left:-125px;height:60px;}
[class*="BT"] hover{position:absolute;z-index:5;width:246px;margin-left:-370px; transition: all 0.3s ease-out 0s; background: -moz-linear-gradient(45deg, rgba(255,255,255,0) 0%, rgba(135,135,135,0.38) 50%, rgba(255,255,255,0) 100%); /* FF3.6+ */background: -webkit-gradient(linear, left bottom, right top, color-stop(0%,rgba(255,255,255,0)), color-stop(50%,rgba(135,135,135,0.38)), color-stop(100%,rgba(255,255,255,0))); /* Chrome,Safari4+ */background: -webkit-linear-gradient(45deg, rgba(255,255,255,0) 0%,rgba(135,135,135,0.38) 50%,rgba(255,255,255,0) 100%); /* Chrome10+,Safari5.1+ */background: -o-linear-gradient(45deg, rgba(255,255,255,0) 0%,rgba(135,135,135,0.38) 50%,rgba(255,255,255,0) 100%); /* Opera 11.10+ */background: -ms-linear-gradient(45deg, rgba(255,255,255,0) 0%,rgba(135,135,135,0.38) 50%,rgba(255,255,255,0) 100%); /* IE10+ */background: linear-gradient(45deg, rgba(255,255,255,0) 0%,rgba(135,135,135,0.38) 50%,rgba(255,255,255,0) 100%); /* W3C */filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00ffffff', endColorstr='#00ffffff',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */ height:60px;margin-top:-30px;}
[class*="OH"]{overflow:hidden;}
[class*="BR"]{border-width:2px;}
[class*="R6"]{border-radius:6px;}
[class*="NF"]{background:transparent;}
[class*="BT"]:hover hover{ margin-left:123px;}
[class*="TU"]{text-transform:uppercase;}
[class*="PT"]{cursor:pointer;}
[class*="BT"] span{ position:absolute; width:200px; margin-left:-100px; z-index:3;}
canvas{margin: 0;padding: 0;display:block;position:absolute;margin-top:-30px;}
</style>
</head>
<body id="page-top" class="five-years">
<nav id="mainNav" class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand page-scroll" href="#page-top">
<img src="img/vavr-logo-small.png" />
</a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li>
<a class="page-scroll" href="//docs.vavr.io/">Docs</a>
</li>
<li>
<a class="page-scroll" href="#downloads">Downloads</a>
</li>
<li>
<a class="page-scroll" href="#modules">Modules</a>
</li>
<li>
<a class="page-scroll" href="#contact">Contact</a>
</li>
<li>
<a class="page-scroll" href="#supporters">Sponsors</a>
</li>
</ul>
</div>
</div>
</nav>
<header>
<div class="header-content">
<div class="header-content-inner">
<div class="header-content-wrapper">
<h1 class="brand-heading">
<img class="brand-heading" src="img/vavr-logo.png" />
</h1>
<h2 class="brand-heading">
<strong>vavr</strong> - turns java<span class="java-tm">™</span> upside down
</h2>
<p style="font-size: 0.8em; color: rgba(255, 255, 255, 0.5)">
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.<br>
</p>
</div>
<div id="codeCarousel" class="carousel slide" data-ride="carousel">
<div class="carousel-inner" role="listbox">
<div class="item active">
<div class="container">
<div class="carousel-caption">
<h2>⭐️ VAVR HAS A NEW OWNER ⭐️</h2>
<p style="font-size: 1.5em">
Since 2024, <a href="https://github.com/pivovarit">Grzegorz Piwowarek</a> is taking full ownership of the project!
<br><br> Announcement: <a href="https://x.com/pivovarit/status/1814901872005697824">Twitter/X</a>
</p>
</div>
</div>
</div>
<div class="item">
<div class="container">
<div class="carousel-caption">
<p>A new powerful collection library saves us from source.stream().really("?").collect(sink()) pipelines.</p>
<pre><code class="language-java">List<String> names = persons
.filter(p -> p.age > 12)
.map(Person::getName);</code></pre>
</div>
</div>
</div>
<div class="item">
<div class="container">
<div class="carousel-caption">
<p>The functional <em>For</em> is an expression that <em>yields</em> a value. The result is a lazy evaluated collection of elements.</p>
<pre><code class="language-java">Iterator<String> iterator =
For(persons.filter(Person::hasAddress), p ->
For(p.addresses).yield(a ->
p.name + "," + a.street
)
);</code></pre>
</div>
</div>
</div>
<div class="item">
<div class="container">
<div class="carousel-caption">
<p>Vavr and Java are fully interoperable.</p>
<pre><code class="language-java">java.util.List<Integer> result =
iterator.map(String::length).asJava();</code></pre>
</div>
</div>
</div>
<div class="item">
<div class="container">
<div class="carousel-caption">
<p>Structural <em>pattern matching</em> is an easy way to <em>decompose</em> values. The result is ... a value!</p>
<pre><code class="language-java">Number num = Match(personOption).of(
Case($Some($Person($())), person -> 1.0d),
Case($None(), 0)
);</code></pre>
</div>
</div>
</div>
<div class="item">
<div class="container">
<div class="carousel-caption">
<p>The <em>Try</em> monad represents the result state of a computation which may be a <em>Success</em> or a <em>Failure</em>.</p>
<pre><code class="language-java">R result = Try(() -> mightFail())
.recover(x -> ...)
.getOrElse(defaultValue);</code></pre>
</div>
</div>
</div>
<div class="item">
<div class="container">
<div class="carousel-caption">
<p>Java's <em>Optional</em> is not Serializable. We use Vavr's <em>Option</em> for remote operations. Check out our JSON module!</p>
<pre><code class="language-java">class Person implements Serializable {
final Option<String> title;
final String name;
...
}</code></pre>
</div>
</div>
</div>
</div>
<a class="left carousel-control" href="#codeCarousel" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#codeCarousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
<!--
<div>
<a href="#downloads" class="btn btn-primary btn-xl page-scroll">Go Functional</a>
</div>
-->
</div>
</header>
<section class="bg-primary" id="downloads">
<div class="container">
<div class="row">
<div class="col-lg-8 col-lg-offset-2 text-center">
<h2 class="section-heading">Downloads</h2>
<hr class="light">
<p class="text-faded">Vavr <em>core</em> is a functional library for Java. It helps to reduce the amount of code and to increase the robustness. A first step towards functional programming is to start thinking in immutable values. Vavr provides immutable collections and the necessary functions and control structures to operate on these values. The results are beautiful and just work.</p>
</div>
</div>
<div class="row">
<div class="col-lg-3 col-md-6 text-center">
<div class="feature-box-primary">
<a target="_blank" href="http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22io.vavr%22%20a%3A%22vavr%22">
<i class="fa fa-4x fa-cloud-download"></i>
<h3>Binaries</h3>
<p class="text-faded">The Vavr binaries can be found on Maven Central. Beside with Gradle and Maven they work also standalone.</p>
</a>
</div>
</div>
<div class="col-lg-3 col-md-6 text-center">
<div class="feature-box-primary">
<a target="_blank" href="http://docs.vavr.io">
<i class="fa fa-4x fa-book"></i>
<h3>Documentation</h3>
<p class="text-faded">The documentation gives an overview and covers the concepts in depth. It is the best way to get started with Vavr.</p>
</a>
</div>
</div>
<div class="col-lg-3 col-md-6 text-center">
<div class="feature-box-primary">
<a target="_blank" href="http://www.javadoc.io/doc/io.vavr/vavr">
<i class="fa fa-4x fa-file-text"></i>
<h3>API Docs</h3>
<p class="text-faded">The Javadoc can be browsed online.</p>
</a>
</div>
</div>
<div class="col-lg-3 col-md-6 text-center">
<div class="feature-box-primary">
<a target="_blank" href="https://github.com/vavr-io/vavr">
<i class="fa fa-4x fa-github"></i>
<h3>Source Code</h3>
<p class="text-faded">Vavr is open source and can be found on Github. It is distributed under the Apache 2.0 License.</p>
</a>
</div>
</div>
</div>
</div>
</section>
<section class="bg-light" id="modules">
<div class="container">
<div class="row">
<div class="col-lg-8 col-lg-offset-2 text-center">
<h2 class="section-heading">Vavr Modules</h2>
<hr class="primary">
<p>There are several additional modules that group around Vavr's <em>core</em>. All of these are supported by the Vavr open source organization.</p>
</div>
</div>
<div class="row">
<div class="col-md-4 text-center">
<div class="feature-box">
<a target="_blank" href="https://github.com/vavr-io/vavr-gwt">
<i class="fa fa-4x fa-cube" data-wow-delay=".3s"></i>
<h3>vavr-gwt</h3>
<p class="text-muted">GWT module for Vavr.</p>
</a>
</div>
</div>
<div class="col-md-4 text-center">
<div class="feature-box">
<a target="_blank" href="https://github.com/vavr-io/vavr-match">
<i class="fa fa-4x fa-cube" data-wow-delay=".1s"></i>
<h3>vavr-match</h3>
<p class="text-muted">Adds compile time support for Vavr's structural pattern matching feature.</p>
</a>
</div>
</div>
<div class="col-md-4 text-center">
<div class="feature-box">
<a target="_blank" href="https://github.com/vavr-io/vavr-test">
<i class="fa fa-4x fa-cube" data-wow-delay=".1s"></i>
<h3>vavr-test</h3>
<p class="text-muted">A property check framework for random testing of program properties.</p>
</a>
</div>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-md-4 text-center">
<div class="feature-box">
<a target="_blank" href="https://github.com/vavr-io/vavr-jackson">
<i class="fa fa-4x fa-cube" data-wow-delay=".3s"></i>
<h3>vavr-jackson</h3>
<p class="text-muted">Jackson datatype module, the standard JSON library for Java.</p>
</a>
</div>
</div>
<div class="col-md-4 text-center">
<div class="feature-box">
<a target="_blank" href="https://github.com/vavr-io/vavr-gson">
<i class="fa fa-4x fa-cube" data-wow-delay=".3s"></i>
<h3>vavr-gson</h3>
<p class="text-muted">Gson datatype module for Vavr.</p>
</a>
</div>
</div>
<div class="col-md-4 text-center">
<div class="feature-box">
<a target="_blank" href="https://github.com/vavr-io/vavr-render">
<i class="fa fa-4x fa-cube" data-wow-delay=".3s"></i>
<h3>vavr-render</h3>
<p class="text-muted">A rendering library, currently housing tree renderers (ascii and graphviz).</p>
</a>
</div>
</div>
<div class="col-md-4 text-center">
</div>
</div>
</div>
</section>
<aside class="bg-dark call-to-action" id="contact">
<div class="container text-center">
<div class="row">
<div class="col-lg-8 col-lg-offset-2 text-center">
<h2>Please visit our <a target="_blank" href="//blog.vavr.io"><strong>Blog</strong></a> or find us here:</h2>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-md-3"></div>
<div class="col-md-2 text-center">
<div class="feature-box-primary">
<a target="_blank" href="https://gitter.im/vavr-io/vavr">
<i class="fa fa-4x fa-align-right" style="transform: rotate(90deg)"></i>
<h3>Gitter Chat</h3>
</a>
</div>
</div>
<div class="col-md-2 text-center">
<div class="feature-box-primary">
<a target="_blank" href="https://twitter.com/vavr_io">
<i class="fa fa-4x fa-twitter"></i>
<h3>Twitter</h3>
</a>
</div>
</div>
<div class="col-md-2 text-center">
<div class="feature-box-primary">
<a target="_blank" href="mailto:cafebab3@gmail.com">
<i class="fa fa-4x fa-envelope"></i>
<h3>Email</h3>
</a>
</div>
</div>
<div class="col-md-3"></div>
</div>
</div>
</aside>
<aside class="bg-light">
<div class="container">
<div class="row">
<div class="col-lg-8 col-lg-offset-2 text-center">
<h2 class="section-heading">Thank you for using Vavr!</h2>
<hr class="primary">
<img class="img-responsive tweets" src="img/media/tweets.png">
</div>
</div>
</div>
</aside>
<aside id="supporters">
<div class="container text-center">
<div class="row">
<div class="col-lg-8 col-lg-offset-2 text-center">
<h2>Our Sponsors</h2>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-md-4 feature-box">
<div class="supporter-logo">
<a href="https://www.jetbrains.com/idea/" target="_blank">
<img class="supporter-logo idea-logo" src="img/icon_IntelliJIDEA.svg">
</a>
</div>
<p>
<a href="https://www.jetbrains.com/idea/" target="_blank">IntelliJ IDEA</a> is our preferred IDE to develop Vavr.
<a href="https://www.jetbrains.com" target="_blank">JetBrains</a> supports open source projects with its products and makes professional software development a more productive and enjoyable experience.
</p>
</div>
<div class="col-md-4 feature-box">
<div class="supporter-logo">
<a href="http://www.stickerscraft.com/?utm_source=conf_spons&utm_medium=display&utm_campaign=vavr" target="_blank">
<img class="supporter-logo stickers-craft-logo" src="img/stickers-craft-logo_circle_300px.png">
</a>
</div>
<p>
<a href="http://www.stickerscraft.com/?utm_source=conf_spons&utm_medium=display&utm_campaign=vavr" target="_blank">StickersCraft</a> does a great durable and high quality stickers that never fade nor tear off.
They craft stickers with passion. Their main customers come from IT background where there is no compromise for manufacturing quality and speed.
</p>
</div>
<div class="col-md-4 feature-box">
<div class="supporter-logo">
<a href="http://touk.pl" target="_blank">
<img class="supporter-logo touk-logo" src="img/touk.png">
</a>
</div>
<p>
<a href="http://touk.pl" target="_blank">TouK</a> uses and supports Vavr library by promoting it on conferences and helping with graphic design and production of promotional materials.
</p>
<p>
<a href="http://touk.pl" target="_blank">TouK</a> is a software house that leverages functional programming providing custom software where correctness, reliability, and scalability are top requirements.
</p>
</div>
</div>
<div class="row">
<div class="col-md-4 feature-box">
<div class="supporter-logo">
<a href="https://www.yourkit.com/java/profiler/index.jsp" target="_blank">
<img class="supporter-logo yk-logo" src="img/yk_logo.png">
</a>
</div>
<p>
Vavr is using <a href="https://www.yourkit.com/java/profiler/index.jsp" target="_blank">YourKit Java Profiler</a> to analyze the runtime behavior.
YourKit supports open source projects with its full-featured Java Profiler.
YourKit, LLC is the creator of <a href="https://www.yourkit.com/java/profiler/index.jsp" target="_blank">YourKit Java Profiler</a> and <a href="https://www.yourkit.com/.net/profiler/index.jsp" target="_blank">YourKit .NET Profiler</a>, innovative and intelligent tools for profiling Java and .NET applications.
</p>
</div>
</div>
</div>
</aside>
<footer>
<div id="copyright" class="container text-center bg-light">
<div class="row">
<div class="col-lg-8 col-lg-offset-2">
<p>
© 2014-<span id="copyright_year">2016</span> Vavr. All Rights Reserved ·
<a href="disclaimer.html" target="_blank">Legal Disclaimer</a> ·
<a href="contact.html" target="_blank">Contact</a>
<br>
<span class="credit-line">Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.</span>
<br>
<span class="credit-line">Es wird bestätigt, dass "JAVA" eine eingetragene Marke von Oracle America, Inc. ist.</span>
</p>
</div>
</div>
</div>
</footer>
<script src="js/jquery.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery.easing.min.js"></script>
<script src="js/vavr.js"></script>
<script src="js/prism.js"></script>
<script>
$(document).ready(function(){
$('#codeCarousel').carousel({
interval: 8000
});
$("#copyright_year").text(new Date().getFullYear());
// funky button
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame'] || window[vendors[x]+'CancelRequestAnimationFrame'];
}
if (!window.requestAnimationFrame) {
window.requestAnimationFrame = function(callback, element) {
var currTime = new Date().getTime();
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
var id = window.setTimeout(function() { callback(currTime + timeToCall); },
timeToCall);
lastTime = currTime + timeToCall;
return id;
};
}
if (!window.cancelAnimationFrame) {
window.cancelAnimationFrame = function(id) {
clearTimeout(id);
};
}
var startBtn = document.getElementById('funky-button');
var requestID;
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
var posX = 0;
var W = 246;
var H = 60;
var circles = [];
canvas.width = 246;
canvas.height = 60;
function animate() {
requestID = requestAnimationFrame(animate);
ctx.fillStyle = "rgba(0,0,0,0.15)";
ctx.fillRect(0, 0, W, H);
for (var j = 0; j < circles.length; j++){
var c = circles[j];
ctx.beginPath();
ctx.arc(c.x, c.y, c.radius, 0, Math.PI*2, false);
ctx.fillStyle = "rgba("+c.r+", "+c.g+", "+c.b+", 0.5)";
ctx.fill();
c.x += c.vx;
c.y += c.vy;
c.radius -= .02;
if(c.radius < 0) {
circles[j] = new create();
}
}
}
function create() {
this.x = W/2;
this.y = H/2;
this.radius = 2 + Math.random()*3;
this.vx = -5 + Math.random()*10;
this.vy = -5 + Math.random()*10;
this.r = Math.round(Math.random())*255;
this.g = Math.round(Math.random())*255;
this.b = Math.round(Math.random())*255;
}
for (var i = 0; i < 500; i++) {
circles.push(new create());
}
startBtn.addEventListener('mouseover', function(e) {
e.preventDefault();
requestID = requestAnimationFrame(animate);
});
startBtn.addEventListener('mouseout', function(e) {
e.preventDefault();
cancelAnimationFrame(requestID);
e.preventDefault();
posX = 0;
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.fillRect(posX, 0, boxWidth, canvas.height);
});
});
</script>
</body>
</html>