Android Canvas Draw rect(Canvas canvas, int color, int stroke, float x, float y, float width, float height)

Here you can find the source of rect(Canvas canvas, int color, int stroke, float x, float y, float width, float height)

Description

rect

Declaration

public static void rect(Canvas canvas, int color, int stroke, float x,
            float y, float width, float height) 

Method Source Code

//package com.java2s;
import android.graphics.Canvas;
import android.graphics.Paint;

public class Main {
    public static void rect(Canvas canvas, int color, int stroke, float x,
            float y, float width, float height) {
        Paint paint = new Paint();
        paint.setColor(color);/*from ww w .  j  av  a  2  s .com*/
        paint.setStyle(Paint.Style.FILL_AND_STROKE);
        paint.setStrokeWidth(stroke);
        float leftx = x;
        float topy = y;
        float rightx = x + width;
        float bottomy = y + height;
        canvas.drawRect(leftx, topy, rightx, bottomy, paint);
    }
}

Related

  1. drawCross(Bitmap bm, int x, int y)
  2. drawSelect(Bitmap bm, int x, int y, int cellWidth, int cellHeight)
  3. drawText(String strMsg, Canvas g, Paint paint, int setx, int sety, int fg, int bg)
  4. drawTextAtCanvasCenter(Canvas canvas, Paint paint, String text)
  5. circle(Canvas canvas, int color, int stroke, float x, float y, float radius)
  6. add(Bitmap firstlayer, Bitmap secondlayer)
  7. add(Bitmap[] images)