use of carbon.widget.CornerView in project Carbon by ZieIony.
the class ShadowGenerator method generateShadow.
public static Shadow generateShadow(View view, float elevation) {
if (!software && renderScript == null) {
try {
renderScript = RenderScript.create(view.getContext());
blurShader = ScriptIntrinsicBlur.create((RenderScript) renderScript, Element.U8_4((RenderScript) renderScript));
} catch (Error ignore) {
software = true;
}
}
CornerView cornerView = (CornerView) view;
int e = (int) Math.ceil(elevation);
int c = (int) Math.max(e, cornerView.getCornerRadius());
for (Object o : shadowSet) {
Shadow s = (Shadow) o;
if (s != null && s.elevation == elevation && s.c == c)
return s;
}
Bitmap bitmap;
int bitmapSize = e * 2 + 2 * c + 1;
bitmap = Bitmap.createBitmap(bitmapSize, bitmapSize, Bitmap.Config.ARGB_8888);
Canvas shadowCanvas = new Canvas(bitmap);
paint.setStyle(Paint.Style.FILL);
paint.setColor(0xffffffff);
roundRect.set(e, e, bitmapSize - e, bitmapSize - e);
shadowCanvas.drawRoundRect(roundRect, c, c, paint);
blur(bitmap, elevation);
Shadow shadow = new Shadow(bitmap, elevation, c);
shadowSet.add(shadow);
return shadow;
}
Aggregations