draw.go 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. // Package draw provides image composition functions.
  5. //
  6. // See "The Go image/draw package" for an introduction to this package:
  7. // http://golang.org/doc/articles/image_draw.html
  8. //
  9. // This package is a superset of and a drop-in replacement for the image/draw
  10. // package in the standard library.
  11. package draw
  12. // This file just contains the API exported by the image/draw package in the
  13. // standard library. Other files in this package provide additional features.
  14. import (
  15. "image"
  16. "image/draw"
  17. )
  18. // Draw calls DrawMask with a nil mask.
  19. func Draw(dst Image, r image.Rectangle, src image.Image, sp image.Point, op Op) {
  20. draw.Draw(dst, r, src, sp, draw.Op(op))
  21. }
  22. // DrawMask aligns r.Min in dst with sp in src and mp in mask and then
  23. // replaces the rectangle r in dst with the result of a Porter-Duff
  24. // composition. A nil mask is treated as opaque.
  25. func DrawMask(dst Image, r image.Rectangle, src image.Image, sp image.Point, mask image.Image, mp image.Point, op Op) {
  26. draw.DrawMask(dst, r, src, sp, mask, mp, draw.Op(op))
  27. }
  28. // Drawer contains the Draw method.
  29. type Drawer = draw.Drawer
  30. // FloydSteinberg is a Drawer that is the Src Op with Floyd-Steinberg error
  31. // diffusion.
  32. var FloydSteinberg Drawer = floydSteinberg{}
  33. type floydSteinberg struct{}
  34. func (floydSteinberg) Draw(dst Image, r image.Rectangle, src image.Image, sp image.Point) {
  35. draw.FloydSteinberg.Draw(dst, r, src, sp)
  36. }
  37. // Image is an image.Image with a Set method to change a single pixel.
  38. type Image = draw.Image
  39. // Op is a Porter-Duff compositing operator.
  40. type Op = draw.Op
  41. const (
  42. // Over specifies ``(src in mask) over dst''.
  43. Over Op = draw.Over
  44. // Src specifies ``src in mask''.
  45. Src Op = draw.Src
  46. )
  47. // Quantizer produces a palette for an image.
  48. type Quantizer = draw.Quantizer