Synfig Project Forum

Forums for Synfig Project
It is currently Sat May 25, 2013 6:45 pm

All times are UTC - 4 hours [ DST ]




Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Sun Aug 15, 2010 8:33 am 
Offline
User avatar

Joined: Sat Jan 02, 2010 2:13 pm
Posts: 133
Location: France
I tried to imitate Flash, using Synfig and javascript.
It's complicated, and my javascript's code is not very good, but it works, and i hope it's funny.
It's here :
http://skias.free.fr/bestiole/
Move the mouse over the cat :)

[Edit : I dont know if this script works with a browser other than Firefox]

_________________
http://mad0images.blogspot.com/


Last edited by mad0 on Mon Aug 16, 2010 5:09 am, edited 1 time in total.

Top
 Profile  
 
PostPosted: Sun Aug 15, 2010 11:00 am 
Offline
User avatar

Joined: Fri Jan 25, 2008 3:46 am
Posts: 288
Location: Nashville. TN
Nice job!

Matt

_________________
Creepspace: The Witch Game - Created with open source software!


Top
 Profile  
 
PostPosted: Sun Aug 15, 2010 11:02 am 
Offline
Site Admin
User avatar

Joined: Sat Dec 01, 2007 6:26 am
Posts: 4142
Location: Spain
Good example of Synfig web integration!!
-G

_________________
Synfig needs your help!
Developers, packagers, bug testers, translators, artists, web developers, wiki writers... you can contribute! :D


Top
 Profile  
 
PostPosted: Sun Aug 15, 2010 6:06 pm 
Offline
User avatar

Joined: Sun Aug 16, 2009 12:09 pm
Posts: 213
Location: Belgium
Interesting way to make the animation interactive, at first I thought you'd have generated a set of animated gifs and replace the static images in a table by the animated one using JS (or CSS :hover selector) ... but your way is nice too. thanks!
B.


Top
 Profile  
 
PostPosted: Mon Aug 16, 2010 5:07 am 
Offline
User avatar

Joined: Sat Jan 02, 2010 2:13 pm
Posts: 133
Location: France
Hello,
Thank you Matt, Genete and Berteh :)
Berteh, I did this test because I saw in another forum that we could animate png with javascript. I found a code sample on Google, and I adapted it.
I have not even thought of animated gifs, however, it would have been easier! :oops:
But the method of moving big picture in a div has an advantage, we can also stop the animation, and not with the gifs. (I do not use it here, but it could be used in another try)

_________________
http://mad0images.blogspot.com/


Top
 Profile  
 
PostPosted: Mon Aug 16, 2010 5:16 am 
Offline
Site Admin
User avatar

Joined: Wed Jan 21, 2009 2:36 pm
Posts: 613
Location: Sweden.
Very interesting!

For those of us who know nothing about Javascript would you mind giving us a brief overview of how you did this?

_________________
www.rylanderanimation.se
Synfig scripts, etc.


Top
 Profile  
 
PostPosted: Mon Aug 16, 2010 6:17 am 
Offline
User avatar

Joined: Sat Jan 02, 2010 2:13 pm
Posts: 133
Location: France
Hello Rylleman,
It is not difficult, just a little complicated.
I export the canvas of the different parts of the animation, and I make separate renders.
The images are created in Gimp as this (you put the small pictures first in the top left, second to his right ... etc. and the last in the bottom right ) :
http://skias.free.fr/bestiole/oeil.png
http://skias.free.fr/bestiole/oreille1.png
Remember the size of small parts, and those of the picture.

Html div's code like this :
Code:
#oreille1 {
   width:122px;
   height:94px;
   background-image: url('oreille1.png');
   background-repeat: no-repeat;
   background-position: 0 0;
   position : absolute;
   top: 69px;
   left: 271px;
   }

(width and height : size of small part. top and left : position on the html page).

The display of the div is :
Code:
<div id="oreille1" onMouseOver="oreille1()"></div>


For the javascript code, i give you mine, but it's not very good, except the part that I copied on Google. I know very few javascript :oops: :

Code:
var chrono_oreille1;
function change_oreille1() {
   var pos_oreille1=$('#oreille1').css('backgroundPosition').split(' ')[0].replace(/px|pt/,'');
   var pos2_oreille1=$('#oreille1').css('backgroundPosition').split(' ')[1].replace(/px|pt/,'');
      pos_oreille1=(pos_oreille1-122<-366)?0:pos_oreille1-122;
            if (pos_oreille1==0) {pos2_oreille1=(pos2_oreille1-94<-473)?0:pos2_oreille1-94;}
         $('#oreille1').css('backgroundPosition',pos_oreille1+'px '+pos2_oreille1+'px');
            if (pos_oreille1==0 && pos2_oreille1==0 && chrono_oreille1!=null) {
               clearInterval(chrono_oreille1);
               chrono_oreille1=null;}
   }
function avance_oreille1() {
   chrono_oreille1=setInterval("change_oreille1()",30)}

function oreille1() {
   if (chrono_oreille1==null) {avance_oreille1();}
   else {return;}
   }

122 is width of small part.
94 is height of small part.
366 is width of picture minus 122, width of small part.
473 is height of picture minus 94, height of small part.

_________________
http://mad0images.blogspot.com/


Top
 Profile  
 
PostPosted: Tue Aug 17, 2010 12:19 pm 
Offline
User avatar

Joined: Sun Aug 16, 2009 12:09 pm
Posts: 213
Location: Belgium
I definitely like the concept... might be the topic of a future challenge!

suggestions to make your work easier for next time:
- render the animated parts (snapshots) in png, with synfig, just the way you did, resulting in, eg: oreille01.png, oreille02.png... oreille24.png
- concatenate all related parts using imagemagick's montage tool in a horizontal-only (or vertical only) sequence of snapshots.
- simplify the javascript code a lot because you don't have to handle 2 dimensions "imagechange()" but only the +width (for horizontal) or +height (for vertical) and return to 0 after the count of snapshots.

I suck at javascript, but if anyone wants to make the code I'd be willing to test it out!
B.


Top
 Profile  
 
PostPosted: Wed Aug 18, 2010 3:55 am 
Offline
User avatar

Joined: Sat Jan 02, 2010 2:13 pm
Posts: 133
Location: France
Hello Berteh,
You're right, I did not say, but I actually made my renders in png.
Gimp is also good for building images, we can open the sequence with "open as layers". Cropping is easy because the layers are transparent. And for the placement of layers, "set grid" and "align to grid", then the layers are easily placed.
And you're right, "horizontal-only" is better for the code, the sample was "horizontal-only", but I thought more difficult to create an image very large.

If you want to test, I can make your code.
And I'll make a model page that can be adapted more easily :)

_________________
http://mad0images.blogspot.com/


Top
 Profile  
 
PostPosted: Wed Aug 18, 2010 12:32 pm 
Offline
User avatar

Joined: Sat Jan 02, 2010 2:13 pm
Posts: 133
Location: France
Hello,
I've tried to make javascript code better, and to make various functions.
http://skias.free.fr/modele/
(all those eyes, it's a bit weird! :lol: )

Image is here : http://skias.free.fr/modele/eye.png
Html file : http://skias.free.fr/modele/modele.txt - Rename the file from .txt to .html
javascript file : http://skias.free.fr/modele/modele.js

Nothing to do with javascript file. You must just :
1- create the divs
2- call the function as in the example.
If you need another function, I can try to encode it :)

_________________
http://mad0images.blogspot.com/


Top
 Profile  
 
PostPosted: Thu Aug 19, 2010 4:49 am 
Offline
User avatar

Joined: Sun Aug 16, 2009 12:09 pm
Posts: 213
Location: Belgium
mad0 wrote:
I've tried to make javascript code better, and to make various functions. http://skias.free.fr/modele/
(...)
If you need another function, I can try to encode it :)


Wonderful, I gotta try this, thanks!


Top
 Profile  
 
PostPosted: Thu Aug 19, 2010 10:52 am 
Offline
User avatar

Joined: Mon Mar 30, 2009 7:33 am
Posts: 394
Location: Spain
@Mad0: Nice, interesting and very good job. Congratulations.


Top
 Profile  
 
PostPosted: Fri Aug 20, 2010 5:36 pm 
Offline
User avatar

Joined: Sat May 02, 2009 3:38 am
Posts: 309
XDDD Pretty clever, dude! Now if only we had a direct interface for scripting Java / Python on Synfig. Regardless, that stuff is awesome, and because it's a cat, it's super awesome!

_________________
Bartimaeus: "One magician demanded I show him an image of the love of his life. I rustled up a mirror."
My website of awesomeness!


Top
 Profile  
 
PostPosted: Tue May 10, 2011 3:23 am 
Offline
User avatar

Joined: Sat Jan 02, 2010 2:13 pm
Posts: 133
Location: France
Hello ! :)
With Firefox 4, my cat was no longer working.
With help on "Site du Zéro"(javascript's forum), I fixed it :
In the code, you must replace all
/px|pt/
by
/px|pt|%/
I don't understand, but it works! :D :D

_________________
http://mad0images.blogspot.com/


Top
 Profile  
 
PostPosted: Sat Jul 28, 2012 4:08 pm 
Offline
User avatar

Joined: Sat Jan 02, 2010 2:13 pm
Posts: 133
Location: France
Hello :)
I have not used ​​synfig for a while, because I went back to Blender. But now here a new project.
http://skias.free.fr/poissons_synfig/aquarium/aquarium1.html
there is very little animation here, but is made with Synfig! it's a aquarium game for my little son who loves fishes.
the box is a trash, but it seemed to me wrong to put fish in the trash, so I made a storage box.
You have to click two times on the gray fish: once to display the sprite, another time to move it into the aquarium. I can't do better.
The table is used to place objects more or less at the bottom of the aquarium.
I still have to improve, and add bubbles :)

_________________
http://mad0images.blogspot.com/


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next

All times are UTC - 4 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group