XWidgetSoft Forum

XWidget & XLaunchpad , Desktop customization
It is currently May 10th, 2025, 12:27 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 28 posts ] 
Author Message
 Post subject: Shake Animation TRICK???
PostPosted: November 5th, 2013, 4:08 am 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887
Check this out guys! Cool? 8-)
(the design is not completed yet that's why the top of the wires look like this)

Everyone knows this pendulum "clock".
Is there a trick so I can add 1 second delay between the shake animations, or a way so the movement will be as the real one??? :roll:
(The balls move parallelly)
Tony added the delay function but is only for switch animations...


Attachments:
ok.jpg
ok.jpg [ 94.91 KiB | Viewed 19126 times ]

_________________
...and remember: don't take life too seriously...
My profile on Deviantart: http://jimking.deviantart.com/
Top
 Profile  
 
PostPosted: November 6th, 2013, 4:17 am 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887
I found this:

var img = paper.image("image.png", 10, 10, 80, 80);
(function swingRight(){
img.animate({'rotation': 30}, 1000, '<>', function swingLeft(){
img.animate({'rotation': -30}, 1000, '<>', swingRight);
});
}());

how can this be applied on Designer...?

An image can be animated (shake-pendulum animation) using a script?

_________________
...and remember: don't take life too seriously...
My profile on Deviantart: http://jimking.deviantart.com/


Top
 Profile  
 
PostPosted: November 6th, 2013, 6:04 am 
Offline
User avatar

Joined: June 10th, 2012, 6:04 am
Posts: 5
you can also write this between every animate starts:
sleep(100);
It means that the next line of cade will start in 100 millisecond after the previous line of code of cade .


Top
 Profile  
 
PostPosted: November 6th, 2013, 7:45 am 
Offline
User avatar

Joined: July 9th, 2012, 1:14 pm
Posts: 112
There is a nice widget by xwidgetsoft with "shaking script" http://url9.de/OBr.
Maybe it's helpful.


Top
 Profile  
 
PostPosted: November 6th, 2013, 7:46 am 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887
Thanks 9yomo! :)

_________________
...and remember: don't take life too seriously...
My profile on Deviantart: http://jimking.deviantart.com/


Top
 Profile  
 
PostPosted: November 6th, 2013, 7:48 am 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887
Dagedee wrote:
There is a nice widget by xwidgetsoft with "shaking script" http://url9.de/OBr.
Maybe it's helpful.

Oh thanks Dagedee! :D
I will check it right now!

_________________
...and remember: don't take life too seriously...
My profile on Deviantart: http://jimking.deviantart.com/


Top
 Profile  
 
PostPosted: November 6th, 2013, 8:26 am 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887
The suggestion of Dagedee made the job! :D
Here is the script:

Quote:
var rockRange = 5; //»Î¶¯·ù¶È£¬¿É×ÔÐÐÐÞ¸ÄÆäÖµ

/////////////////////
var Counter= 1;
function timercore1OnUpdate(Sender)
{
Counter = Counter +1;
rotator1.rotateAngle = -15 + (Math.cos((Counter%40)/40*2*Math.PI)/rockRange+0.25)/Math.PI*180 ;

Counter = Counter +1;
rotator2.rotateAngle = -15 + (Math.cos((Counter%40)/40*2*Math.PI)/rockRange+0.25)/Math.PI*180 ;
}


But the delay function for the second ball (rotator2) sleep(100);
where exactly must be placed??


Pratically I think that the right ball when the widget starts, on the first run, needs 1 sec of delay.
And then a delay on each ball at the end of their movement (?)

_________________
...and remember: don't take life too seriously...
My profile on Deviantart: http://jimking.deviantart.com/


Top
 Profile  
 
PostPosted: November 6th, 2013, 12:29 pm 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887
Searching on Internter I found these:
http://stackoverflow.com/questions/9510 ... n-of-sleep

Quote:
var waitTillSomethingHappens = function(){
if(somethingHappened == 1)
{
alert('Something Happened get out of sleep');
}
else
{
setTimeout(waitTillSomethingHappens,1000);
}
};

Or:
Quote:
function yourFunction(){

//do something
setInterval(myFunc(),1000);
//do something else

}

function myFunc(){
return;
}


Could some apply it to my script...?

_________________
...and remember: don't take life too seriously...
My profile on Deviantart: http://jimking.deviantart.com/


Top
 Profile  
 
PostPosted: November 6th, 2013, 2:12 pm 
Offline
User avatar

Joined: July 9th, 2012, 1:14 pm
Posts: 112
It is just "sleep () //ms", for example:

function button1OnClick(Sender)
{
image1.visible = true;
sleep (2000); //ms
image1.visible = false;
}
Attachment:
sleep_example.rar [5.5 KiB]
Downloaded 329 times


Top
 Profile  
 
PostPosted: November 6th, 2013, 4:32 pm 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887
Dagedee wrote:
It is just "sleep () //ms", for example:

function button1OnClick(Sender)
{
image1.visible = true;
sleep (2000); //ms
image1.visible = false;
}
Attachment:
sleep_example.rar

Thanks man but with animations I think that is different...
That's why I asked how exactly the sleep function can be applied on my case...!
It will be more helpful if you can provide me exactly the script with this mode..

_________________
...and remember: don't take life too seriously...
My profile on Deviantart: http://jimking.deviantart.com/


Top
 Profile  
 
PostPosted: November 7th, 2013, 4:03 am 
Offline
User avatar

Joined: July 9th, 2012, 1:14 pm
Posts: 112
It is exactly the way 9yomo wrote already.

"you can also write this between every animate starts:
sleep(100);
It means that the next line of code will start in 100 millisecond after the previous line of code."
in your case e.g.:

Counter = Counter +1;
sleep(100)
rotator1.rotateAngle = -15 + (Math.cos((Counter%40)/40*2*Math.PI)/rockRange+0.25)/Math.PI*180 ;

Well, you asked for "sleep" but I don't think that this will meet your request. Most likely it would work with a timercore, "timeout" and "set interval". Maybe someone knows the exact code (unfortunately I don't know).
I would use a gif or animated png image to get this effect. It is easy to make and doesn't need much CPU power ("sleep" needs a lot).
Attachment:
sphere.gif
sphere.gif [ 13.27 KiB | Viewed 19074 times ]


Last edited by Dagedee on November 7th, 2013, 7:03 am, edited 2 times in total.

Top
 Profile  
 
PostPosted: November 7th, 2013, 4:47 am 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887
Dagedee wrote:
I would use a gif or animated png image to get this effect. It is easy to make and doesn't need much CPU power ("sleep" needs a lot).
Attachment:
sphere.gif

Thanks Dagedee! I will modify the code and I'll post the results... :)
About the gifs or animated pngs they need work to make all the frames and unfortunately especially with gifs, I have tested in the past and the cpu increases a lot!

_________________
...and remember: don't take life too seriously...
My profile on Deviantart: http://jimking.deviantart.com/


Top
 Profile  
 
PostPosted: November 7th, 2013, 7:01 am 
Offline
User avatar

Joined: July 9th, 2012, 1:14 pm
Posts: 112
Well, I know already that you are not very enthusiastic about gifs and animated png images. :D
But I made only positive experiences so far. Animated png and gif images need very little CPU power.
(You might check the attached widget) Okay, it takes some time to create them, but it saves a lot of CPU power on the other hand.
It took me not more than 10 min to create the gifs I used for the attached widget. I'm using Photoshop to create gifs but it is also possible to use Gimp or (the easiest way) to use Photoscape http://url9.de/OEo.


Last edited by Dagedee on November 11th, 2013, 5:15 am, edited 1 time in total.

Top
 Profile  
 
PostPosted: November 7th, 2013, 7:48 am 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887
Good job Dagedee! 8-)
I only use GIMP for my widgets and yes I'm not so fun of the gifs and animated png. :lol:
But don't forget these:
1) More big and complicate image/widget = more resources
I'm almost sure that if you try to reproduce the balls movement from my widget you will see the real cpu consumption..
2) Needs a lot of images/frames so the movement will be fluid and more realistic possible.
Just compare the movement of the gif and the test widget... ;)

_________________
...and remember: don't take life too seriously...
My profile on Deviantart: http://jimking.deviantart.com/


Top
 Profile  
 
PostPosted: November 8th, 2013, 4:42 pm 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887
Any help guys with the script..? :(

_________________
...and remember: don't take life too seriously...
My profile on Deviantart: http://jimking.deviantart.com/


Top
 Profile  
 
PostPosted: November 11th, 2013, 5:23 am 
Offline
User avatar

Joined: July 9th, 2012, 1:14 pm
Posts: 112
I've created some more widgets (gif & animated png) with smoother animation now, CPU is always at zero. (Used frames are 73, but I only had to create 36 the others are just copies.) If you will use very large images than the CPU consumption will increase, that's for sure. :)
Attachment:
spheres.gif
spheres.gif [ 118.05 KiB | Viewed 19018 times ]

Attachment:
spheres_examples.rar [188.89 KiB]
Downloaded 363 times


Top
 Profile  
 
PostPosted: November 11th, 2013, 5:37 am 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887
Quote:
If you will use very large images than the CPU consumption will increase, that's for sure. :)

Yes I'm afraid so..! Damm I'm sure that only a little part is missing in my script. I just need only 1sec delay at the first run of the right ball, and after that 1sec delay for each ball at the end of their movement, when their return...
(if my calculations are right! :lol: )

_________________
...and remember: don't take life too seriously...
My profile on Deviantart: http://jimking.deviantart.com/


Top
 Profile  
 
PostPosted: November 11th, 2013, 6:28 am 
Offline
User avatar

Joined: July 9th, 2012, 1:14 pm
Posts: 112
You can determine the interval of every frame of a gif. :)
... I know you prefer a solution via script, hence I will not bug you any longer with gifs and animated pngs. :D
Attachment:
gif_setting.png
gif_setting.png [ 16.42 KiB | Viewed 19013 times ]


Last edited by Dagedee on November 11th, 2013, 10:10 am, edited 1 time in total.

Top
 Profile  
 
PostPosted: November 11th, 2013, 8:44 am 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887
No Dagedee of course you're not bother me! I appreciate your interest.. :)
Let's hope that someone will give me a hand with the script...

_________________
...and remember: don't take life too seriously...
My profile on Deviantart: http://jimking.deviantart.com/


Top
 Profile  
 
PostPosted: November 11th, 2013, 10:08 am 
Offline
User avatar

Joined: July 9th, 2012, 1:14 pm
Posts: 112
All right! :D


Top
 Profile  
 
PostPosted: November 15th, 2013, 10:39 pm 
Offline
User avatar

Joined: March 8th, 2013, 10:27 pm
Posts: 353
What's the thing with classic newtonian physics :lol: ?? :lol: :lol:
SHM was always difficult for me.... :mrgreen:

I'll see what I can do.

_________________
Life is a myriad game... Just play it!


Top
 Profile  
 
PostPosted: November 15th, 2013, 11:13 pm 
Offline
User avatar

Joined: March 8th, 2013, 10:27 pm
Posts: 353
Add a datetimecore and set it to update the datetimecore1OnUpdate
Code:
var even = false;      //set true to start animation from left

function datetimecore1OnUpdate(Sender)
{
  //do your animation!!!
  if(even) {
    for(i = 7; i >= 0; i--)
    {
        sleep(62); //delay(62); ???
        right.RotateAngle = i;
    }
    for(i = 1; i <= 8; i++)
    {
        sleep(62); //delay(62); ???
        right.RotateAngle = i;
    }
  } else { //odd
  for(i = 353; i <= 360; i++)
    {
        sleep(62); //delay(62); ???
        left.RotateAngle = i;
    }
    for(i = 359; i >= 352; i--)
    {
        sleep(62); //delay(62); ???
        left.RotateAngle = i;
    }
  }
  even = !even;
}

had to 'simulate' shake animation in code. Though not so perfect but... :( Works with rocketing CPU's unfortunately. Couldn't help, the sleep() kills the CPU time! (Usage goes upto 10%-15%)

Xwidget had a delay function but it appears that Tony had removed it (still exists in Autocomplete though!). That was a bit soft on the CPU

_________________
Life is a myriad game... Just play it!


Top
 Profile  
 
PostPosted: November 16th, 2013, 2:49 am 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887
Thanks man!!! And yes I tested and the CPU is not good.. I will try to modify the delay times a bit so the movement will be more realistic as possible. There is too much delay between the balls at the end of their movement. About the delay function I will ask Tony if can provide me a patch with the delay enable. But I think that the other users must have the patch too so the widget will work fine on their pc right..? :(

_________________
...and remember: don't take life too seriously...
My profile on Deviantart: http://jimking.deviantart.com/


Top
 Profile  
 
PostPosted: November 19th, 2013, 6:47 pm 
Offline
User avatar

Joined: March 8th, 2013, 10:27 pm
Posts: 353
Yeah

_________________
Life is a myriad game... Just play it!


Top
 Profile  
 
PostPosted: November 19th, 2013, 6:53 pm 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887
digigamer wrote:
Yeah

Just leave it man..! So much trouble... :|

_________________
...and remember: don't take life too seriously...
My profile on Deviantart: http://jimking.deviantart.com/


Top
 Profile  
 
PostPosted: December 3rd, 2013, 3:22 pm 
Offline

Joined: October 26th, 2013, 8:17 am
Posts: 362
i never had this kind of clock, so i don't know how exactly these clocks work,
but i guessed it should be this way:
so here's my solution:

Attachment:
Pendulum_Sphere_Clock.XWidgetPkg [254.49 KiB]
Downloaded 357 times


and just to note:
left ball doesn't have shadow on the ground


Top
 Profile  
 
PostPosted: December 3rd, 2013, 3:54 pm 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887
hamid wrote:
i never had this kind of clock, so i don't know how exactly these clocks work,
but i guessed it should be this way:
so here's my solution:

Attachment:
Pendulum_Sphere_Clock.XWidgetPkg


and just to note:
left ball doesn't have shadow on the ground

Oh my God!!!! UNBELIEVABLE! :shock:
You did it!!! How?!
Yes I know about the ball shadows but this was the minimum...
Really I don't know what can I say....

T H A N K S

I will finish the design and I will post it as soon as possible! :D

_________________
...and remember: don't take life too seriously...
My profile on Deviantart: http://jimking.deviantart.com/


Top
 Profile  
 
PostPosted: December 14th, 2013, 9:11 am 
Offline
User avatar

Joined: March 8th, 2013, 10:27 pm
Posts: 353
viewtopic.php?f=10&t=3667
Some interesting things were found here... it solves the cpu usage problem nicely, the rotateto() function specifically

_________________
Life is a myriad game... Just play it!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 28 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 41 guests


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