drawing and remove a path with animation - android

I got some points from user Touch and store them in an array ,
I draw lines (by quadTo method) between these points with Animation.
that's ok by using Value Generate Animators.
but the ask is how can I remove them with Animation?
means for example after draw lines between A and B and C points (start from A and ends in C) with Animation , how can I remove these lines after one second with Animation?(remove from start point A to end point C)
Am I missing any methods in APIs that behave for similar task I want?
or anybody can help me how can I implement it?
thanks for your attention , and sorry for my bad English:)

Related

Motion to draw numbers on android

im new to this android things. And i have to develop an application that can help an autism to learn numbers. I have a few ideas and I've been trying to learn and implement the code. But it's failed. The question is how can i apply the motion code or sprite to draw a numbers or letter? For example like this, i wanna make the penguin move through the line and draw a number nine.
There is example from mybringback.com which is the image move to draw a rectangle. How can i implement it to draw a number? Im sorry if i asking too much, i just trying to get some ideas.
I think that you should first build an utility program, in order to create the "path vector".
What I mean by path vector is simply a vector of Points (where a point has x value, and y value). And your utility should let you draw whatever you want, with a simple pen. You should draw on surface and store points when mouse is down, and ignore points when mouse is up.
Then, in the main program, you will just have to read at the path of your number/letter.
I've tried to implement something like this for the Sugar OLPC platform, without serializing path into files : I was able to draw, and to view the animation. And I used the process I've just described you.
Hope it can help you.
P.S : I used the word mouse, but you guessed that I talk about finger ...
There are various ways to achieve animation effects. One approach that is quite versatile involves creating a custom View or SurfaceView in which you Override the onDraw method. Various tutorials can be found on this; the official Android discussion of it is here:
http://developer.android.com/guide/topics/graphics/2d-graphics.html#on-view
Your implementation will look something like this:
// Find elapsed time since previous draw
// Compute new position of drawable/bitmap along figure
// Draw bitmap in appropriate location
// Add line to buffer containing segments of curve drawn so far
// Render all segments in curve buffer
// Take some action to call for the rendering of the next frame (this may be done in another thread)
Obviously a simplification. For a very simplistic tutorial, see here:
http://www.techrepublic.com/blog/software-engineer/bouncing-a-ball-on-androids-canvas/1733/
Note that different implementations of this technique will require different levels of involvement by you; for example, if you use a SurfaceView, you are in charge of calling the onDraw method, whereas subclassing the normal View lets you leave Android in charge of redrawing (at the expense of limiting your ability to draw on a different thread). In this respect, Google remains your friend =]

Moving between two points in canvas

I have 2 points(x1,y1) and (x2,y2). I need to move the image from (x1,y1) to (x2,y2). Please let me know if there is any methods in android SDK to achieve this.
If you are doing a custom view that handles it's on onDraw method you could:
Create a path object:
Move to position 1 using the moveTo method
line to position 2 using the line2 method
Create a path measure object.
User the path measure object to animate to the position.(Here is an example of that--note you will have to do it a little differently as the code doesn't show View.onDraw & View.invalidate being called).
Alternatively if you aren't handling your own on draw, you might be able to simply use a TranslateAnimation.
Looks like all you need is an animation.
Search this site for Animation Drawable and you'll get tons of examples :)

Animation sinusoid in android

I have a problem with moving animation. I want to create animation which start when I to a screen and she starts from touched place and go to end place like on this picture:
The end place is constant. How Can I do this sinusoid movement?
edit1: I want to click and when i click, show image and he goes this way to end place. I don't click and drag this picture. This picture must shows and goes to this place without my help. Only what I do is touch the screen. How I can do that?I have a problem with moving animation. I want to create animation which start when I to a screen and she starts from touched place and go to end place like on this picture:
The end place is constant. How Can I do this sinusoid movement?
edit1: I want to click and when i click, show image and he goes this way to end place. I don't click and drag this picture. This picture must shows and goes to this place without my help. Only what I do is touch the screen. How I can do that?
I wrote something like this that allows curved animation, you can see the full answer (and working code) here: Problem to achieve curved animation
It shouldn't be too difficult to either chain a number of those together, or modify the algorithm to use a cubic (or higher) function to produce multiple curves.
Only caveat is that because of the bezier curve, there is no guarantee the path will actually travel through the middle point you give it. If this is a problem again you could easily replace the bezier algorithm I use in the above example with something more suitable for your needs.
Check the sources of TranslationAnimation where the translation is done. Then build your function that maps the sinus function on the line from start to end. You could start with setting a horizontal line of with length dist(start,end) starting at (start), mapping sinus on it and then rotating it around your starting point.

Slowly Draw A Line In Android

I have a Line class composed of two Points of two ints each that I draw with a wrapper over Canvas.drawLine().
Easy so far.
I want to have that Line drawn slowly from one Point to the other. My best guess is to make a function that will dice up my Line into an list of Lines, starting from the first Point with each subsequent Line getting longer and longer till it reaches from one Point to the other. Then, I will have a Canvas.drawLine wrapper that will take that array of Lines, and iterate over them, drawing each one with a pause of some sort in between them, giving the appearance of the line "growing".
Is there something in the android libraries that already does this and/or would this be better solved some other way?
Edit: This is android 2.1
Android has libraries for creating animations. Look into tweened animations and the AnimationDrawable class.
Or maybe you can have one line with a fixed starting point and on each draw the end point increments . I believe this approach has better performance .

How to implement a DrawLine function ?

Question : Is there any better way to implement a function that draws line on the screen other than drawing circles on the input points ?
Details : I am trying to write a function which basically will draw a line.However the line will not be a regular colored line. This line will let user to copy pixels from one image to another trough that line , you can think It like "history brush" or "stamp" on Photoshop . My first thought was just get the points and draw circles on each point. Which is working but not smooth and have some bugs. The first problem is it is not working if user sweep his finger too fast. I thought it would solve problem if i can fill the dots between two points and then draw the line which is kind of work but this time drawing gets very slow. One other problem is that it never looks smooth.
Bresenham's line algorithm
Isn't the BitmapShader what you're looking for?

Categories

Resources