//newPattern creates a SurfacePattern without a Surface method. func newPattern(is cairo.ImageSurface) (cairo.Pattern, error) { p, err := cairo.NewSurfacePattern(is) if err != nil { return nil, err } return mimepattern{p.XtensionPattern}, nil }
if err = c.SetSourceSurface(i, cairo.ZP); err != nil { return err } c.Paint() return nil }}, {"image-pattern", func(c *cairo.Context) error { i, err := cairo.FromImage(img) //img declared globally and set in main if err != nil { return err } defer i.Close() sz := i.Size() pat, err := cairo.NewSurfacePattern(i) if err != nil { return err } defer pat.Close() pat.SetExtend(cairo.ExtendRepeat) off := pt(128, 128) c. Translate(off). Rotate(math.Pi / 4). Scale(pt(1/math.Sqrt2, 1/math.Sqrt2)). Translate(off.Conj()) pat.SetMatrix(cairo.NewScaleMatrix(sz.Div(256).Mul(5)))