GithubHelp home page GithubHelp logo

Comments (1)

wout avatar wout commented on May 17, 2024

You can achieve similar functionality with svg.js, although it takes a completely different approach. Let's take something similar to Raphael's hsb example for comparison.

/* extend shape module with hsb method */
SVG.extend(SVG.Shape, {
  hsb: function(h, s, b) {
    return this.attr('fill', { h: h % 360, s: s, b: b })
  }
})

/* create canvas */
var draw = svg('canvas')

/* create circle */
var c = draw.circle(100).move(10, 10).hsb(0, 100, 100)

/* animate hsb */
c.animate(1e4, '-').during(function(pos, morph) {
  this.hsb(morph(0,360), 100, 100)
})

It wouldn't be too hard to write a plugin to bend this functionality to a more Raphael-like syntax.
But that's a different story.

More info on extending objects in svg.js can be found here:
https://github.com/wout/svg.js#extending-functionality

And info on synchronising animations:
https://github.com/wout/svg.js#synchronising-animations

To come to your second question, I have indeed looked into requestAnimationFrame and decided to go with a interval / date iterator to keep it simple. But I am looking to replace it with rAF as a part of performance enhancements as soon as the library gets to a steady level structurally.

from svg.js.

Related Issues (20)

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.