go1_8.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. // +build !go1.9,!go1.8.typealias
  5. package draw
  6. import (
  7. "image"
  8. "image/color"
  9. "image/draw"
  10. )
  11. // Drawer contains the Draw method.
  12. type Drawer interface {
  13. // Draw aligns r.Min in dst with sp in src and then replaces the
  14. // rectangle r in dst with the result of drawing src on dst.
  15. Draw(dst Image, r image.Rectangle, src image.Image, sp image.Point)
  16. }
  17. // Image is an image.Image with a Set method to change a single pixel.
  18. type Image interface {
  19. image.Image
  20. Set(x, y int, c color.Color)
  21. }
  22. // Op is a Porter-Duff compositing operator.
  23. type Op int
  24. const (
  25. // Over specifies ``(src in mask) over dst''.
  26. Over Op = Op(draw.Over)
  27. // Src specifies ``src in mask''.
  28. Src Op = Op(draw.Src)
  29. )
  30. // Draw implements the Drawer interface by calling the Draw function with
  31. // this Op.
  32. func (op Op) Draw(dst Image, r image.Rectangle, src image.Image, sp image.Point) {
  33. (draw.Op(op)).Draw(dst, r, src, sp)
  34. }
  35. // Quantizer produces a palette for an image.
  36. type Quantizer interface {
  37. // Quantize appends up to cap(p) - len(p) colors to p and returns the
  38. // updated palette suitable for converting m to a paletted image.
  39. Quantize(p color.Palette, m image.Image) color.Palette
  40. }