制作在一个圆形的时尚形象消失 [英] Making image disappear in a circular fashion

查看:163
本文介绍了制作在一个圆形的时尚形象消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个圆的的图片。我想把它显示给用户,在第一。

I have an image of a circle. I want to display it to the user, at first.

CountDownTimer onTick()的方法,我希望它平稳消失,部门逐界,以循环方式。下面是说明想什么,我要更好的方式图像:

In a CountDownTimer's onTick() method, I want it to disappear smoothly, sector-by-sector, in a circular fashion. Below is an image that explains what I'd like to way better:

灰色区域实际上是透明的。

onFinish() CountDownTimer 图像应该完全消失。

In the onFinish() of the CountDownTimer the image should disappear completely.

1)我想这是可以做到用 Canvas.drawArc()。我将不得不计算角度,划出一道弧线,并填充透明色圆形图像的该部门,对吧?

1) I guess this can be done using Canvas.drawArc(). I would have to calculate the angle, draw an arc and fill that sector of the circle image with transparent color, right?

new CountDownTimer(fullSpan, tick) {

    public void onTick(long millisUntilFinished) {
        int angle = (fullSpan-millisUntilFinished) / fullSpan * 360;
        drawSector(angle);  //draw a transparent sector
    }

    public void onFinish() {
        drawSector(360);  //draw a transparent circle
    }
}.start();

2)我怀疑有可能是实现这一目标的更好的方法。我没有在Android 画布的经验。我可以从更有经验的人的建议?

2) I suspect there might be a better way of achieving this. I don't have any experience on Android Canvas. Can I have suggestions from the more experienced ones?

推荐答案

填充透明色的圆形图像的该部门,对吧? 错误结果
如果你把一个透明的颜色比任何其他的结果是,你会看到垫层色彩(因为是透明的定义不可见)。结果
相反,您可以擦除并重新绘制形状填充(在你的插图黑色)。

fill that sector of the circle image with transparent color, right? wrong.
If you put a transparent color over any other, the result is that you will see the underlaying color (since transparent is invisible by definition).
Instead, you could erase and redraw the filled (black in your illustration) shape.

一个机会可能是,如果背景是一个纯色。结果
然后,您可以透明/使用同样的颜色作为背景,以掩盖与不断扩大的弧(在图中的灰色部分)圆删除。

One chance could be if the background was a solid color.
Then you could fake transparency/erasing by using the very same color as the background to cover up the circle with an expanding arc (the grey part in your illustration).

这篇关于制作在一个圆形的时尚形象消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆