Skip to content

Commit

Permalink
Added code to draw a frame around the sketch, to illustrate that you …
Browse files Browse the repository at this point in the history
…can draw more things than just the bitmap in onDraw().
  • Loading branch information
Jocelyn Becker committed Jan 24, 2018
1 parent ec872ec commit a617cde
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,20 @@ protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
// Draw the bitmap that has the saved path.
canvas.drawBitmap(mExtraBitmap, 0, 0, null);

@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);

// Draw the bitmap that has the saved path.
canvas.drawBitmap(mExtraBitmap, 0, 0, null);

// Draw a frame around the picture.
int inset = 40;
Rect myFrame = new Rect (inset, inset,
getScreenWidth() - inset, getScreenHeight() - inset);
canvas.drawRect(myFrame, mPaint);
}
}

// Variables for the latest x,y values,
Expand Down Expand Up @@ -151,4 +165,15 @@ public boolean onTouchEvent(MotionEvent event) {
}
return true;
}


// Get the width of the screen
public static int getScreenWidth() {
return Resources.getSystem().getDisplayMetrics().widthPixels;
}

// Get the height of the screen
public static int getScreenHeight() {
return Resources.getSystem().getDisplayMetrics().heightPixels;
}
}

0 comments on commit a617cde

Please sign in to comment.