Skip to content

Commit 406acce

Browse files
committed
color.NRGBA -> color.RGBA
1 parent dd97b7c commit 406acce

19 files changed

Lines changed: 59 additions & 59 deletions

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ func main() {
297297

298298
## Colors
299299

300-
You can construct new colors using `gfx.ColorNRGBA` and `gfx.ColorWithAlpha`.
300+
You can construct new colors using `gfx.ColorRGBA` and `gfx.ColorWithAlpha`.
301301

302302
### Default colors
303303

colors.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import "image/color"
44

55
// Standard colors transparent, opaque, black, white, red, green, blue, cyan, magenta, and yellow.
66
var (
7-
ColorTransparent = ColorNRGBA(0, 0, 0, 0)
8-
ColorOpaque = ColorNRGBA(0xFF, 0xFF, 0xFF, 0xFF)
7+
ColorTransparent = ColorRGBA(0, 0, 0, 0)
8+
ColorOpaque = ColorRGBA(0xFF, 0xFF, 0xFF, 0xFF)
99
ColorBlack = Palette1Bit.Color(0)
1010
ColorWhite = Palette1Bit.Color(1)
1111
ColorRed = Palette3Bit.Color(1)
@@ -16,7 +16,7 @@ var (
1616
ColorYellow = Palette3Bit.Color(6)
1717

1818
// ColorByName is a map of all the default colors by name.
19-
ColorByName = map[string]color.NRGBA{
19+
ColorByName = map[string]color.RGBA{
2020
"Transparent": ColorTransparent,
2121
"Opaque": ColorOpaque,
2222
"Black": ColorBlack,
@@ -32,9 +32,9 @@ var (
3232

3333
// BlockColor contains a Light, Medium and Dark color.
3434
type BlockColor struct {
35-
Light color.NRGBA
36-
Medium color.NRGBA
37-
Dark color.NRGBA
35+
Light color.RGBA
36+
Medium color.RGBA
37+
Dark color.RGBA
3838
}
3939

4040
// Block colors, each containing a Light, Medium and Dark color.
@@ -104,26 +104,26 @@ var (
104104
}
105105
)
106106

107-
// ColorWithAlpha creates a new color.NRGBA based
107+
// ColorWithAlpha creates a new color.RGBA based
108108
// on the provided color.Color and alpha arguments.
109-
func ColorWithAlpha(c color.Color, a uint8) color.NRGBA {
110-
nc := color.NRGBAModel.Convert(c).(color.NRGBA)
109+
func ColorWithAlpha(c color.Color, a uint8) color.RGBA {
110+
nc := color.RGBAModel.Convert(c).(color.RGBA)
111111

112112
nc.A = a
113113

114114
return nc
115115
}
116116

117-
// ColorNRGBA constructs a color.NRGBA.
118-
func ColorNRGBA(r, g, b, a uint8) color.NRGBA {
119-
return color.NRGBA{r, g, b, a}
120-
}
121-
122117
// ColorRGBA constructs a color.RGBA.
123118
func ColorRGBA(r, g, b, a uint8) color.RGBA {
124119
return color.RGBA{r, g, b, a}
125120
}
126121

122+
// ColorNRGBA constructs a color.NRGBA.
123+
func ColorNRGBA(r, g, b, a uint8) color.NRGBA {
124+
return color.NRGBA{r, g, b, a}
125+
}
126+
127127
// LerpColors performs linear interpolation between two colors.
128128
func LerpColors(c0, c1 color.Color, t float64) color.Color {
129129
switch {

colors_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
)
77

88
func TestColorWithAlpha(t *testing.T) {
9-
c := ColorWithAlpha(ColorNRGBA(255, 0, 0, 255), 128)
9+
c := ColorWithAlpha(ColorRGBA(255, 0, 0, 255), 128)
1010

1111
if got, want := c.A, uint8(128); got != want {
1212
t.Fatalf("c.A = %d, want %d", got, want)

doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ There is rudimentary support for making animations using gfx.Animation, the anim
220220
221221
Colors
222222
223-
You can construct new colors using gfx.ColorNRGBA and gfx.ColorWithAlpha.
223+
You can construct new colors using gfx.ColorRGBA and gfx.ColorWithAlpha.
224224
225225
Default colors
226226

draw_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ import "testing"
55
func TestDrawOver(t *testing.T) {
66
src := NewImage(3, 3)
77

8-
src.SetNRGBA(1, 1, ColorNRGBA(75, 0, 130, 64))
8+
src.SetRGBA(1, 1, ColorRGBA(75, 0, 130, 64))
99

1010
dst := NewImage(3, 3, ColorMagenta)
1111

1212
DrawOver(dst, dst.Bounds(), src, ZP)
1313
}
1414

1515
func TestDrawSrc(t *testing.T) {
16-
src := NewImage(3, 3, ColorNRGBA(0, 255, 0, 64))
16+
src := NewImage(3, 3, ColorRGBA(0, 255, 0, 64))
1717
dst := NewImage(3, 3, ColorMagenta)
1818

1919
DrawSrc(dst, dst.Bounds(), src, ZP)

image.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import (
1313
var ZP = image.ZP
1414

1515
// NewImage creates an image of the given size (optionally filled with a color)
16-
func NewImage(w, h int, colors ...color.Color) *image.NRGBA {
17-
m := NewNRGBA(IR(0, 0, w, h))
16+
func NewImage(w, h int, colors ...color.Color) *image.RGBA {
17+
m := NewRGBA(IR(0, 0, w, h))
1818

1919
if len(colors) > 0 {
2020
DrawColor(m, m.Bounds(), colors[0])

imdraw.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ var _ BasicTarget = (*IMDraw)(nil)
5959

6060
type point struct {
6161
pos Vec
62-
col color.NRGBA
62+
col color.RGBA
6363
pic Vec
6464
in float64
6565
precision int
@@ -123,7 +123,7 @@ func (imd *IMDraw) Draw(t Target) {
123123
// the position.
124124
func (imd *IMDraw) Push(pts ...Vec) {
125125
opts := point{
126-
col: imd.Color.(color.NRGBA),
126+
col: imd.Color.(color.RGBA),
127127
pic: imd.Picture,
128128
in: imd.Intensity,
129129
precision: imd.Precision,
@@ -317,7 +317,7 @@ func (imd *IMDraw) outlineRectangle(thickness float64) {
317317
for i := 0; i+1 < len(points); i++ {
318318
a, b := points[i], points[i+1]
319319
mid := a
320-
mid.col = mixNRGBA(a.col, b.col)
320+
mid.col = mixRGBA(a.col, b.col)
321321
mid.in = (a.in + b.in) / 2
322322

323323
imd.pushPt(a.pos, a)
@@ -613,8 +613,8 @@ func (imd *IMDraw) polyline(thickness float64, closed bool) {
613613
imd.restorePoints(points)
614614
}
615615

616-
func mixNRGBA(c1, c2 color.NRGBA) color.NRGBA {
617-
return color.NRGBA{
616+
func mixRGBA(c1, c2 color.RGBA) color.RGBA {
617+
return color.RGBA{
618618
c1.R/2 + c2.R/2,
619619
c1.G/2 + c2.G/2,
620620
c1.B/2 + c2.B/2,

interfaces.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ type TrianglesPosition interface {
8585
// TrianglesColor specifies Triangles with Color property.
8686
type TrianglesColor interface {
8787
Triangles
88-
Color(i int) color.NRGBA
88+
Color(i int) color.RGBA
8989
}
9090

9191
// TrianglesPicture specifies Triangles with Picture propery.
@@ -125,7 +125,7 @@ type TargetPicture interface {
125125
// Positions outside the Picture's Bounds must return full transparent (Alpha(0)).
126126
type PictureColor interface {
127127
Picture
128-
Color(at Vec) color.NRGBA
128+
Color(at Vec) color.RGBA
129129
}
130130

131131
// Float64Scaler can scale a float64 to another float64.

layer.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ func NewLayer(tileset *Tileset, width int, data LayerData) *Layer {
4343

4444
// At returns the color at (x, y).
4545
func (l *Layer) At(x, y int) color.Color {
46-
return l.NRGBAAt(x, y)
46+
return l.RGBAAt(x, y)
4747
}
4848

49-
// NRGBAAt returns the color.NRGBA at (x, y).
50-
func (l *Layer) NRGBAAt(x, y int) color.NRGBA {
49+
// RGBAAt returns the color.RGBA at (x, y).
50+
func (l *Layer) RGBAAt(x, y int) color.RGBA {
5151
if i := l.TileIndexAt(x, y); i > -1 {
5252
s := l.Tileset.Size
5353

54-
return l.Tileset.Tiles[i].NRGBAAt(x%s.X, y%s.Y)
54+
return l.Tileset.Tiles[i].RGBAAt(x%s.X, y%s.Y)
5555
}
5656

5757
return ColorTransparent
@@ -90,7 +90,7 @@ func (l *Layer) Bounds() image.Rectangle {
9090

9191
// ColorModel returns the color model for the paletted layer.
9292
func (l *Layer) ColorModel() color.Model {
93-
return color.NRGBAModel
93+
return color.RGBAModel
9494
}
9595

9696
// ColorIndexAt returns the palette index of the pixel at (x, y).

layer_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ func TestLayerAt(t *testing.T) {
5757
}
5858
}
5959

60-
func TestLayerNRGBAAt(t *testing.T) {
60+
func TestLayerRGBAAt(t *testing.T) {
6161
l := newTestLayer()
6262

63-
if got, want := l.NRGBAAt(-1, 100), ColorTransparent; got != want {
64-
t.Fatalf("l.NRGBAAt(-1, 100) = %v, want %v", got, want)
63+
if got, want := l.RGBAAt(-1, 100), ColorTransparent; got != want {
64+
t.Fatalf("l.RGBAAt(-1, 100) = %v, want %v", got, want)
6565
}
6666

67-
if got, want := l.NRGBAAt(2, 2), ColorNRGBA(66, 110, 93, 255); got != want {
68-
t.Fatalf("l.NRGBAAt(2, 2) = %v, want %v", got, want)
67+
if got, want := l.RGBAAt(2, 2), ColorRGBA(66, 110, 93, 255); got != want {
68+
t.Fatalf("l.RGBAAt(2, 2) = %v, want %v", got, want)
6969
}
7070
}
7171

@@ -98,7 +98,7 @@ func TestLayerBounds(t *testing.T) {
9898
func TestLayerColorModel(t *testing.T) {
9999
l := newTestLayer()
100100

101-
if l.ColorModel() != color.NRGBAModel {
101+
if l.ColorModel() != color.RGBAModel {
102102
t.Fatalf("unexpected color model")
103103
}
104104
}

0 commit comments

Comments
 (0)