Skip to content

Instantly share code, notes, and snippets.

@trfiladelfo
Forked from kidfolk/circleimage.java
Created April 16, 2013 14:47
Show Gist options
  • Save trfiladelfo/5396512 to your computer and use it in GitHub Desktop.
Save trfiladelfo/5396512 to your computer and use it in GitHub Desktop.
protected void onDraw(Canvas canvas){
super.onDraw(canvas);
// init shader
BitmapShader shader;
shader = new BitmapShader(originalBitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
// init paint
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setShader(shader);
int circleCenter = width / 2;
// circleCenter is the x or y of the view's center
// radius is the radius in pixels of the cirle to be drawn
// paint contains the shader that will texture the shape
canvas.drawCircle(circleCenter, circleCenter, radus, paint);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment