Drawing a Moustache: the moustache function (I)
28
func moustache(m image.Image, x, y, size, droopFactor int) image.Image {
mrgba := rgba(m) // Create specialized RGBA image from m.
p := raster.NewRGBAPainter(mrgba)
p.SetColor(image.RGBAColor{0, 0, 0, 255})
w, h := m.Bounds().Dx(), m.Bounds().Dy()
r := raster.NewRasterizer(w, h)
var (
mag = raster.Fix32((10 + size) << 8)
width = pt(20, 0).Mul(mag)
mid = pt(x, y)
droop = pt(0, droopFactor).Mul(mag)
left = mid.Sub(width).Add(droop)
right = mid.Add(width).Add(droop)
bow = pt(0, 5).Mul(mag).Sub(droop)
curlx = pt(10, 0).Mul(mag)
curly = pt(0, 2).Mul(mag)
risex = pt(2, 0).Mul(mag)
risey = pt(0, 5).Mul(mag)
)
// continued on next slide...