List of utility methods to do Canvas Draw
void | drawCross(Bitmap bm, int x, int y) draw Cross Canvas c = new Canvas(bm); Paint p = new Paint(); p.setColor(0xffff0000); c.drawLine(x - 4, y, x + 4, y, p); c.drawLine(x, y - 4, x, y + 4, p); |
void | drawSelect(Bitmap bm, int x, int y, int cellWidth, int cellHeight) draw Select Canvas canvas = new Canvas(bm); canvas.drawColor(Color.TRANSPARENT, android.graphics.PorterDuff.Mode.CLEAR); Paint paint = new Paint(); paint.setARGB(255, 255, 0, 0); paint.setStyle(Style.STROKE); paint.setStrokeWidth(3f); canvas.drawRect(new Rect((x - 1) * cellWidth, (y - 1) * cellHeight, ... |
void | drawText(String strMsg, Canvas g, Paint paint, int setx, int sety, int fg, int bg) draw Text paint.setColor(bg); g.drawText(strMsg, setx + 1, sety, paint); g.drawText(strMsg, setx, sety - 1, paint); g.drawText(strMsg, setx, sety + 1, paint); g.drawText(strMsg, setx - 1, sety, paint); paint.setColor(fg); g.drawText(strMsg, setx, sety, paint); g.restore(); ... |
void | drawTextAtCanvasCenter(Canvas canvas, Paint paint, String text) draw Text At Canvas Center if (text == null) { return; final int width = canvas.getWidth(); final int height = canvas.getHeight(); int offsetX, offsetY; offsetX = calcXWhenAlignCenter(width, paint, text); offsetY = calcYWhenAlignCenter(height, paint); ... |
void | circle(Canvas canvas, int color, int stroke, float x, float y, float radius) circle Paint paint = new Paint();
paint.setColor(color);
paint.setStyle(Paint.Style.FILL_AND_STROKE);
paint.setStrokeWidth(stroke);
canvas.drawCircle(x, y, radius, paint);
|
void | rect(Canvas canvas, int color, int stroke, float x, float y, float width, float height) rect Paint paint = new Paint(); paint.setColor(color); paint.setStyle(Paint.Style.FILL_AND_STROKE); paint.setStrokeWidth(stroke); float leftx = x; float topy = y; float rightx = x + width; float bottomy = y + height; ... |
Bitmap | add(Bitmap firstlayer, Bitmap secondlayer) combines to Bitmap s Bitmap data = Bitmap.createBitmap(secondlayer.getWidth(), secondlayer.getHeight(), secondlayer.getConfig()); Canvas temp = new Canvas(data); temp.drawBitmap(secondlayer, 0, 0, null); temp.drawBitmap(firstlayer, 0, 0, null); return data; |
Bitmap | add(Bitmap[] images) combines to Bitmap s Bitmap data = Bitmap.createBitmap(images[0].getWidth(), images[0].getHeight(), images[0].getConfig()); Canvas temp = new Canvas(data); for (int i = 0; i < images.length; i++) { temp.drawBitmap(images[i], 0, 0, null); return data; |