Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1304)

Delta Between Two Patch Sets: draw/draw.go

Issue 101670045: code review 101670045: go.image/draw: new package, a superset of the standard ...
Left Patch Set: Created 9 years, 9 months ago
Right Patch Set: diff -r e492ffa4cad4 https://code.google.com/p/go.image Created 9 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | draw/scale.go » ('j') | draw/scale.go » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2014 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.
12 package 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
17 import (
18 "image"
19 "image/color"
20 "image/draw"
21 )
22
23 // Draw calls DrawMask with a nil mask.
24 func Draw(dst Image, r image.Rectangle, src image.Image, sp image.Point, op Op) {
25 draw.Draw(dst, r, src, sp, draw.Op(op))
26 }
27
28 // DrawMask aligns r.Min in dst with sp in src and mp in mask and then
29 // replaces the rectangle r in dst with the result of a Porter-Duff
30 // composition. A nil mask is treated as opaque.
31 func DrawMask(dst Image, r image.Rectangle, src image.Image, sp image.Point, mas k image.Image, mp image.Point, op Op) {
32 draw.DrawMask(dst, r, src, sp, mask, mp, draw.Op(op))
33 }
34
35 // Drawer contains the Draw method.
36 type Drawer interface {
37 // Draw aligns r.Min in dst with sp in src and then replaces the
38 // rectangle r in dst with the result of drawing src on dst.
39 Draw(dst Image, r image.Rectangle, src image.Image, sp image.Point)
40 }
41
42 // FloydSteinberg is a Drawer that is the Src Op with Floyd-Steinberg error
43 // diffusion.
44 var FloydSteinberg Drawer = floydSteinberg{}
45
46 type floydSteinberg struct{}
47
48 func (floydSteinberg) Draw(dst Image, r image.Rectangle, src image.Image, sp ima ge.Point) {
49 draw.FloydSteinberg.Draw(dst, r, src, sp)
50 }
51
52 // Image is an image.Image with a Set method to change a single pixel.
53 type Image interface {
54 image.Image
55 Set(x, y int, c color.Color)
56 }
57
58 // Op is a Porter-Duff compositing operator.
59 type Op int
60
61 const (
62 // Over specifies ``(src in mask) over dst''.
63 Over Op = Op(draw.Over)
64 // Src specifies ``src in mask''.
65 Src Op = Op(draw.Src)
66 )
67
68 // Draw implements the Drawer interface by calling the Draw function with
69 // this Op.
70 func (op Op) Draw(dst Image, r image.Rectangle, src image.Image, sp image.Point) {
71 (draw.Op(op)).Draw(dst, r, src, sp)
72 }
73
74 // Quantizer produces a palette for an image.
75 type Quantizer interface {
76 // Quantize appends up to cap(p) - len(p) colors to p and returns the
77 // updated palette suitable for converting m to a paletted image.
78 Quantize(p color.Palette, m image.Image) color.Palette
79 }
LEFTRIGHT
« no previous file | draw/scale.go » ('j') | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b