android.graphics.RadialGradient Java Examples
The following examples show how to use
android.graphics.RadialGradient.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SVGHandlerTest.java From CustomShapeImageView with Apache License 2.0 | 6 votes |
@Test public void testParseRadialGradient() throws Exception { //given when(picture.beginRecording(anyInt(), anyInt())).thenReturn(canvas); SVGParser.SVGHandler parserHandler = spy(this.parserHandler); RadialGradient gradient = mock(RadialGradient.class); PowerMockito.whenNew(RadialGradient.class).withArguments( eq(10.1f), eq(4.1f), eq(5.0f), eq(new int[]{-65536}), eq(new float[]{10.1f}), eq(Shader.TileMode.CLAMP) ).thenReturn(gradient); //when startSVG(parserHandler); startElement(parserHandler, attributes(attr("id", "g1"), attr("cx", "10.1"), attr("cy", "4.1"), attr("r", "5.0")), "radialGradient"); startElement(parserHandler, attributes(attr("offset", "10.1"), attr("style", "stop-color:ff0000")), "stop"); endElement(parserHandler, "stop"); endElement(parserHandler, "radialGradient"); startElement(parserHandler, attributes(attr("width", "100"), attr("height", "100"), attr("fill", "url(#g1)")), "rect"); endElement(parserHandler, "rect"); endSVG(parserHandler); //then verify(paint).setShader(gradient); ; }
Example #2
Source File: AndroidGraphics.java From CodenameOne with GNU General Public License v2.0 | 6 votes |
public void fillRadialGradient(int startColor, int endColor, int x, int y, int width, int height, int startAngle, int arcAngle) { boolean antialias = paint.isAntiAlias(); paint.setStyle(Paint.Style.FILL); paint.setAntiAlias(false); paint.setAlpha(255); paint.setShader(new RadialGradient(x+width/2, y+width/2, Math.max(width, height)/2, 0xff000000 | startColor, 0xff000000 | endColor, Shader.TileMode.MIRROR)); canvas.save(); applyTransform(); this.tmprectF.set(x, y, x + width, y + height); canvas.drawArc(this.tmprectF, 360 - startAngle, -arcAngle, true, paint); //canvas.drawRect(x, y, x + width, y + height, paint); paint.setAntiAlias(antialias); paint.setShader(null); unapplyTransform(); canvas.restore(); }
Example #3
Source File: ColorPicker.java From SystemBarTint with Apache License 2.0 | 6 votes |
private Bitmap createColorWheelBitmap(int width, int height) { Bitmap bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888); int colorCount = 12; int colorAngleStep = 360 / 12; int colors[] = new int[colorCount + 1]; float hsv[] = new float[] { 0f, 1f, 1f }; for (int i = 0; i < colors.length; i++) { hsv[0] = (i * colorAngleStep + 180) % 360; colors[i] = Color.HSVToColor(hsv); } colors[colorCount] = colors[0]; SweepGradient sweepGradient = new SweepGradient(width / 2, height / 2, colors, null); RadialGradient radialGradient = new RadialGradient(width / 2, height / 2, colorWheelRadius, 0xFFFFFFFF, 0x00FFFFFF, TileMode.CLAMP); ComposeShader composeShader = new ComposeShader(sweepGradient, radialGradient, PorterDuff.Mode.SRC_OVER); colorWheelPaint.setShader(composeShader); Canvas canvas = new Canvas(bitmap); canvas.drawCircle(width / 2, height / 2, colorWheelRadius, colorWheelPaint); return bitmap; }
Example #4
Source File: MultiPropertyAnimation.java From AnimationApiDemos with Apache License 2.0 | 6 votes |
private ShapeHolder addBall(float x, float y) { OvalShape circle = new OvalShape(); circle.resize(BALL_SIZE, BALL_SIZE); ShapeDrawable drawable = new ShapeDrawable(circle); ShapeHolder shapeHolder = new ShapeHolder(drawable); shapeHolder.setX(x); shapeHolder.setY(y); int red = (int) (100 + Math.random() * 155); int green = (int) (100 + Math.random() * 155); int blue = (int) (100 + Math.random() * 155); int color = 0xff000000 | red << 16 | green << 8 | blue; Paint paint = drawable.getPaint(); int darkColor = 0xff000000 | red / 4 << 16 | green / 4 << 8 | blue / 4; RadialGradient gradient = new RadialGradient(37.5f, 12.5f, 50f, color, darkColor, Shader.TileMode.CLAMP); paint.setShader(gradient); shapeHolder.setPaint(paint); balls.add(shapeHolder); return shapeHolder; }
Example #5
Source File: ThemeEditorView.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
private Bitmap createColorWheelBitmap(int width, int height) { Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); int colorCount = 12; int colorAngleStep = 360 / 12; int colors[] = new int[colorCount + 1]; float hsv[] = new float[] { 0.0f, 1.0f, 1.0f }; for (int i = 0; i < colors.length; i++) { hsv[0] = (i * colorAngleStep + 180) % 360; colors[i] = Color.HSVToColor(hsv); } colors[colorCount] = colors[0]; SweepGradient sweepGradient = new SweepGradient(width / 2, height / 2, colors, null); RadialGradient radialGradient = new RadialGradient(width / 2, height / 2, colorWheelRadius, 0xffffffff, 0x00ffffff, Shader.TileMode.CLAMP); ComposeShader composeShader = new ComposeShader(sweepGradient, radialGradient, PorterDuff.Mode.SRC_OVER); colorWheelPaint.setShader(composeShader); Canvas canvas = new Canvas(bitmap); canvas.drawCircle(width / 2, height / 2, colorWheelRadius, colorWheelPaint); return bitmap; }
Example #6
Source File: DefaultLockerHitCellView.java From LockDemo with Apache License 2.0 | 6 votes |
@Override public void draw(@NonNull Canvas canvas, @NonNull CellBean cellBean, boolean isError) { final int saveCount = canvas.save(); // draw outer circle this.paint.setColor(this.getOuterColor(isError)); canvas.drawCircle(cellBean.x, cellBean.y, cellBean.radius, this.paint); // draw fill circle Paint mPaint = new Paint(); mRadialGradient = new RadialGradient(cellBean.x, cellBean.y, cellBean.radius - this.getLineWidth() * 4, getGradientColor(isError),Color.WHITE, Shader.TileMode.REPEAT ); mPaint.setShader(mRadialGradient); canvas.drawCircle(cellBean.x, cellBean.y, cellBean.radius - this.getLineWidth() * 4, mPaint); // draw inner circle this.paint.setColor(this.getColor(isError)); canvas.drawCircle(cellBean.x, cellBean.y, cellBean.radius / 4f, this.paint); canvas.restoreToCount(saveCount); }
Example #7
Source File: BagDrawable.java From ClassifyView with Apache License 2.0 | 6 votes |
@Override public void draw(Canvas canvas) { if (keepShow||inMerge) { canvas.save(); canvas.clipRect(getBounds()); mRectF.set(getBounds()); mRectF.inset(mOutlinePadding, mOutlinePadding); if (mOutLineWidth > 0) { mOutlinePaint.setStrokeWidth(mOutLineWidth); mRectF.inset(mOutLineWidth, mOutLineWidth); mOutlinePaint.setColor(mOutLineColor); canvas.drawRoundRect(mRectF, mRadius, mRadius, mOutlinePaint); } // mPaint.setShader(new SweepGradient(mRectF.centerX(),mRectF.centerY(),mColors,mPositions)); mPaint.setShader(new RadialGradient(mRectF.centerX(), mRectF.centerY(), mRectF.width(), mCenterColor, mEdgeColor, Shader.TileMode.CLAMP)); canvas.drawRoundRect(mRectF, mRadius, mRadius, mPaint); canvas.restore(); } }
Example #8
Source File: BeaconMap.java From BLE-Indoor-Positioning with Apache License 2.0 | 6 votes |
protected void drawBeaconBackground(Canvas canvas, Beacon beacon, PointF beaconCenter) { float distance = (float) canvasProjection.getCanvasUnitsFromMeters(beacon.getDistance()); canvas.drawCircle(beaconCenter.x, beaconCenter.y, distance, beaconRangePaint); float advertisingRadius = (float) canvasProjection.getCanvasUnitsFromMeters(beacon.getEstimatedAdvertisingRange()); Paint innerBeaconRangePaint = new Paint(beaconRangePaint); innerBeaconRangePaint.setAlpha(100); Shader rangeShader = new RadialGradient( beaconCenter.x, beaconCenter.y, advertisingRadius - (pixelsPerDip * 0), primaryFillPaint.getColor(), beaconRangePaint.getColor(), Shader.TileMode.MIRROR); innerBeaconRangePaint.setShader(rangeShader); //canvas.drawCircle(beaconCenter.x, beaconCenter.y, advertisingRadius, innerBeaconRangePaint); canvas.drawCircle(beaconCenter.x, beaconCenter.y, advertisingRadius, beaconRangePaint); }
Example #9
Source File: RangeSliderViewEx.java From AndroidReview with GNU General Public License v3.0 | 6 votes |
@AnimateMethod public void setRadius(final float radius) { rippleRadius = radius; if (rippleRadius > 0) { RadialGradient radialGradient = new RadialGradient( downX, downY, rippleRadius * 3, Color.TRANSPARENT, Color.BLACK, Shader.TileMode.MIRROR ); ripplePaint.setShader(radialGradient); } invalidate(); }
Example #10
Source File: MultiPropertyAnimation.java From codeexamples-android with Eclipse Public License 1.0 | 6 votes |
private ShapeHolder addBall(float x, float y) { OvalShape circle = new OvalShape(); circle.resize(BALL_SIZE, BALL_SIZE); ShapeDrawable drawable = new ShapeDrawable(circle); ShapeHolder shapeHolder = new ShapeHolder(drawable); shapeHolder.setX(x); shapeHolder.setY(y); int red = (int)(100 + Math.random() * 155); int green = (int)(100 + Math.random() * 155); int blue = (int)(100 + Math.random() * 155); int color = 0xff000000 | red << 16 | green << 8 | blue; Paint paint = drawable.getPaint(); int darkColor = 0xff000000 | red/4 << 16 | green/4 << 8 | blue/4; RadialGradient gradient = new RadialGradient(37.5f, 12.5f, 50f, color, darkColor, Shader.TileMode.CLAMP); paint.setShader(gradient); shapeHolder.setPaint(paint); balls.add(shapeHolder); return shapeHolder; }
Example #11
Source File: PieChart.java From XCL-Charts with Apache License 2.0 | 6 votes |
/** * 给画笔设置渲染颜色和效果 * @param paintArc 画笔 * @param cirX 中心点X坐标 * @param cirY 中心点Y坐标 * @param radius 半径 * @return 返回渲染效果类 */ private RadialGradient renderRadialGradient(Paint paintArc, float cirX, float cirY, float radius) { float radialRadius = radius * 0.8f; int color = paintArc.getColor(); int darkerColor = DrawHelper.getInstance().getDarkerColor(color); RadialGradient radialGradient = new RadialGradient(cirX, cirY, radialRadius, darkerColor,color, Shader.TileMode.MIRROR); //返回环形渐变 return radialGradient; }
Example #12
Source File: AndroidGraphics.java From CodenameOne with GNU General Public License v2.0 | 6 votes |
public void fillRectRadialGradient(int startColor, int endColor, int x, int y, int width, int height, float relativeX, float relativeY, float relativeSize) { boolean antialias = paint.isAntiAlias(); paint.setStyle(Paint.Style.FILL); paint.setAntiAlias(false); paint.setAlpha(255); float radius = Math.min((float)width, (float)height) * relativeSize; int centerX = (int) (width * (1 - relativeX)); int centerY = (int) (height * (1 - relativeY)); paint.setShader(new RadialGradient(x + centerX, y + centerY, radius, 0xff000000 | startColor, 0xff000000 | endColor, Shader.TileMode.MIRROR)); canvas.save(); applyTransform(); canvas.drawRect(x, y, x + width, y + height, paint); paint.setAntiAlias(antialias); paint.setShader(null); unapplyTransform(); canvas.restore(); }
Example #13
Source File: ThemeEditorView.java From Telegram with GNU General Public License v2.0 | 6 votes |
private Bitmap createColorWheelBitmap(int width, int height) { Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); int colorCount = 12; int colorAngleStep = 360 / 12; int[] colors = new int[colorCount + 1]; float[] hsv = new float[]{0.0f, 1.0f, 1.0f}; for (int i = 0; i < colors.length; i++) { hsv[0] = (i * colorAngleStep + 180) % 360; colors[i] = Color.HSVToColor(hsv); } colors[colorCount] = colors[0]; SweepGradient sweepGradient = new SweepGradient(width / 2, height / 2, colors, null); RadialGradient radialGradient = new RadialGradient(width / 2, height / 2, colorWheelRadius, 0xffffffff, 0x00ffffff, Shader.TileMode.CLAMP); ComposeShader composeShader = new ComposeShader(sweepGradient, radialGradient, PorterDuff.Mode.SRC_OVER); colorWheelPaint.setShader(composeShader); Canvas canvas = new Canvas(bitmap); canvas.drawCircle(width / 2, height / 2, colorWheelRadius, colorWheelPaint); return bitmap; }
Example #14
Source File: ThemeEditorView.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
private Bitmap createColorWheelBitmap(int width, int height) { Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); int colorCount = 12; int colorAngleStep = 360 / 12; int colors[] = new int[colorCount + 1]; float hsv[] = new float[] { 0.0f, 1.0f, 1.0f }; for (int i = 0; i < colors.length; i++) { hsv[0] = (i * colorAngleStep + 180) % 360; colors[i] = Color.HSVToColor(hsv); } colors[colorCount] = colors[0]; SweepGradient sweepGradient = new SweepGradient(width / 2, height / 2, colors, null); RadialGradient radialGradient = new RadialGradient(width / 2, height / 2, colorWheelRadius, 0xffffffff, 0x00ffffff, Shader.TileMode.CLAMP); ComposeShader composeShader = new ComposeShader(sweepGradient, radialGradient, PorterDuff.Mode.SRC_OVER); colorWheelPaint.setShader(composeShader); Canvas canvas = new Canvas(bitmap); canvas.drawCircle(width / 2, height / 2, colorWheelRadius, colorWheelPaint); return bitmap; }
Example #15
Source File: MultiColorPicker.java From Android-Color-Picker with Apache License 2.0 | 6 votes |
private Bitmap createColorWheelBitmap(int width, int height) { Bitmap bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888); int colorCount = 12; int colorAngleStep = 360 / 12; int colors[] = new int[colorCount + 1]; float hsv[] = new float[] { 0f, 1f, 1f }; for (int i = 0; i < colors.length; i++) { hsv[0] = (i * colorAngleStep + 180) % 360; colors[i] = Color.HSVToColor(hsv); } colors[colorCount] = colors[0]; SweepGradient sweepGradient = new SweepGradient(width / 2, height / 2, colors, null); RadialGradient radialGradient = new RadialGradient(width / 2, height / 2, colorWheelRadius, 0xFFFFFFFF, 0x00FFFFFF, TileMode.CLAMP); ComposeShader composeShader = new ComposeShader(sweepGradient, radialGradient, PorterDuff.Mode.SRC_OVER); colorWheelPaint.setShader(composeShader); Canvas canvas = new Canvas(bitmap); canvas.drawCircle(width / 2, height / 2, colorWheelRadius, colorWheelPaint); return bitmap; }
Example #16
Source File: ColorPicker.java From Mi-Band with GNU General Public License v2.0 | 6 votes |
private Bitmap createColorWheelBitmap(int width, int height) { Bitmap bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888); int colorCount = 12; int colorAngleStep = 360 / 12; int colors[] = new int[colorCount + 1]; float hsv[] = new float[]{0f, 1f, 1f}; for (int i = 0; i < colors.length; i++) { hsv[0] = (i * colorAngleStep + 180) % 360; colors[i] = Color.HSVToColor(hsv); } colors[colorCount] = colors[0]; SweepGradient sweepGradient = new SweepGradient(width / 2, height / 2, colors, null); RadialGradient radialGradient = new RadialGradient(width / 2, height / 2, colorWheelRadius, 0xFFFFFFFF, 0x00FFFFFF, TileMode.CLAMP); ComposeShader composeShader = new ComposeShader(sweepGradient, radialGradient, PorterDuff.Mode.SRC_OVER); colorWheelPaint.setShader(composeShader); Canvas canvas = new Canvas(bitmap); canvas.drawCircle(width / 2, height / 2, colorWheelRadius, colorWheelPaint); return bitmap; }
Example #17
Source File: FlyoutMenuView.java From FlyoutMenus with MIT License | 6 votes |
Bitmap createMenuShadowBitmap() { menuShadowRadius = (int) flyoutMenuView.menuElevation * 2; menuShadowInset = menuShadowRadius / 2; int size = 2 * menuShadowRadius + 1; Bitmap shadowBitmap = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); shadowBitmap.eraseColor(0x0); // clear Paint paint = new Paint(); paint.setAntiAlias(true); paint.setShader(new RadialGradient( menuShadowRadius + 1, menuShadowRadius + 1, menuShadowRadius, ColorUtils.setAlphaComponent(SHADOW_COLOR, SHADOW_ALPHA), ColorUtils.setAlphaComponent(SHADOW_COLOR, 0), Shader.TileMode.CLAMP)); Canvas canvas = new Canvas(shadowBitmap); canvas.drawRect(0, 0, size, size, paint); return shadowBitmap; }
Example #18
Source File: CircleImageView.java From SwipyRefreshLayout with MIT License | 5 votes |
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); }
Example #19
Source File: RoundedVignetteBitmapDisplayer.java From WliveTV with Apache License 2.0 | 5 votes |
@Override protected void onBoundsChange(Rect bounds) { super.onBoundsChange(bounds); RadialGradient vignette = new RadialGradient( mRect.centerX(), mRect.centerY() * 1.0f / 0.7f, mRect.centerX() * 1.3f, new int[]{0, 0, 0x7f000000}, new float[]{0.0f, 0.7f, 1.0f}, Shader.TileMode.CLAMP); Matrix oval = new Matrix(); oval.setScale(1.0f, 0.7f); vignette.setLocalMatrix(oval); paint.setShader(new ComposeShader(bitmapShader, vignette, PorterDuff.Mode.SRC_OVER)); }
Example #20
Source File: CrescentEdgeEffect.java From ticdesign with Apache License 2.0 | 5 votes |
private void updatePaint() { int deepColor = (getColor() & 0xffffff) | 0xff000000; int middleColor = (getColor() & 0xffffff) | 0x7f000000; RadialGradient radialGradient = new RadialGradient( mGlowCenterX, mGlowCenterY, mGlowRadius, new int[] {0, 0, middleColor, deepColor}, new float[] {0, CRESCENT_EDGE_STOP, CRESCENT_EDGE_MIDDLE_STOP, 1f}, Shader.TileMode.CLAMP ); mPaint.setShader(radialGradient); }
Example #21
Source File: CircleImageView.java From Android-Application-ZJB with Apache License 2.0 | 5 votes |
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); }
Example #22
Source File: GoogleCircleProgressView.java From Dota2Helper with Apache License 2.0 | 5 votes |
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); }
Example #23
Source File: CircleImageView.java From BookReader with Apache License 2.0 | 5 votes |
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); }
Example #24
Source File: RippleDrawable.java From MDPreference with Apache License 2.0 | 5 votes |
private RippleDrawable(Drawable backgroundDrawable, int backgroundAnimDuration, int backgroundColor, int rippleType, int delayClickType, int maxRippleRadius, int rippleAnimDuration, int rippleColor, Interpolator inInterpolator, Interpolator outInterpolator, int type, int topLeftCornerRadius, int topRightCornerRadius, int bottomRightCornerRadius, int bottomLeftCornerRadius, int left, int top, int right, int bottom){ setBackgroundDrawable(backgroundDrawable); mBackgroundAnimDuration = backgroundAnimDuration; mBackgroundColor = backgroundColor; mRippleType = rippleType; setDelayClickType(delayClickType); mMaxRippleRadius = maxRippleRadius; mRippleAnimDuration = rippleAnimDuration; mRippleColor = rippleColor; if(mRippleType == TYPE_TOUCH && mMaxRippleRadius <= 0) mRippleType = TYPE_TOUCH_MATCH_VIEW; mInInterpolator = inInterpolator; mOutInterpolator = outInterpolator; setMask(type, topLeftCornerRadius, topRightCornerRadius, bottomRightCornerRadius, bottomLeftCornerRadius, left, top, right, bottom); mFillPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mFillPaint.setStyle(Paint.Style.FILL); mShaderPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mShaderPaint.setStyle(Paint.Style.FILL); mBackground = new Path(); mBackgroundBounds = new RectF(); mRipplePoint = new PointF(); mMatrix = new Matrix(); mInShader = new RadialGradient(0, 0, GRADIENT_RADIUS, new int[]{mRippleColor, mRippleColor, 0}, GRADIENT_STOPS, Shader.TileMode.CLAMP); if(mRippleType == TYPE_WAVE) mOutShader = new RadialGradient(0, 0, GRADIENT_RADIUS, new int[]{0, ColorUtil.getColor(mRippleColor, 0f), mRippleColor}, GRADIENT_STOPS, Shader.TileMode.CLAMP); }
Example #25
Source File: RoundedVignetteBitmapDisplayer.java From Android-Application-ZJB with Apache License 2.0 | 5 votes |
@Override protected void onBoundsChange(Rect bounds) { super.onBoundsChange(bounds); RadialGradient vignette = new RadialGradient( mRect.centerX(), mRect.centerY() * 1.0f / 0.7f, mRect.centerX() * 1.3f, new int[]{0, 0, 0x7f000000}, new float[]{0.0f, 0.7f, 1.0f}, Shader.TileMode.CLAMP); Matrix oval = new Matrix(); oval.setScale(1.0f, 0.7f); vignette.setLocalMatrix(oval); paint.setShader(new ComposeShader(bitmapShader, vignette, PorterDuff.Mode.SRC_OVER)); }
Example #26
Source File: CircleImageView.java From mooc_hyman with Apache License 2.0 | 5 votes |
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); }
Example #27
Source File: CircleImageView.java From ShareBox with Apache License 2.0 | 5 votes |
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); }
Example #28
Source File: RoundedVignetteBitmapDisplayer.java From candybar with Apache License 2.0 | 5 votes |
@Override protected void onBoundsChange(Rect bounds) { super.onBoundsChange(bounds); RadialGradient vignette = new RadialGradient( mRect.centerX(), mRect.centerY() * 1.0f / 0.7f, mRect.centerX() * 1.3f, new int[]{0, 0, 0x7f000000}, new float[]{0.0f, 0.7f, 1.0f}, Shader.TileMode.CLAMP); Matrix oval = new Matrix(); oval.setScale(1.0f, 0.7f); vignette.setLocalMatrix(oval); paint.setShader(new ComposeShader(bitmapShader, vignette, PorterDuff.Mode.SRC_OVER)); }
Example #29
Source File: HeatMap.java From AndroidHeatMap with Apache License 2.0 | 5 votes |
/** * Draw a radial gradient at a given location. Only draws in black with the gradient being only * in transparency. * * @param canvas Canvas to draw into. * @param x The x location to draw the point. * @param y The y location to draw the point. * @param radius The radius (in pixels) of the point. * @param blurFactor A factor to scale the circles width by. * @param alpha The transparency of the gradient. */ @AnyThread private void drawDataPoint(Canvas canvas, float x, float y, double radius, double blurFactor, double alpha) { if (blurFactor == 1) { canvas.drawCircle(x, y, (float)radius, mBlack); } else { //create a radial gradient at the requested position with the requested size RadialGradient gradient = new RadialGradient(x, y, (float)(radius * blurFactor), new int[] { Color.argb((int)(alpha * 255), 0, 0, 0), Color.argb(0, 0, 0, 0) }, null, Shader.TileMode.CLAMP); mFill.setShader(gradient); canvas.drawCircle(x, y, (float)(2 * radius), mFill); } }
Example #30
Source File: RoundedVignetteBitmapDisplayer.java From letv with Apache License 2.0 | 5 votes |
protected void onBoundsChange(Rect bounds) { super.onBoundsChange(bounds); RadialGradient vignette = new RadialGradient(this.mRect.centerX(), (this.mRect.centerY() * 1.0f) / 0.7f, this.mRect.centerX() * 1.3f, new int[]{0, 0, 2130706432}, new float[]{0.0f, 0.7f, 1.0f}, TileMode.CLAMP); Matrix oval = new Matrix(); oval.setScale(1.0f, 0.7f); vignette.setLocalMatrix(oval); this.paint.setShader(new ComposeShader(this.bitmapShader, vignette, Mode.SRC_OVER)); }