Example usage for android.graphics Paint Paint

List of usage examples for android.graphics Paint Paint

Introduction

In this page you can find the example usage for android.graphics Paint Paint.

Prototype

public Paint() 

Source Link

Document

Create a new paint with default settings.

Usage

From source file:Main.java

public static Paint getGameOverColor() {
    Paint paint = new Paint();
    paint.setColor(Color.WHITE);//from w  w  w. ja  v  a 2  s .  co  m
    paint.setTextSize(80);
    paint.setTypeface(Typeface.DEFAULT_BOLD);
    paint.setShadowLayer(2, 3, 3, Color.GRAY);
    return paint;
}

From source file:Main.java

public static void drawBackground(Canvas canvas, int backgroundColor, int width, int height) {
    Paint paint = new Paint();
    paint.setStyle(Paint.Style.FILL_AND_STROKE);
    paint.setAntiAlias(true);/*from w w  w.j  av  a 2 s  . c o  m*/
    paint.setColor(backgroundColor);
    canvas.drawRect(0, 0, width, height, paint);
}

From source file:Main.java

public static Paint getGameOverRestartMessageColor() {
    Paint paint = new Paint();
    paint.setColor(Color.YELLOW);
    paint.setTextSize(20);/*www  .  java2  s . c o m*/
    paint.setTypeface(Typeface.DEFAULT_BOLD);
    //        paint.setShadowLayer(2, 3, 3, Color.WHITE);
    return paint;
}

From source file:Main.java

public static Paint getNewPaintColorFilter(int colorInt) {
    Paint paint = new Paint();
    paint.setColorFilter(new PorterDuffColorFilter(colorInt, PorterDuff.Mode.MULTIPLY));
    return paint;
}

From source file:Main.java

public static void drawCircleBorder(Canvas canvas, int radius, int w, int y) {
    Paint paint = new Paint();
    paint.setAntiAlias(true);//from w ww  . ja va 2  s  . com
    paint.setFilterBitmap(true);
    paint.setDither(true);
    paint.setColor(Color.WHITE);
    paint.setStyle(Paint.Style.STROKE);
    paint.setStrokeWidth(mBorderThickness);
    canvas.drawCircle(w / 2, y / 2, radius, paint);
}

From source file:Main.java

public static void erase(Canvas canvas, RectF rectf) {
    Paint paint = new Paint();
    paint.setColor(0);/*from   w w w  . j  a v a2  s .com*/
    paint.setDither(true);
    paint.setXfermode(new PorterDuffXfermode(android.graphics.PorterDuff.Mode.CLEAR));
    canvas.drawRect(rectf, paint);
}

From source file:Main.java

public static void drawKnots(Canvas canvas, List<PointF> knots, int color) {
    Log.d("GammaGraph", "function drawKnots");
    Paint paint = new Paint();
    paint.setAntiAlias(true);//from   w  w w . j  a  va  2 s.  c  om
    paint.setColor(color);
    paint.setStrokeWidth(7);
    for (PointF knot : knots) {
        canvas.drawPoint(knot.x, knot.y, paint);
    }
}

From source file:Main.java

public static Bitmap changeBitmapColor(Bitmap bmp, int color) {
    Bitmap b = Bitmap.createBitmap(bmp.getWidth(), bmp.getHeight(), bmp.getConfig());
    Canvas canvas = new Canvas(b);
    Paint paint = new Paint();
    paint.setColor(color);/*w w  w. j  av  a  2s .c  o  m*/
    paint.setAntiAlias(true);
    canvas.drawBitmap(bmp, bmp.getWidth(), bmp.getHeight(), paint);
    return b;
}

From source file:Main.java

public static Bitmap getRemoveBitmap(Context context, Bitmap bitmap) {
    Paint paint = new Paint();
    paint.setAntiAlias(true);//  w  w w.j  av a 2  s  .  c o  m
    Bitmap bitmap1;
    try {
        Bitmap bitmap2 = BitmapFactory.decodeStream(context.getAssets().open("remove@2x.png"));
        bitmap1 = Bitmap.createBitmap(bitmap.getWidth() + bitmap2.getWidth() / 2,
                bitmap.getHeight() + bitmap2.getHeight() / 2, android.graphics.Bitmap.Config.ARGB_8888);
        Canvas canvas1 = new Canvas(bitmap1);
        canvas1.drawARGB(0, 0, 0, 0);
        canvas1.drawBitmap(bitmap, bitmap2.getWidth() / 2, bitmap2.getHeight() / 2, paint);
        bitmap.recycle();
        canvas1.drawBitmap(bitmap2, 0.0F, 0.0F, paint);
        bitmap2.recycle();
    } catch (IOException ioexception) {
        ioexception.printStackTrace();
        bitmap1 = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(),
                android.graphics.Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmap1);
        canvas.drawARGB(0, 0, 0, 0);
        canvas.drawBitmap(bitmap, 0.0F, 0.0F, paint);
        bitmap.recycle();
    }
    return bitmap1;
}

From source file:Main.java

public static Bitmap setShadow(Bitmap bitmap, int radius) {
    BlurMaskFilter blurFilter = new BlurMaskFilter(radius, BlurMaskFilter.Blur.OUTER);
    Paint shadowPaint = new Paint();
    shadowPaint.setAlpha(50);/*from   w w w  . j  ava2s . c o  m*/
    shadowPaint.setColor(0xff424242);
    shadowPaint.setMaskFilter(blurFilter);
    int[] offsetXY = new int[2];
    Bitmap shadowBitmap = bitmap.extractAlpha(shadowPaint, offsetXY);
    Bitmap shadowImage32 = shadowBitmap.copy(Bitmap.Config.ARGB_8888, true);
    Canvas c = new Canvas(shadowImage32);
    c.drawBitmap(bitmap, -offsetXY[0], -offsetXY[1], null);
    return shadowImage32;
}