Shubhadeep Chaudhuri
- Forum posts: 1
Aug 29, 2012, 9:49:01 PM via Website
Aug 29, 2012 9:49:01 PM via Website
Well I'm trying to create this kind of animation where an image emerges from the center
And this is the code I'm using
But the animation is very lagging. I understand it is because of the amount of modifications to the clip path in each frame.
So an alternative way to do this would really help. I couldn't think of anything else.
And this is the code I'm using
1int size = 5;
2Paint p = new Paint();
3Path path = new Path();
4
5private void animate() {
6 for (int i = 0; i < 20; i++) {
7 path.addCircle(centerX, centerY, size, Path.Direction.CCW);
8 canvas.clipPath(path);
9 canvas.drawBitmap(bmp, 0, 0, null);
10 path.reset();
11 int incr = size;
12 while (p.getAlpha() != 0) {
13 incr += 1;
14 p.setAlpha(p.getAlpha() - 5);
15 path.addCircle(centerX, centerY, incr, Path.Direction.CCW);
16 canvas.clipPath(path, Op.UNION);
17 canvas.drawBitmap(bmp, 0, 0, p);
18 path.reset();
19 }
20 size += 10;
21 }
22}
2Paint p = new Paint();
3Path path = new Path();
4
5private void animate() {
6 for (int i = 0; i < 20; i++) {
7 path.addCircle(centerX, centerY, size, Path.Direction.CCW);
8 canvas.clipPath(path);
9 canvas.drawBitmap(bmp, 0, 0, null);
10 path.reset();
11 int incr = size;
12 while (p.getAlpha() != 0) {
13 incr += 1;
14 p.setAlpha(p.getAlpha() - 5);
15 path.addCircle(centerX, centerY, incr, Path.Direction.CCW);
16 canvas.clipPath(path, Op.UNION);
17 canvas.drawBitmap(bmp, 0, 0, p);
18 path.reset();
19 }
20 size += 10;
21 }
22}
But the animation is very lagging. I understand it is because of the amount of modifications to the clip path in each frame.
So an alternative way to do this would really help. I couldn't think of anything else.
— modified on Aug 29, 2012, 9:49:54 PM
Recommended editorial content
With your consent, external content is loaded here.
By clicking on the button above, you agree that external content may be displayed to you. Personal data may be transmitted to third-party providers in the process. You can find more information about this in our Privacy Policy.