Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@xiprox
Created January 2, 2016 13:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xiprox/6026aed4d8b1e3a995f1 to your computer and use it in GitHub Desktop.
Save xiprox/6026aed4d8b1e3a995f1 to your computer and use it in GitHub Desktop.
A ShowcaseDrawer that draws showcase circle with the greater side of a view divided by 2 as its radius value.
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.view.View;
import com.github.amlcurran.showcaseview.MaterialShowcaseDrawer;
/**
* A {@link com.github.amlcurran.showcaseview.ShowcaseDrawer} that draws showcase circle with the
* greater side of a view divided by 2 as its radius value.
*/
public class ViewBasedRadiusShowcaseDrawer extends MaterialShowcaseDrawer {
private float mRadius;
private Paint mEraserPaint;
public ViewBasedRadiusShowcaseDrawer(Resources resources, View view) {
super(resources);
mRadius = Math.max(view.getHeight(), view.getWidth()) / 2;
mEraserPaint = new Paint();
mEraserPaint.setColor(0xFFFFFF);
mEraserPaint.setAlpha(0);
mEraserPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.MULTIPLY));
mEraserPaint.setAntiAlias(true);
}
@Override
public void drawShowcase(Bitmap buffer, float x, float y, float scaleMultiplier) {
Canvas bufferCanvas = new Canvas(buffer);
bufferCanvas.drawCircle(x, y, mRadius, mEraserPaint);
}
@Override
public int getShowcaseWidth() {
return (int) (mRadius * 2);
}
@Override
public int getShowcaseHeight() {
return (int) (mRadius * 2);
}
@Override
public float getBlockedRadius() {
return mRadius;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment