HTML5 canvas player.


Great job haramanai !

Even if, actually, sifplayer is “limited”, it’s really impressive and a so fantastic tool for all software who use the sif file format !
I feelt that synfig was a kind of flash “app’killer”, now, linked to html5 it’s even certainly obvious.

From my test point of view :

  • in Encapsulated layer, zoom is supported but not focal parameter (see zoom layer in my test.sif)
  • in Region Layer, if during animation somes vertex are suppress, animation is lossed (see arbol-transo-vertex layer)

TestFile :
online “demo” (or not)
I have used sifplayer commit version 561ea7934a

Nota : in my case, sifplayer work well in local, but why not online ? [SOLVED 23/10/12]


Sorry guys for the delayed response but I haven’t much free time.
d.j.a.y thanks for the test files. I will see what I can do… Also whats the problem you encountered on-line?
Right now I am in the process to find a solution to generalize the sifjson. This will result to rewrite the tweener and the renderer so I will try to document the code to be easier for any one who wands to participate to read and modify the code.

d.j.a.y looks like that there is no xml file (test.sif) in the sif online demo. The test.sif file must be in the same domain with the page. Or there some server restriction.

New version of the sifPlayer.
Lot of changes in the design of the player.
Now the src looks the way it is supposed to look.
The sifjson is removed from the project.

The new version is more object oriented and I think it will be much easier to be modified.
Don’t expect stickman to run as I haven’t added the strech layer yet.
Now all the layers have a file. for example the region layer is in the src/region.js.
When you add a new layer for example stretch layer in the src just follow the the way the other layers are created and name the file stretch.js then add the javascript in the sifPlayer.html and the player will automatically run your layer.

Some things are missing but if you look in the src you will see that it is much easier now to add new futures.

I need instructions of how things work. for example the stretch layer and the focus param.

Now I think every one can contribute…

Which kind of information do you need?

For example in the stickman i find stretch layer like this.
As I undestand this the x min value is epsilon and max infinite. Is the reciprocal something that can hapen only to this kind of layer or I have to check all the params for the possibility of a reciprocal?

                    <layer type="stretch" active="true" version="0.1" desc="compensator-elbow2" group="(stk)-stretches">
                      <param name="amount">
                        <composite type="vector">
                            <reciprocal type="real" link=":(stk)-elbow2-r">
                                <real value="0.0000010000"/>
                                <real value="999999.0000000000"/>
                            <real value="1.0000000000"/>
                      <param name="center">

Also in a outline layer I found an entry that looks like this

                      <greyed type="bline_point">
                              <real value="1.0000000000"/>
                              <real value="0.5000000000"/>

I have to check for this and for the region? Can I over pass this by creating a point that have t1.theta = 0 and t1.radius = 0?

Also the param focus… what is doing?

At last if reciprocal is one type of the values. Is there anymore like this?


:smiley: Happy to see your progress! I’m definitely going to use this for some project!

Later we’ll need some kind of player control, like loop playback etc.

Perhaps we could use canvas metadata to introduce some very basic interactivity, like buttons for replay and such?
Maybe it is possible to store custom object data somehow to use for further interactivity?

I thought about those things and this is the main reason I am using createjs.Tweenjs. If you go in the sifPlayer.html and write after the var so line
so.timeline.loop = true;

you will get the loop you wand.

Go check the createjs.Tweenjs api documentation for more.

Also for interactivity we may use the desc to describe the way the object will behave.

My problem is the stickman. Without stickman there is no proper sifplayer.

Regarding to reciprocal and greyed, please consider that any parameter can be converted to one of the convertible types:

So if a layer expects a real value, it can be any of the coverted values to real.

Please see loadcanvas.cpp for reference on how it is parsed. The subparameters and its types is defined in each class derived from Linkable_ValueNode: … eNode.html


Thanks Genete this is what I wanted. Too many things in there.

some server restriction —> i have renamed test.sif in test.xml and now the bug works online
Yep we found a new entry for sifplayer Q&A :wink:


I was hopping to come here and say: Yeah stickman is supported! But as soon I was on a zoom layer that uses logarithm for amount and stretch with epsilon and infinity I decided that I have to remove those layers from the stickman and create something like stickman lite to work on it.
Yeah stickman lite is supported!

d.j.a.y please donwload the new version from github the focus is added.

Keep in mind that the sifplayer.js in the build folder have some problems. So use the example of the first folder that is loading all the files.

It is awesome to see your development commits on github. Great work! I hope it becomes the Synfig killer complement to make it more popular.

I just putted support for the google closure compiler. This way we can make builds that will result to a much smaller version of the sifplayer. So now you can find a all in one version of sifPlayer inside the build folder.

I also re-added the MIT license note.

Go check it out. The sifplayer.min.js file inside the build folder right now is 13.3kb .

It’s time for testing guys…

Hi haramanai,
Is it possible to scale the animation based on the browser’s window size?

Regarding to tests. Can you please write a small recipe for completely dumb users to explain how to do the test with simple files. It should be added to the README file or some sort of instructions in the repository.


Hi Genete.
This is an external problem of the sifPlayer.
The example renders the sif file to the size of the canvas that is created in the body of the html file.
So to change the size of the canvas you must change the line that reads,

I havent tried before to change the canvas size with javascript to give you a way to do it easier. I will se what I can do for this.

the only thing that really needs documentation is the sifPlayer.SifObject constructor.

In SifObject.js writes.


  • @class SifObject
  • @constructor
  • @param {XmlDocument} xmlDoc The xml document that represents the synfig animation
  • @param {CanvasRenderingContext2D} } ctx The canvas 2D context object to draw into.
  • @param {Number} x The x of the SifObject
  • @param {Number} y The y of the SifObject
  • @param {Number} width The width of the SifObject
  • @param {Number} height The height of the SifObject
  • @param {String} sifPath The path of the sif.xml this is needed for import layer

As was mentioned by rylleman the speed was very fast. I think I fixed it.
I also added the circle layer.

I also wand to say that sifplayer is not completed but I don’t know how to continue the development. What I mean is that the way I use synfig I do not have any problems with the current state of the sifplayer but an advanced user may use futures that I am not even aware of. I think that the best way to continue this is to report problems and upload sif files that have the problem to help me fix it or impliment it. If you get a strange big alert ussualy this means that you reached a problem.

Keep in mind that outlines are not implimented.
Also the values that use epsilon and logarith are not implimented and will not in the near future.

But what should I do to test your sifplayer?
I have a sif(z) file. And now what?
Please give us a step by step recipe :slight_smile:

The sif file must be uncompressed. If it is compressed you will have .sifz. Uncompress that and add to the new file .sif or .xml.
Then you get this file to the dir of the sifPlayer.html.
Let’s say that you have r.xml

in the sifPlayer.html you will find a line that reads :
var xmlDoc = loadXML(‘assets/test.sif’);
change that to :
var xmlDoc = loadXML(‘r.xml’);

and save.

run the sifPlayer.html and you will have you file rendered.

Also keep in mind that some browsers will not let you to load a file from your local computer. You will get an error and you will see nothing.
You will better use firefox when you are testing. Cause firefox let’s you do this.

I made some changes to the sifplayer and the SifObject constructor is now

  • @class SifObject
  • @constructor
  • @param {XmlDocument} xmlDoc The xml document that represents the synfig animation
  • @param {Number} x The x of the SifObject
  • @param {Number} y The y of the SifObject
  • @param {Number} width The width of the SifObject
  • @param {Number} height The height of the SifObject
  • @param {String} sifPath The path of the sif.xml this is needed for import layer
    in the sifPlayer.html is used in a line that reads:
    var so = new sifPlayer.SifObject(xmlDoc, 0, 0, canvas.width, canvas.height, ‘assets/’);

the last param is the location of your sif file. This is needed for the import layer. If you followed the instructions I just said and your sif uses imagies you must change that line to:
var so = new sifPlayer.SifObject(xmlDoc, 0, 0, canvas.width, canvas.height, ‘’);

Done / And yep, focus work !

Humm … seem’s they are a clip duration problem.
Is it because i have taken the sif player from the build directory?

héhé…stickman is coming :wink: