how to change the duration of AnimationDrawable on the fly/runtime? - android-animation

Can anyone tell how to change the frame duration of AnimationDrawable on the fly/runtime/dynamically? I am having 25 frames in the AnimationDrawable i want to change the duration on seekbar progress change listener. with range of 100-80-60-40-20 means fastforwording the animation. please suggest!!!!

see my answer to this question
How can I change the duration for an Android AnimationDrawable animation on-the-fly?

Related

Mac OS: CAAnimation - seamlessly update the animation

I'm making custom UI element and I need to animate it. The problem is that at some point I need to update my animation, but when I update it, there is a visible lag/gap between current animation position (state) and new animation.
In other words, when I'm applying new animation, this animation starts from 0 position (state), while the actual (visible) state of the previous animation is different.
Here is example: (link)
<blockquote class="imgur-embed-pub" lang="en" data-id="a/q3NA31f"></blockquote><script async src="//s.imgur.com/min/embed.js" charset="utf-8"></script>
Code for animation:
CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:#"transform.rotation"];
anim.duration = time;
anim.repeatCount = INFINITY;
anim.fromValue = from;
anim.byValue = by;
[self.myLayer addAnimation:anim forKey:kActivityAnimationKey];
First applied animation have different time/from/by parameters.
ANY advices will be much appreciated, since I stuck on it on two days and tried everything that comes to head by this time.
I was able to finish this task and I will give a general answer to this question.
If you want to update your current ongoing animation, but you're in the middle of it, you need to replace current animation with animation that will end current animation on the right place.
For example, in my question there is an animation that have fromValue and byValue. It means, that if you'll start the same animation with different duration, it will change its current rotation state to fromValue.
To fix this behaviour, we need to add animation that will finish our animation from current rotation state to fromValue. To get your current rotation, or other property you need to animate, we have presentationLayer of CALayer. We can set the values from it to our "closing" animation.
How we can know when our closing animation is ended? The answer is CAAnimationDelegate. Just set up a delegate to the closing animation and when it's done - add another animation with different parameters. You can seamlessly update your animation now.
Keep in mind that closing animation time must be a fraction of your original animation time to make things smooth. You can calculate it like this: (end state - current state) * original duration.

Flash effect using front facing camera Xcode

So I have searched for hours on a solution to this and have attempted using filters with no success. I was wondering how can I create a flash effect using the front face camera but then modify the image so it looks like it added the flash as if it was using the back camera? I know a few apps such as snapchat have done this but I could not find a tutorial on how to achieve it. I have tried adjusting brightness, gamma & exposure with no success.
NOTE: I know there is no flash on a front camera for iOS.
EDIT: I am thinking it is possible by setting the screen brightness to the max, animating then going back to the previous brightness.
On an iOS device you take a screenshot when you press home + lock and the screen flashes white. Do you mean this effect? If so, try this:
Add a UIView with a white background color to your view hierarchy such that it covers the whole screen. Then, start an animation that fades the opacity of this view to zero. On completion, remove the view from its superview:
[UIView animateWithDuration: 0.5
animations: ^{
whiteView.alpha = 0.0;
}
completion: ^(BOOL finished) {
[whiteView removeFromSuperview];
}
];
If you want the entire screen to flash, add the white view to the application's UIWindow and set the frame accordingly. All buttons work all the time, if you add the white view just in the moment before the animation starts and remove it on completion - except during the short flash
I was able to make this work by increasing the system brightness right before the photo was taken, then resetting the value back. This would allow such brightness to reflect against someones face when in a dark room. If anyone wants to see the code, let me know. It is in Swift.

Animation with wxWidgets

In wxWidgets, is it possible to have on a wxPanel, an object that contains a mouse click event which moves the objects to another location when activated? The movement should be seen as an animation, e.g. Sliding from its initial location to the next location (Using wxTimer?). Is this by any means, possible?
Basically you need to change the position of whatever you are displaying smoothly so a timer at 25 Hz and then update the position a proportion of the movement each time, e.g. if you need to move from 0,0 to 100,200 smoothly in 4 seconds then updating your position by +1,+2 each timer event should do nicely. You may find that you need to invalidate a display area that includes the position before the move and after it to force a redraw but give it a try without first.

Animating a circle UIImageView to disappear

If I have a UIImageView of a circle, how could Core Animation make it disappear like in this question?
How to use CoreAnimation to animate a circle like a clock countdown
Create a CAShapeLayer. Set its path to your “clock” shape. Set it as the layer mask of your image view (e.g. imageView.layer.mask = shapeLayer).
Then you can try using a CAKeyframeAnimation to animate the shape layer's path, but I suspect the results won't be pleasing. Instead you'll probably want to use a CADisplayLink as a timer and update the shape layer's path every time it fires.
What you are looking for is known as a "clock wipe" transition.
David is pointing you in the right direction. I have a sample project on Github that shows exactly what you are looking for:
iOS Core Animation Demo
When you run the app, click on the "Mask Animation" button. It does what you're talking about. It shows an image view with a clock wipe, and then hides it again. It would be a simple matter to switch it around to have the image fully visible at first and then animate a clock wipe to hide it.

How to make radial CCProgressTimer reveal a sprite

By default, it appears that a radial CCProgressTimer starts by displaying its entire sprite and removes a portion of the sprite in counterclockwise fashion.
Is there a way to have the timer begin by displaying nothing and display more and more of the sprite as the timer progresses to completion?
Yes. Start with percentage = 100 and count down to 0.