Skip to content

Commit 25bf792

Browse files
committed
image/color: add alpha-premultiplied comment.
Change-Id: I9968f53a8286a0e5ccc197a9b5fae499e2f95326 Reviewed-on: https://go-review.googlesource.com/7790 Reviewed-by: Rob Pike <[email protected]>
1 parent 4f35ad6 commit 25bf792

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/image/color/color.go

+13-4
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,17 @@ type Color interface {
1212
// for the color. Each value ranges within [0, 0xFFFF], but is represented
1313
// by a uint32 so that multiplying by a blend factor up to 0xFFFF will not
1414
// overflow.
15+
//
16+
// An alpha-premultiplied color component c has been scaled by alpha (a),
17+
// so has valid values 0 <= c <= a.
1518
RGBA() (r, g, b, a uint32)
1619
}
1720

18-
// RGBA represents a traditional 32-bit alpha-premultiplied color,
19-
// having 8 bits for each of red, green, blue and alpha.
21+
// RGBA represents a traditional 32-bit alpha-premultiplied color, having 8
22+
// bits for each of red, green, blue and alpha.
23+
//
24+
// An alpha-premultiplied color component C has been scaled by alpha (A), so
25+
// has valid values 0 <= C <= A.
2026
type RGBA struct {
2127
R, G, B, A uint8
2228
}
@@ -33,8 +39,11 @@ func (c RGBA) RGBA() (r, g, b, a uint32) {
3339
return
3440
}
3541

36-
// RGBA64 represents a 64-bit alpha-premultiplied color,
37-
// having 16 bits for each of red, green, blue and alpha.
42+
// RGBA64 represents a 64-bit alpha-premultiplied color, having 16 bits for
43+
// each of red, green, blue and alpha.
44+
//
45+
// An alpha-premultiplied color component C has been scaled by alpha (A), so
46+
// has valid values 0 <= C <= A.
3847
type RGBA64 struct {
3948
R, G, B, A uint16
4049
}

0 commit comments

Comments
 (0)