1// Copyright 2015 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5// Package draw provides image composition functions.
6//
7// See "The Go image/draw package" for an introduction to this package:
8// http://golang.org/doc/articles/image_draw.html
9//
10// This package is a superset of and a drop-in replacement for the image/draw
11// package in the standard library.
12package draw
13
14// This file just contains the API exported by the image/draw package in the
15// standard library. Other files in this package provide additional features.
16
17import (
18	"image"
19	"image/draw"
20)
21
22// Draw calls DrawMask with a nil mask.
23func Draw(dst Image, r image.Rectangle, src image.Image, sp image.Point, op Op) {
24	draw.Draw(dst, r, src, sp, draw.Op(op))
25}
26
27// DrawMask aligns r.Min in dst with sp in src and mp in mask and then
28// replaces the rectangle r in dst with the result of a Porter-Duff
29// composition. A nil mask is treated as opaque.
30func DrawMask(dst Image, r image.Rectangle, src image.Image, sp image.Point, mask image.Image, mp image.Point, op Op) {
31	draw.DrawMask(dst, r, src, sp, mask, mp, draw.Op(op))
32}
33
34// Drawer contains the Draw method.
35type Drawer = draw.Drawer
36
37// FloydSteinberg is a Drawer that is the Src Op with Floyd-Steinberg error
38// diffusion.
39var FloydSteinberg Drawer = floydSteinberg{}
40
41type floydSteinberg struct{}
42
43func (floydSteinberg) Draw(dst Image, r image.Rectangle, src image.Image, sp image.Point) {
44	draw.FloydSteinberg.Draw(dst, r, src, sp)
45}
46
47// Image is an image.Image with a Set method to change a single pixel.
48type Image = draw.Image
49
50// Op is a Porter-Duff compositing operator.
51type Op = draw.Op
52
53const (
54	// Over specifies ``(src in mask) over dst''.
55	Over Op = draw.Over
56	// Src specifies ``src in mask''.
57	Src Op = draw.Src
58)
59
60// Quantizer produces a palette for an image.
61type Quantizer = draw.Quantizer
62