-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
814 lines (697 loc) · 27.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
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
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="keywords" content="">
<title>Exaloop</title>
<!-- Styles -->
<link href="assets/css/page.min.css" rel="stylesheet">
<!-- Favicons -->
<link rel="apple-touch-icon" href="assets/img/apple-touch-icon.png">
<link rel="icon" href="assets/img/favicon.png">
<!-- Open Graph Tags -->
<meta property="og:type" content="website">
<meta property="og:title" content="Exaloop">
<meta property="og:description" content="Modernizing high-performance computing.">
<meta property="og:image" content="assets/img/logo-open-graph.png">
<meta property="og:url" content="https://exaloop.io/">
<meta name="twitter:card" content="summary_large_image">
<script src="https://kit.fontawesome.com/5263d9c177.js" crossorigin="anonymous"></script>
<link rel="stylesheet" href="assets/css/styles/routeros.min.css">
<script src="assets/js/highlight.min.js"></script>
<script>hljs.highlightAll();</script>
<style type="text/css" media="screen">
html, body, canvas {
max-width: 100%;
overflow-x: hidden;
}
.image.round img {
border-radius: 100%;
border: 0px solid;
border-color: #3c8fd9;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}
.image.icon img {
border-radius: 100%;
border: 5px solid;
background-color: #ffffff;
border-color: #ffffff;
}
.snippet {
background-color: transparent;
border-radius: 10px;
padding: 0px;
border: none;
box-shadow: none;
}
.fade-in-text {
animation: fadeIn linear 3s;
-webkit-animation: fadeIn linear 3s;
-moz-animation: fadeIn linear 3s;
-o-animation: fadeIn linear 3s;
-ms-animation: fadeIn linear 3s;
}
@keyframes fadeIn {
0% {opacity:0;}
100% {opacity:1;}
}
@-moz-keyframes fadeIn {
0% {opacity:0;}
100% {opacity:1;}
}
@-webkit-keyframes fadeIn {
0% {opacity:0;}
100% {opacity:1;}
}
@-o-keyframes fadeIn {
0% {opacity:0;}
100% {opacity:1;}
}
@-ms-keyframes fadeIn {
0% {opacity:0;}
100% {opacity:1;}
}
pre > code {
font-family: Hack, monospace;
font-size: 20px;
}
.btn {
text-transform: none;
}
.header {
background-color: #2d42e4;
}
#head-canvas {
position: absolute;
z-index: 1;
}
.snippet-info {
font-size: 20px;
}
</style>
</head>
<body>
<!-- Navbar -->
<div id="head">
<canvas class="cooleffect" id="head-canvas"></canvas>
<div>
<nav class="navbar navbar-expand-lg navbar-light navbar-stick-dark" data-navbar="sticky">
<div class="container">
<div class="navbar-left">
<button class="navbar-toggler" type="button">☰</button>
<a class="navbar-brand" href="index.html">
<img class="logo-dark" src="assets/img/logo-dark.svg" alt="logo">
<img class="logo-light" src="assets/img/logo-light.svg" alt="logo">
</a>
</div>
<section class="navbar-mobile">
<span class="navbar-divider d-mobile-none"></span>
<nav class="nav nav-navbar">
<a class="nav-link" href="https://docs.exaloop.io">Docs</a>
<a class="nav-link" href="https://blog.exaloop.io">Blog</a>
<a class="nav-link" href="https://docs.exaloop.io/codon/general/faq">FAQ</a>
<a class="nav-link" href="benchmarks.html">Benchmarks</a>
<a class="nav-link" href="about.html">About</a>
<a class="nav-link" href="mailto:info@exaloop.io">Contact</a>
</nav>
</section>
<a class="btn btn-sm btn-round btn-dark" href="https://github.com/exaloop"><i class="fa fa fa-github"></i> GitHub</a>
</div>
</nav><!-- /.navbar -->
<!-- Header -->
<header class="header text-white pt-12 pb-10">
<div class="container">
<div class="fade-in-text">
<h1 class="display-4">Modernizing high-performance computing.</h1>
</div>
</div>
</header><!-- /.header -->
</div>
</div>
<!-- Main Content -->
<main class="main-content">
<section class="section">
<div class="container">
<header class="section-header" id="technology">
<small>Introducing</small>
<br />
<img src="assets/img/codon.png" width="250" />
</header>
<div class="row">
<div class="col-sm-4 mx-auto text-center">
<div class="image round">
<img src="assets/img/info/python.svg" alt="python">
</div>
<br />
<h3>Ease of Python</h3>
<p style="font-size:20px">
Codon adopts <a href="https://python.org" target="_blank">Python</a>'s syntax, features and libraries, and is fully
interoperable with Python
</p>
</div>
<div class="col-sm-4 mx-auto text-center">
<div class="image round">
<img src="assets/img/info/llvm.svg" alt="llvm">
</div>
<br />
<h3>Performance of C</h3>
<p style="font-size:20px">
Codon uses <a href="https://llvm.org" target="_blank">LLVM</a> to compile to native machine code,
without vanilla Python's runtime overhead
</p>
</div>
<div class="col-sm-4 mx-auto text-center">
<div class="image round">
<img src="assets/img/info/domains.svg" alt="domains">
</div>
<br />
<h3>Extensible</h3>
<p style="font-size:20px">
Codon is fully extensible via plugins that can add new libraries, optimizations or even
syntax
</p>
</div>
</div>
</div>
</section>
<section class="section bg-gray">
<div class="container">
<header class="section-header" id="nutshell">
<small>Under the Hood</small>
<br />
<h1>How it Works</h1>
</header>
<div class="row" data-aos="fade-in">
<img src="assets/img/info/pipeline.svg" alt="codon-pipeline" width="100%">
</div>
</div>
</section>
<section class="section overflow-hidden pb-0">
<div class="container">
<header class="section-header">
<small>See it in action</small>
<br />
<h2>Codon at a Glance</h2>
</header>
<ul class="nav nav-tabs-outline">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#snippet-basics">Basics</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#snippet-interop">Interop</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#snippet-parallel">Parallel</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#snippet-types">Types</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#snippet-decorator">Decorator</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#snippet-gpu">GPU</a>
</li>
</ul>
<br><br>
<div class="tab-content text-left" data-aos="fade-in">
<div class="tab-pane fade show active" id="snippet-basics">
<pre class="snippet"><code class="language-python"># Lists, dictionaries, and everything else you'd expect
fruits = ['Banana', 'Apple', 'Lime']
prices = {'Banana': 0.25, 'Apple': 0.99, 'Lime': 0.39}
# Python's simple control flow
for fruit in fruits:
print(f'{fruit}s cost ${prices[fruit]}')
# Easy and straightforward, just like Python
cart = ['Banana']*10 + ['Apple']*5 + ['Lime']*15
total = sum(prices[fruit] for fruit in cart)
print(f'Total: ${total}')</code></pre>
<p class="snippet-info">
<b>Python's simple, intuitive syntax</b>
If you know Python, there's no learning curve to using Codon. Same syntax, semantics and
builtin modules. Unlike Python, Codon compiles to native code and runs orders of magnitude
faster. <b><a href="https://docs.exaloop.io/codon/language/basics" target="_blank">Learn more...</a></b>
</p>
</div>
<div class="tab-pane fade" id="snippet-interop">
<pre class="snippet"><code class="language-python">from random import randint
def roll():
return randint(1, 6)
# Compute in Codon...
rolls = [sum(roll() for _ in range(10)) for _ in range(1000)]
# ... then plot in Python / matplotlib
from python import matplotlib.pyplot as plt
n, bins, patches = plt.hist(rolls)
plt.show()</code></pre>
<p class="snippet-info">
<b>Import and use your favorite Python libraries</b>
Codon has out-of-the-box interoperability with Python, meaning you can take full advantage
of Python's expansive ecosystem of libraries, from NumPy to Pandas to Tensorflow to Matplotlib.
<b><a href="https://docs.exaloop.io/codon/interoperability/python" target="_blank">Learn more...</a></b>
</p>
</div>
<div class="tab-pane fade" id="snippet-parallel">
<pre class="snippet"><code class="language-python">def is_prime(n):
return sum(1 for i in range(2, n) if n % i == 0) == 0
total, limit = 0, 100000
# The following loop's iterations are executed by multiple threads
@par
for i in range(2, 100000):
if is_prime(i):
total += 1 # Codon turns this into a parallel reduction
print(f'There are {total} primes less than {limit}')</code></pre>
<p class="snippet-info">
<b>Seamless parallelism via <a href="https://openmp.org" target="_blank">OpenMP</a></b>
Since Codon is implemented from the ground up as a new compiler, it doesn't have any of Python's
multithreading limitations. Codon has full-fledged OpenMP support to take advantage of multiple
cores. <b><a href="https://docs.exaloop.io/codon/advanced/parallel" target="_blank">Learn more...</a></b>
</p>
</div>
<div class="tab-pane fade" id="snippet-types">
<pre class="snippet"><code class="language-python"># Optional type annotations
def hypot(a: float, b: float) -> float:
return (a**2 + b**2) ** .5
# Calling hypot('x', 'y') gives "error: cannot unify str and float"
# Generic type parameters can convey fine-grained typing constraints
def display[T](v: List[T]):
for a in v:
print(a)
# Calling display('hello') gives "error: cannot unify str and List[T]"</code></pre>
<p class="snippet-info">
<b>Optional type annotations à la <a href="http://mypy-lang.org" target="_blank">mypy</a></b>
Codon adopts the type annotation syntax introduced by newer Python versions. While type annotations
can be used to enforce types statically, they are completely optional and can be inferred automatically.
<b><a href="https://docs.exaloop.io/codon/language/functions" target="_blank">Learn more...</a></b>
</p>
</div>
<div class="tab-pane fade" id="snippet-decorator">
<pre class="snippet"><code class="language-python">import codon
# The following function will be compiled and optimized by Codon
@codon.jit
def fib(n):
if n <= 2:
return 1
else:
return fib(n - 1) + fib(n - 2)
# The call to 'fib' gets routed to Codon
print(fib(40))</code></pre>
<p class="snippet-info">
<b>Embeddable in Python apps with a simple decorator</b>
Within larger Python codebases, Codon can be integrated on a per-function basis via the <code>@codon.jit</code>
decorator, to compile and optimize performance-critical segments of code.
<b><a href="https://docs.exaloop.io/codon/interoperability/decorator" target="_blank">Learn more...</a></b>
</p>
</div>
<div class="tab-pane fade" id="snippet-gpu">
<pre class="snippet"><code class="language-python">import gpu
# Codon will compile the following function to PTX code for the GPU
@gpu.kernel
def hello(a, b, c):
i = gpu.thread.x
c[i] = b[i] + c[i]
N = 10
a, b, c = [i for i in range(N)], [2*i for i in range(N)], [0] * N
# Kernel functions take additional 'grid' and 'block' parameters
hello(a, b, c, grid=1, block=N)</code></pre>
<p class="snippet-info">
<b>Integrated GPU backend</b>
Codon's GPU backend lets you write and execute GPU kernels without having to resort to CUDA. Kernels can
either be explicit via <code>@gpu.kernel</code> or implicit with GPU-parallelized loops via <code>@par(gpu=True)</code>.
<b><a href="https://docs.exaloop.io/codon/advanced/gpu" target="_blank">Learn more...</a></b>
</p>
</div>
</div>
</div>
</section>
<section class="section bg-gray">
<div class="container">
<header class="section-header">
<small>Covering a Range of Industries</small>
<h1>Applications</h1>
</header>
<div class="row">
<div class="col-lg-6 mx-auto text-center" data-aos="fade-in">
<i class="fa-solid fa-dna fa-5x fa-fw" style="color:#c5c5c5"></i>
<br />
<h3>Bio</h3>
<p style="font-size:20px">
Codon was initially developed to solve computing challenges in genomics and bioinformatics
(see <a href="https://seq-lang.org">Seq</a>), areas we continue to focus on heavily.
</p>
</div>
<div class="col-lg-6 mx-auto text-center" data-aos="fade-in">
<i class="fa-solid fa-piggy-bank fa-5x fa-fw" style="color:#c5c5c5"></i>
<br />
<h3>Finance</h3>
<p style="font-size:20px">
Codon's finance module accelerates and simplifies testing new trading strategies on large
historical datasets.
</p>
</div>
</div>
<br />
<div class="row">
<div class="col-lg-6 mx-auto text-center" data-aos="fade-in">
<i class="fa-solid fa-box fa-5x fa-fw" style="color:#c5c5c5"></i>
<br />
<h3>Libraries</h3>
<p style="font-size:20px">
Codon-native versions of popular Python libraries offer enhanced performance, better memory
footprints and library-specific compiler optimizations.
</p>
</div>
<div class="col-lg-6 mx-auto text-center" data-aos="fade-in">
<i class="fa-solid fa-microchip fa-5x fa-fw" style="color:#c5c5c5"></i>
<br />
<h3>GPUs</h3>
<p style="font-size:20px">
Codon allows GPU kernels to be written in plain Python, and facilitates GPU programming
without having to resort to CUDA.
</p>
</div>
</div>
<br />
<div class="row">
<div class="col-lg-6 mx-auto text-center" data-aos="fade-in">
<i class="fa-brands fa-chrome fa-5x fa-fw" style="color:#c5c5c5"></i>
<br />
<h3>WebAssembly</h3>
<p style="font-size:20px">
Codon can target WebAssembly, allowing Python/Codon programs to run seamlessly in the browser.
</p>
</div>
<div class="col-lg-6 mx-auto text-center" data-aos="fade-in">
<i class="fa-solid fa-plus fa-5x fa-fw" style="color:#c5c5c5"></i>
<br />
<h3>More</h3>
<p style="font-size:20px">
We're actively developing modules for a wide range of industries and sectors.
Stay tuned for more!
</p>
</div>
</div>
</div>
</section>
<section class="section">
<div class="container">
<header class="section-header" id="jupyter">
<small>Codon for Data Science</small>
<br />
<h1>
<img src="assets/img/info/codon-small.svg" alt="codon-logo" width="15%">
×
<img src="assets/img/info/jupyter.svg" alt="jupyter-logo" width="15%">
</h1>
</header>
<div class="row">
<div class="col-lg-10 mx-auto text-center" data-aos="slide-up">
<video width="100%" controls autoplay="autoplay" loop playsinline>
<source src="assets/video/codon-jupyter.mp4" type="video/mp4">
<p>(Your browser doesn't support HTML5 video.)</p>
</video>
</div>
</div>
</div>
</section>
<section id="section-pricing" class="section bg-gray">
<div class="container">
<header class="section-header">
<small>Using our Software</small>
<br />
<h1>Exaloop & You</h1>
</header>
<div class="row gap-y text-center">
<div class="col-md-6" data-aos="fade-in">
<div class="pricing-1 popular">
<p class="plan-name">Non-Production Use</p>
<br>
<h2 class="price">free</h2>
<p class="small text-lighter">Forever!</p>
<div class="text-muted">
<small>Full Codon compiler and software stack</small><br>
<small>Range of backends, libraries and plugins</small><br>
<small>Limited to non-production and non-commercial use</small><br>
</div>
<br>
<p class="text-center py-3">
<a class="btn btn-outline-primary" href="https://github.com/exaloop" target="_blank">Get started</a>
</p>
</div>
</div>
<div class="col-md-6" data-aos="fade-in">
<div class="pricing-1 popular">
<p class="plan-name">Unrestricted Use</p>
<br>
<h2 class="price">contact us</h2>
<p class="small text-lighter">at info@exaloop.io</p>
<div class="text-muted">
<small>Everything in <i>free</i></small><br>
<small>Additional modules and plugins</small><br>
<small>Added support and maintenance</small><br>
</div>
<br>
<p class="text-center py-3">
<a class="btn btn-outline-primary" href="mailto:info@exaloop.io">Get started</a>
</p>
</div>
</div>
</div>
</div>
</section>
</main>
<!-- Footer -->
<footer class="footer">
<div class="container">
<div class="row gap-y align-items-center">
<div class="col-6 col-lg-3">
<a href="index.html"><img src="assets/img/logo-dark.svg" alt="logo"></a>
</div>
<div class="col-6 col-lg-3 text-right order-lg-last">
<div class="social">
<a class="social-git" href="https://github.com/exaloop"><i class="fa fa-github"></i></a>
<a class="social-twitter" href="https://twitter.com/exaloop"><i class="fa fa-twitter"></i></a>
<a class="social-linkedin" href="https://www.linkedin.com/company/exaloop/"><i class="fa fa-linkedin"></i></a>
<a class="social-discord" href="https://join.slack.com/t/exaloop/shared_invite/zt-1jusa4kc0-T3rRWrrHDk_iZ1dMS8s0JQ"><i class="fa-brands fa-slack"></i></a>
</div>
</div>
<div class="col-lg-6">
<div class="nav nav-bold nav-uppercase nav-trim justify-content-lg-center">
<a class="nav-link" href="https://docs.exaloop.io">Docs</a>
<a class="nav-link" href="https://blog.exaloop.io">Blog</a>
<a class="nav-link" href="https://docs.exaloop.io/codon/general/faq">FAQ</a>
<a class="nav-link" href="benchmarks.html">Benchmarks</a>
<a class="nav-link" href="about.html">About</a>
<a class="nav-link" href="mailto:info@exaloop.io">Contact</a>
</div>
</div>
</div>
</div>
</footer><!-- /.footer -->
<!-- Scripts -->
<script src="assets/js/page.min.js"></script>
<script>
/*!
* Adapted from:
* Mantis.js / jQuery / Zepto.js plugin for Constellation
* @version 1.2.2
* @author Acauã Montiel <contato@acauamontiel.com.br>
* @license http://acaua.mit-license.org/
*/
(function ($, window) {
var $window = $(window);
function CoolEffect (canvas, options) {
var $canvas = $(canvas),
context = canvas.getContext('2d'),
defaults = {
star: {
color: 'rgba(255, 255, 255, .3)',
width: 1,
randomWidth: true
},
line: {
color: 'rgba(255, 255, 255, .3)',
width: 0.2
},
position: {
x: 0,
y: 0
},
width: window.innerWidth,
height: $('#head').height(),
velocity: 0.1,
length: 100,
distance: 120,
radius: 150,
stars: []
},
config = $.extend(true, {}, defaults, options);
function Star (horizontal) {
this.x0 = Math.random() * canvas.width;
this.y0 = Math.random() * canvas.height;
this.x = this.x0;
this.y = this.y0;
this.vx = (config.velocity - (Math.random() * 0.5));
this.vy = (config.velocity - (Math.random() * 0.5));
this.radius = config.star.randomWidth ? (Math.random() * config.star.width) : config.star.width;
}
Star.prototype = {
create: function(){
context.beginPath();
context.arc(this.x, this.y, this.radius, 0, Math.PI * 2, false);
context.fill();
},
animate: function(){
var i;
for (i = 0; i < config.length; i++) {
var star = config.stars[i];
if (star.y < 0 || star.y > canvas.height) {
star.x0 = star.x;
star.y0 = star.y;
star.vx = star.vx;
star.vy = - star.vy;
} else if (star.x < 0 || star.x > canvas.width) {
star.x0 = star.x;
star.y0 = star.y;
star.vx = - star.vx;
star.vy = star.vy;
}
var old = star.x;
star.x += 3*star.vx;
star.y += 3*star.vy;
context.beginPath();
context.moveTo(star.x0, star.y0);
context.lineTo(star.x, star.y);
context.stroke();
context.closePath();
}
},
line: function(){
/*
var length = config.length,
iStar,
jStar,
i,
j;
for (i = 0; i < length; i++) {
for (j = 0; j < length; j++) {
iStar = config.stars[i];
jStar = config.stars[j];
if (
(iStar.x - jStar.x) < config.distance &&
(iStar.y - jStar.y) < config.distance &&
(iStar.x - jStar.x) > - config.distance &&
(iStar.y - jStar.y) > - config.distance
) {
if (
(iStar.x - config.position.x) < config.radius &&
(iStar.y - config.position.y) < config.radius &&
(iStar.x - config.position.x) > - config.radius &&
(iStar.y - config.position.y) > - config.radius
) {
context.beginPath();
context.moveTo(iStar.x, iStar.y);
context.lineTo(jStar.x, jStar.y);
context.stroke();
context.closePath();
}
}
}
}
*/
}
};
this.createStars = function () {
var length = config.length,
star,
i;
context.clearRect(0, 0, canvas.width, canvas.height);
for (i = 0; i < length; i++) {
config.stars.push(new Star(i < length / 2));
star = config.stars[i];
star.create();
}
star.line();
star.animate();
};
this.setCanvas = function () {
canvas.width = config.width;
canvas.height = config.height;
};
this.setContext = function () {
context.fillStyle = config.star.color;
context.strokeStyle = config.line.color;
context.lineWidth = config.line.width;
};
this.setInitialPosition = function () {
if (!options || !options.hasOwnProperty('position')) {
config.position = {
x: canvas.width * 0.5,
y: canvas.height * 0.5
};
}
};
this.loop = function (callback) {
callback();
this.rAF = window.requestAnimationFrame(function () {
this.loop(callback);
}.bind(this));
};
this.handlers = {
window: {
mousemove: function(e){
config.position.x = e.pageX - $canvas.offset().left;
config.position.y = e.pageY - $canvas.offset().top;
},
resize: function () {
window.cancelAnimationFrame(this.rAF);
}
}
};
this.bind = function () {
$window
.on('mousemove', this.handlers.window.mousemove)
.on('resize', this.handlers.window.resize.bind(this));
};
this.unbind = function () {
$window
.off('mousemove', this.handlers.window.mousemove)
.off('resize', this.handlers.window.resize);
}
this.init = function () {
this.setCanvas();
this.setContext();
this.setInitialPosition();
this.loop(this.createStars);
this.bind();
};
}
function instantiate(element, options) {
var c = new CoolEffect(element, options);
c.init();
}
$.fn.cooleffect = function (options) {
return this.each(function () {
$window.on('resize', () => {
instantiate(this, options);
});
instantiate(this, options);
});
};
})($, window);
// Init plugin
$('canvas').cooleffect({
star: {
width: 3
},
line: {
color: 'rgba(255, 255, 255, .5)'
},
length: (window.innerWidth / 15),
radius: (window.innerWidth / 50)
});
</script>
<script src="assets/js/leader-line.min.js"></script>
</body>
</html>