Git Product home page Git Product logo

triangleslife's Introduction

Triangles life

This is a smoothly animated background effect made with canvas. See it working here : http://codepen.io/Yakudoo/pen/46a1b7798417f1ccbbe9a836492f71c0

License http://creativecommons.org/licenses/by-sa/4.0/deed.en_US

Requirements

Require GreenSock TweenMax : http://greensock.com/tweenmax

Demo

Try this on codepen

Usage

Triangles Life let you add a smooth andclassy triangles effects on a canvas.

To add this on your website, simply include the latest TweenMax library together with the TrianglesLife.js into your document <head>.

Add a canvas to your html file in the body.

<body>
  <canvs id="myCanvas"></canvas>
</body>

Style your canvas by adding a height and width in the css.

#myCanvas {
  position:absolute;
  margin: auto;
  width: 100%;
  height: 100%;
  background-color : #222;
}

Then add a javascript like this one :

var params = {
  canvasId : 'myCanvas',        // id of your canvas
  triangleWidth : 16,           // width of each triangle
  triangleHeight : 18,          // height of each triangle
  trailMaxLength : 12,          // Maximum of connected triangles to form a trail
  trailIntervalCreation : 200,  // Delay before the creation of a new trail (in milliseconds)
  delayBeforeDisappear : 2,     // Delay before a trail starts to disappear (in seconds)
  colors : ['#eb9000', '#f6b400','#440510', '#8a0a08','#91dffa'] // Colors you want to use for the triangles
};

var tl = new TrianglesLife(params);

trianglesLife.start()

Start the generation :

tl.start();

trianglesLife.kill()

You can kill the process of the generator by doing :

tl.kill();

trianglesLife.pause()

Pause it :

tl.pause();

trianglesLife.resume()

Resume it :

tl.resume();

trianglesLife.closeAll()

Close all the triangles :

tl.closeAll();

triangleslife's People

Contributors

yakudoo avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.