List of usage examples for android.graphics Paint setStyle
public void setStyle(Style style)
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);//w ww .j av a 2s . co m paint.setColor(backgroundColor); canvas.drawRect(0, 0, width, height, paint); }
From source file:Main.java
public static void drawCropRect(Canvas canvas, RectF bounds) { Paint p = new Paint(); p.setStyle(Paint.Style.STROKE); p.setColor(Color.WHITE);// w w w.j av a 2 s. c o m p.setStrokeWidth(3); canvas.drawRect(bounds, p); }
From source file:Main.java
@NonNull static Paint createPaint(int color) { final Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setStyle(STROKE); paint.setColor(color);//from ww w . j av a 2 s. c o m return paint; }
From source file:Main.java
public static void drawShade(Canvas canvas, RectF bounds) { int w = canvas.getWidth(); int h = canvas.getHeight(); Paint p = new Paint(); p.setStyle(Paint.Style.FILL); p.setColor(Color.BLACK & 0x88000000); RectF r = new RectF(); r.set(0, 0, w, bounds.top);//from w ww. j a va 2 s .c o m canvas.drawRect(r, p); r.set(0, bounds.top, bounds.left, h); canvas.drawRect(r, p); r.set(bounds.left, bounds.bottom, w, h); canvas.drawRect(r, p); r.set(bounds.right, bounds.top, w, bounds.bottom); canvas.drawRect(r, p); }
From source file:Main.java
public static void drawBorder(int width, int height, Canvas canvas, Paint paint, Path workingPath) { paint.setStyle(Paint.Style.STROKE); workingPath.reset();//from w ww . ja v a 2 s . c om workingPath.moveTo(0, 0); workingPath.lineTo(width, 0); workingPath.lineTo(width, height); workingPath.lineTo(0, height); workingPath.lineTo(0, 0); workingPath.close(); canvas.drawPath(workingPath, paint); }
From source file:Main.java
public static Paint getPaint(Paint.Style style, int color) { Paint mPaint = new Paint(); mPaint.setAntiAlias(true);/*from w w w.j a v a2 s. co m*/ mPaint.setStyle(style); mPaint.setColor(color); mPaint.setTextSize(30); return mPaint; }
From source file:Main.java
public static void drawRuleOfThird(Canvas canvas, RectF bounds) { Paint p = new Paint(); p.setStyle(Paint.Style.STROKE); p.setColor(Color.argb(128, 255, 255, 255)); p.setStrokeWidth(2);/*from w w w . j av a 2s .c om*/ float stepX = bounds.width() / 3.0f; float stepY = bounds.height() / 3.0f; float x = bounds.left + stepX; float y = bounds.top + stepY; for (int i = 0; i < 2; i++) { canvas.drawLine(x, bounds.top, x, bounds.bottom, p); x += stepX; } for (int j = 0; j < 2; j++) { canvas.drawLine(bounds.left, y, bounds.right, y, p); y += stepY; } }
From source file:Main.java
public static BitmapDrawable writeOnDrawable(Activity actv, Resources res, int drawableId, String text, int textSize) { Bitmap bm = BitmapFactory.decodeResource(res, drawableId).copy(Bitmap.Config.ARGB_8888, true); DisplayMetrics dm = new DisplayMetrics(); actv.getWindowManager().getDefaultDisplay().getMetrics(dm); int pixelSize = (int) ((textSize * dm.scaledDensity)); if (text.length() > 2) { pixelSize = (int) ((textSize * dm.scaledDensity) * (0.5 - (text.length() / 10))); }//from w w w . jav a 2 s . c o m Paint paint = new Paint(); paint.setStyle(Style.FILL); paint.setColor(Color.WHITE); paint.setTextSize(pixelSize); paint.setTextAlign(Paint.Align.CENTER); // float adjust = paint.measureText(text); Canvas canvas = new Canvas(bm); int xPos = (int) ((bm.getWidth() / 2)); int yPos = (int) ((bm.getHeight() / 2) - ((paint.descent() + paint.ascent()) / 2)); canvas.drawText(text, xPos, yPos, paint); return new BitmapDrawable(res, bm); }
From source file:Main.java
public static Bitmap highlightSelectedFaceThumbnail(Bitmap originalBitmap) { Bitmap bitmap = originalBitmap.copy(Bitmap.Config.ARGB_8888, true); Canvas canvas = new Canvas(bitmap); Paint paint = new Paint(); paint.setAntiAlias(true);//from ww w . j av a 2 s. com paint.setStyle(Paint.Style.STROKE); paint.setColor(Color.parseColor("#3399FF")); int stokeWidth = Math.max(originalBitmap.getWidth(), originalBitmap.getHeight()) / 10; if (stokeWidth == 0) { stokeWidth = 1; } bitmap.getWidth(); paint.setStrokeWidth(stokeWidth); canvas.drawRect(0, 0, bitmap.getWidth(), bitmap.getHeight(), paint); return bitmap; }
From source file:Main.java
public static Paint getUIPainter() { Paint uiPaint = new Paint(Paint.ANTI_ALIAS_FLAG); uiPaint.setColor(Color.argb(128, 255, 255, 255)); uiPaint.setStyle(Style.STROKE); uiPaint.setStrokeWidth((float) 3.0); return uiPaint; }