Deprecated: Function get_magic_quotes_gpc() is deprecated in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 99

Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 619

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1169

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176
8000 GitHub - ttonightt/thunder.js: Just a tiny but useful and easy-use library that allows you to add great animated lightning to your canvases!
Nothing Special   »   [go: up one dir, main page]

Skip to content

Just a tiny but useful and easy-use library that allows you to add great animated lightning to your canvases!

License

Notifications You must be signed in to change notification settings

ttonightt/thunder.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

⚡ thunder.js

Just a tiny but useful and easy-use library that allows you to add great animated lightning to your canvases!

Only developer version is available for now!!!

Check how it works following this demo link Some features from docs may not work in appropriate way!!!
New versions come at least one times a week. Wait the final release! ;)

📜 Tutorial

1.1. At first connect thunder.js or thunder.min.js from .zip, that you've downloaded already:

<script type="text/javascript" src="thunder.js"></script>

* Just put code above into <head>

1.2. Also don't forget to create <canvas> anywhere and link it in your source. The simplest way to do it is below:

<!-- somewhere in the <body></body> -->
<canvas id="-canvas-id-"></canvas>
<script type="text/javascript" src="path-to-your-source.js"></script>
// your-source.js
const ctx = document.getElementById("-canvas-id").getContext("2d");

* If you gonna develop smth either mobile- or Apple- friendly set appropriate canvas size considering window.devicePixelRatio.
(Just multiple objective width and height of canvas on it and compress them back by means of CSS). That's enough. Thunder.js is drawing lightnings using "devicePixelRatio" directly


2.1. Okay, you've done it, you're ready to draw first lightning. You need to connect your ctxs to thunder.js, so:

ThunderJSProperties.setContexts(ctx /*main canvas*/, ctxb /*additional one to make lightning glowing*/);

* Yeah, I know that using additional canvas for blur is such a stupid way, but both Safari for IOS and desktop just don't support ctx.filter. Some libs that are kinda fix it either too slow or just doesn't work! :/
So, if you know any workable tool to fix it text me please. Or just text to Tim Cook idk. Thanks!)

2.2. To create a new lightning use instance of Lightning class:

let myLightning = new Lightning (x0, y0, x, y);
  • x0, y0 are recognized as a start of lightning. Consider this, if you going to "expand" by means of .expand() method
  • x, y are recognized as an end of lightning
    Besides basic four arguments you can add specific "properties" arg' that can contains color, animation algorythm and some other parameters, which you might store in ThunderJSProperties early. Learn more

2.3. Animate or draw it!

// in case you want to animate it:
myLightning.startAnimation();
// in case you want to draw:
myLightning.draw();

To stop animation:

myLightning.stopAnimation();

🔱 Other Docs

Lightning (class)

Main class of thunder.js

  • constructor (x0: number, y0: number, x: number, y: number, properties: {/*...*/})

    properties : {...} is in fact an instance of ThunderJSProperties and can contains any parameter from there. As far as you understand it exists to configure specificly the lightning instead of using ThunderJSProperties parameters.

  • .expand (ex: number, ey: number):void "expands" the lightning to fit from the start to getted ex and ey. Start stay fixed.
  • .startAnimation (ctx, ctxb):void Basicly starts animation of the lightning

    ctx : CanvasRenderingContext2D. Gets ThunderJSProperties.ctx if unset
    ctxb : CanvasRenderingContext2D. Gets ThunderJSProperties.ctx if unset

  • .stopAnimation ():void Stops the animation
  • .draw (ctx, ctxb):void Draws the lightning

    ctx : CanvasRenderingContext2D. Gets ThunderJSProperties.ctx if unset
    ctxb : CanvasRenderingContext2D. Gets ThunderJSProperties.ctx if unset

ThunderJSProperties (object)

Set of global lightning parameters from a common look to some service parameters

/* ThunderJSProperties structure: */
ThunderJSProperties = {
    ctx: /*CanvasRenderingContext2D*/, // null by default
    ctxb: /*CanvasRenderingContext2D*/, // null by default
    look: {
        color: /*hexcode, rgb or rgba*/,
        blurColor: /*hexcode, rgb or rgba*/,
        colorFading: /*[0 to 1, 0 to 1] or just 0 to 1*/, // 1 by default
        lineFading: /*[]*/, // [0.7, 2] by default
    },
    algorythm: /* "teslacoil", "fast", "oneshot" */, /* "teslacoil" (default) is the slowest and literally look like lightning from Tesla coil,
                  "fast" is the fastest but looks less naturally,
                  "oneshot" is the best algo' to "blink" the lightning */
    fps: /*number*/,
    ignoreIterator: /*boolean*/, // if true and fps <= 0 lightning will animate as fast as possible. If false and fps <= 0 lightning will redraw not every iteratorTreshold'th frame
    iteratorTreshold: /*number*/, // read commet above
}

About

Just a tiny but useful and easy-use library that allows you to add great animated lightning to your canvases!

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0