Slide 25
Slide 25 text
Paint it (black)
• Knows how to colour the
pixels
• All drawing calls need a Paint
• Handles text as well
• TextPaint subclass
CC-BY-NC-ND Mark Chadwick on Flickr
Paint is the object that holds the informations about how to paint something on a Canvas. Actually, all drawing operations require that you pass a Paint
along. It’s really the intuitive idea of the paint that you use to draw something in real life: if you have a canvas and a brush but no paint, there’s no way
you’re ever going to be able to draw anything.
!
Paint holds informations about the usual basic properties about how to draw: the fill color, the stroke (color, width, caps, etc), the alpha level, etc. It also
holds informations about the antialiasing to apply, the bitmap filtering (off by default) and the text hinting. Of course not all of Paint’s properties are useful
for all kinds of drawing operations.
!
Paint knows also how to measure and draw text. It holds informations on the Typeface to use, the text size, style, scaling ratio, etc. It offers methods to
measure text size (all of which do a pretty bad job at it, and each of them has a nuanced different meaning from the others, but that’s really confused and
difficult to understand), and there’s even a text-specific subclass, TextPaint, that holds more informations about the text should be measured and painted.
!
The Paint object you pass to a drawing call is used throughout the painting pipeline.