2017-07-15 77 views
0

SMARTISAN OS具有這種作用的天氣應用程序:從攝氏改變格式爲華氏時,溫度數字會滾動這樣的: Motion blur effect sample如何實現這樣的運動模糊效果?

我認爲這不是數字滾動時簡單的模糊效果,因爲你可以從圖像中看到這些數字只在垂直方向上模糊。數字以低速滾動,然後更快。模糊半徑隨着滾動而變長。對我而言,這種影響並不容易實現。

+0

的相同的解決方案實際上,事實並非如此。現在你的問題是什麼? (請不要說它是「我該如何實現它」,因爲這對Stack Overflow來說太廣泛了。) –

回答

0

只需創建一個總是在畫布上繪製的自定義視圖。你必須自己處理上下運動,在這種情況下,你將無法使用簡單的內置UI元素。一旦您想要獲得滾動效果,只需多次繪製移動文本,但每次都要略微移動它,並根據其速度改變其不透明度。

在這種情況下使用OpenGL可能是一種矯枉過正,因爲這種情況只是關於文本。運動模糊將會非常困難,並且執行性能會很大,並且將文本繪製成十幾次只會對性能產生較小的影響。

希望我能幫上忙。

0

@andras

/** 
* use for 2D-Radial-Blur 
* 
* @param src 
* @param dx It effetcs the speed. you can use 1/-1 for a test 
* @param dy It effetcs the speed. you can use 1/-1 for a test 
* @param times effects motion length 
* @return 
*/ 
public static Bitmap doRadialBlur(Bitmap src, int dx, int dy, int times) { 

    Bitmap dst = Bitmap.createBitmap(src.getWidth(), src.getHeight(), Bitmap.Config.ARGB_8888); 

    Canvas canvas = new Canvas(dst); 
    Matrix matrix = new Matrix(); 
    Paint paint = new Paint(); 
    canvas.drawBitmap(src, matrix, paint); 

    paint.setAlpha(51); // 51/255 =20% 

    for (int i = 0; i < times; i++) { 
     matrix.setTranslate(i * dx, i * dy); 
     canvas.drawBitmap(src, matrix, paint); 
    } 

    return dst; 
} 

https://github.com/dkmeteor/RadialBlur-Android