public OvalShadow(int shadowRadius, int circleDiameter) {
super();
mShadowPaint = new Paint();
mShadowRadius = shadowRadius;
mCircleDiameter = circleDiameter;
mRadialGradient = new RadialGradient(mCircleDiameter / 2, mCircleDiameter / 2,
mShadowRadius, new int[]{
FILL_SHADOW_COLOR, Color.TRANSPARENT
}, null, Shader.TileMode.CLAMP);
mShadowPaint.setShader(mRadialGradient);
}
java类android.graphics.Shader的实例源码
MaterialProgressDrawable.java 文件源码
项目:JD-Test
阅读 35
收藏 0
点赞 0
评论 0
Cloud.java 文件源码
项目:LandscapeView
阅读 28
收藏 0
点赞 0
评论 0
public void draw(Canvas canvas) {
canvas.save(Canvas.MATRIX_SAVE_FLAG);
canvas.scale(scale, 0.8f * scale, x, y);
for (Puff p : puffs) {
LandscapeView.paint.setShader(new RadialGradient(x + p.x, y + p.y - p.size / 2, p.size, new int[]{0xffffffff, p.color}, new float[]{0.9f, 1}, Shader.TileMode.CLAMP));
LandscapeView.paint.setAlpha(255);
canvas.drawCircle(x + p.x, y + p.y, p.size, LandscapeView.paint);
}
canvas.restore();
}
RoundCircleImageView.java 文件源码
项目:Rxjava2.0Demo
阅读 24
收藏 0
点赞 0
评论 0
public RoundCircleImageView(Bitmap mBitmap) {
this.mBitmap = mBitmap;
mPaint = new Paint();
mPaint.setAntiAlias(true);
BitmapShader shader = new BitmapShader(mBitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
mPaint.setShader(shader);
mWidth = Math.min(mBitmap.getWidth(), mBitmap.getHeight());
}
RoundImageDrawable.java 文件源码
项目:Rxjava2.0Demo
阅读 23
收藏 0
点赞 0
评论 0
public RoundImageDrawable(Bitmap bitmap) {
mBitmap = bitmap;
BitmapShader shader = new BitmapShader(bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
mPaint = new Paint();
mPaint.setAntiAlias(true);
mPaint.setShader(shader);
mRectF = new RectF();
}
BubbleRank.java 文件源码
项目:bubble-rank
阅读 21
收藏 0
点赞 0
评论 0
private void setBitmapShaders(int index, Bitmap bitmap) {
if (bitmap != null && getBigRadius() > 0 && getSmallRadius() > 0) {
bigPicShaders.put(
index,
new BitmapShader(
getResizedBitmap(bitmap, getBigRadius() * 2, getBigRadius() * 2),
Shader.TileMode.CLAMP, Shader.TileMode.CLAMP));
smallPicShaders.put(
index,
new BitmapShader(
getResizedBitmap(bitmap, getSmallRadius() * 2, getSmallRadius() * 2),
Shader.TileMode.CLAMP, Shader.TileMode.CLAMP));
}
}
CircleImageView.java 文件源码
项目:KUtils-master
阅读 36
收藏 0
点赞 0
评论 0
private void setup() {
if (!mReady) {
mSetupPending = true;
return;
}
if (mBitmap == null) {
return;
}
mBitmapShader = new BitmapShader(mBitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
mBitmapPaint.setAntiAlias(true);
mBitmapPaint.setShader(mBitmapShader);
mBorderPaint.setStyle(Paint.Style.STROKE);
mBorderPaint.setAntiAlias(true);
mBorderPaint.setColor(mBorderColor);
mBorderPaint.setStrokeWidth(mBorderWidth);
mBitmapHeight = mBitmap.getHeight();
mBitmapWidth = mBitmap.getWidth();
mBorderRect.set(0, 0, getWidth(), getHeight());
mBorderRadius = Math.min((mBorderRect.height() - mBorderWidth) / 2, (mBorderRect.width() - mBorderWidth) / 2);
mDrawableRect.set(mBorderWidth, mBorderWidth, mBorderRect.width() - mBorderWidth, mBorderRect.height() - mBorderWidth);
mDrawableRadius = Math.min(mDrawableRect.height() / 2, mDrawableRect.width() / 2);
updateShaderMatrix();
invalidate();
}
WXComponent.java 文件源码
项目:ucar-weex-core
阅读 28
收藏 0
点赞 0
评论 0
public void setBackgroundImage(@NonNull String bgImage) {
if ("".equals(bgImage.trim())) {
getOrCreateBorder().setImage(null);
} else {
Shader shader = WXResourceUtils.getShader(bgImage, mDomObj.getLayoutWidth(), mDomObj.getLayoutHeight());
getOrCreateBorder().setImage(shader);
}
}
WXResourceUtils.java 文件源码
项目:ucar-weex-core
阅读 21
收藏 0
点赞 0
评论 0
/**
* Assembly gradients
* @param image gradient values contains direction、colors
* @param width component width
* @param height component height
* @return gradient shader
*/
public static Shader getShader(String image, float width, float height) {
List<String> valueList = parseGradientValues(image);
if (valueList != null && valueList.size() == 3) {
float[] points = parseGradientDirection(valueList.get(0), width, height);
Shader shader = new LinearGradient(points[0], points[1],
points[2], points[3],
getColor(valueList.get(1), Color.WHITE), getColor(valueList.get(2), Color.WHITE),
Shader.TileMode.REPEAT);
return shader;
}
return null;
}
TerminalBackDrawable.java 文件源码
项目:terminal-seekbar
阅读 26
收藏 0
点赞 0
评论 0
@Override
public void draw(Canvas canvas) {
terminalPaint.setStyle(Paint.Style.FILL);
terminalPaint.setColor(color);
terminalPaint.setAlpha(alpha);
//int[] toAlpha = new int[]{Color.argb(255, Color.red(255), Color.green(255), Color.blue(255)), Color.argb(0, Color.red(0), Color.green(0), Color.blue(0))};
int[] toAlpha = new int[]{Color.argb(255, 255, 255, 225),Color.argb(0, 0, 0, 0)};
RadialGradient shader = new RadialGradient(cx, cy, radius, toAlpha, null, Shader.TileMode.MIRROR);
terminalPaint.setShader(shader);
terminalPaint.setStrokeJoin(Paint.Join.ROUND);
terminalPaint.setStrokeCap(Paint.Cap.ROUND);
canvas.drawCircle(cx, cy, radius, terminalPaint);
}
SwipeBackLayout.java 文件源码
项目:RLibrary
阅读 32
收藏 0
点赞 0
评论 0
/**
* 绘制侧滑时, 左边的渐变线
*/
protected void drawSwipeLine(Canvas canvas) {
if (mTargetView != null && mTargetView.getLeft() != getMeasuredWidth()) {
mDimRect.set(mTargetView.getLeft() - dimWidth, 0, mTargetView.getLeft(), getMeasuredHeight());
mPaint.setAlpha((int) (255 * (1 - (mTargetView.getLeft() * 1f / getMeasuredWidth()))));
mPaint.setShader(new LinearGradient(mDimRect.left, 0, mDimRect.right, 0,
new int[]{Color.TRANSPARENT, Color.parseColor("#40000000")}, null, Shader.TileMode.CLAMP));
canvas.drawRect(mDimRect, mPaint);
}
}