1package drawing
2
3import (
4	"image"
5	"image/color"
6
7	"golang.org/x/image/draw"
8	"golang.org/x/image/math/f64"
9
10	"github.com/golang/freetype/raster"
11)
12
13// Painter implements the freetype raster.Painter and has a SetColor method like the RGBAPainter
14type Painter interface {
15	raster.Painter
16	SetColor(color color.Color)
17}
18
19// DrawImage draws an image into dest using an affine transformation matrix, an op and a filter
20func DrawImage(src image.Image, dest draw.Image, tr Matrix, op draw.Op, filter ImageFilter) {
21	var transformer draw.Transformer
22	switch filter {
23	case LinearFilter:
24		transformer = draw.NearestNeighbor
25	case BilinearFilter:
26		transformer = draw.BiLinear
27	case BicubicFilter:
28		transformer = draw.CatmullRom
29	}
30	transformer.Transform(dest, f64.Aff3{tr[0], tr[1], tr[4], tr[2], tr[3], tr[5]}, src, src.Bounds(), op, nil)
31}
32