draw.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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, and the go1_*.go files, just contains the API exported by the
  13. // image/draw package in the standard library. Other files in this package
  14. // provide additional features.
  15. import (
  16. "image"
  17. "image/draw"
  18. )
  19. // Draw calls DrawMask with a nil mask.
  20. func Draw(dst Image, r image.Rectangle, src image.Image, sp image.Point, op Op) {
  21. draw.Draw(dst, r, src, sp, draw.Op(op))
  22. }
  23. // DrawMask aligns r.Min in dst with sp in src and mp in mask and then
  24. // replaces the rectangle r in dst with the result of a Porter-Duff
  25. // composition. A nil mask is treated as opaque.
  26. func DrawMask(dst Image, r image.Rectangle, src image.Image, sp image.Point, mask image.Image, mp image.Point, op Op) {
  27. draw.DrawMask(dst, r, src, sp, mask, mp, draw.Op(op))
  28. }
  29. // FloydSteinberg is a Drawer that is the Src Op with Floyd-Steinberg error
  30. // diffusion.
  31. var FloydSteinberg Drawer = floydSteinberg{}
  32. type floydSteinberg struct{}
  33. func (floydSteinberg) Draw(dst Image, r image.Rectangle, src image.Image, sp image.Point) {
  34. draw.FloydSteinberg.Draw(dst, r, src, sp)
  35. }