12. A Canvas works for you as a pretense, or
interface, to the actual surface upon which your
graphics will be drawn — it holds all of your
"draw" calls
13.
14. Tl;dr: Canvas is the class that translates
drawing actions into a Bitmap
81. We want our view
to vignette the
image set in the
layout
82. You have to:
Create a RadialGradient
(psst, getMeasuredHeight & getMeasuredWidth)
Assign to the Paint object
Use canvas.drawPaint(Paint) to fill it
83. Pro:
Avoid instantiate in the onDrawMethod
(onSizeChanged is your friend)
Use the drawable size, not the View size
Check ScaleMode and Padding behaviour
97. Create a new bitmap to hold the image
Create a temporary canvas for it
Draw the imageView image on the canvas
Save the canvas using a paint with the PorterDuff
setup the bounds of the drawable mask
Draw the mask on the temporary canvas
Restore the temporary canvas
Draw the bitmap on the real canvas
98. Pro:
Optimize it to avoid instatiation in the onDraw
Play around with ratios
123. You have to:
Calculate center
Create a matrix
Set the rotation of the matrix
Create a new Bitmap as big as view
Create the canvas of that Bitmap
Draw image on the canvas with the matrix
Draw the resulting bitmap on the main canvas
124. Pro:
Connect a seekBar with the rotation (wow!)
Do it without and with optimization
(is it noticeable?)