GithubHelp home page GithubHelp logo

ytiurin / particleswarm Goto Github PK

View Code? Open in Web Editor NEW
8.0 3.0 1.0 6.86 MB

:honeybee: Particle swarm optimization method, animated in DOM w/GPU acceleration.

License: MIT License

HTML 12.51% JavaScript 87.49%

particleswarm's Introduction

Demo GIF

Particle swarm ๐Ÿ Watch in action

Particle swarm is an optimization method that iteratively improves a candidate solution with regard to a given measure of quality. Check the Wikipedia page for algorithm description.

Usage

This code defines a particle swarm object, containing 10 particles with random position.

// Create swarm
var swarm = new Swarm;
// Configure particles movement
swarm.particleBraking = 0.997;
swarm.maxSpeed = 50;
// Set swarm target and bound 
// particles allowed position
swarm.targetPosition = new Vector( 100 / 2, 100 / 2 );
swarm.boundingRect = [ new Vector, new Vector( 100, 100 ) ];
// Set number of particles
var particlesCount = 10;
// Create particles
while ( particlesCount-- )
  swarm.addParticle(
    new Particle(
      new Vector( Math.random() * 100, Math.random() * 100 )));
// move particles 60 times per second
setInterval(function(){
  swarm.next()
}, 16);

GPU acceleration

Animated elements are transformed using CSS translate3d/rotate3d properties, which is GPU accelerated in majority of modern browsers.

particleswarm's People

Contributors

ytiurin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

katsura-san

particleswarm's Issues

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.