diff --git a/audio/audio_test.go b/audio/audio_test.go index 74acec8c2..d3bdf7078 100644 --- a/audio/audio_test.go +++ b/audio/audio_test.go @@ -64,7 +64,7 @@ func TestGC(t *testing.T) { t.Error(err) } // 200[ms] should be enough all the bytes are consumed. - // TODO: This is a darty hack. Would it be possible to use virtual time? + // TODO: This is a dirty hack. Would it be possible to use virtual time? time.Sleep(200 * time.Millisecond) } t.Errorf("time out") diff --git a/audio/error_ios.go b/audio/error_ios.go index 526ac8753..d6f6b9bea 100644 --- a/audio/error_ios.go +++ b/audio/error_ios.go @@ -32,7 +32,7 @@ import ( "fmt" ) -// addErrorInfoForContextCreation adds an additional infomation to the error when creating an audio context. +// addErrorInfoForContextCreation adds an additional information to the error when creating an audio context. // See also hajimehoshi/oto#93. func addErrorInfoForContextCreation(err error) error { if err == nil { diff --git a/audio/internal/convert/resampling.go b/audio/internal/convert/resampling.go index 98d1b51e6..912f3bd0c 100644 --- a/audio/internal/convert/resampling.go +++ b/audio/internal/convert/resampling.go @@ -113,7 +113,7 @@ func (r *Resampling) src(i int64) (float64, float64, error) { if i < 0 { return 0, 0, nil } - if r.size/4 <= int64(i) { + if r.size/4 <= i { return 0, 0, nil } nextPos := int64(i) / resamplingBufferSize diff --git a/audio/wav/decode.go b/audio/wav/decode.go index 1a70e9d36..bb97aa616 100644 --- a/audio/wav/decode.go +++ b/audio/wav/decode.go @@ -102,7 +102,7 @@ func (s *stream) Seek(offset int64, whence int) (int64, error) { return n - s.headerSize, nil } -// DecodeWithSampleRate decodes WAV (RIFF) data to playable stream. +// DecodeWithoutResampling decodes WAV (RIFF) data to playable stream. // // The format must be 1 or 2 channels, 8bit or 16bit little endian PCM. // The format is converted into 2 channels and 16bit. diff --git a/blend.go b/blend.go index 99fecd67c..5d3df19df 100644 --- a/blend.go +++ b/blend.go @@ -164,7 +164,7 @@ func (b BlendFactor) internalBlendFactor(source bool) graphicsdriver.BlendFactor } } -// BlendFactor is an operation for source and destination color values. +// BlendOperation is an operation for source and destination color values. type BlendOperation byte const ( diff --git a/cmd/ebitenmobile/gomobile.go b/cmd/ebitenmobile/gomobile.go index a6f0d8d98..d8e65db97 100644 --- a/cmd/ebitenmobile/gomobile.go +++ b/cmd/ebitenmobile/gomobile.go @@ -147,7 +147,7 @@ import ( return tmp, err } - // To record gomobile to go.sum for Go 1.16 and later, go-get gomobile instaed of golang.org/x/mobile (#1487). + // To record gomobile to go.sum for Go 1.16 and later, go-get gomobile instead of golang.org/x/mobile (#1487). // This also records gobind as gomobile depends on gobind indirectly. // Using `...` doesn't work on Windows since mobile/internal/mobileinit cannot be compiled on Windows w/o Cgo (#1493). if err := runGo("get", "golang.org/x/mobile/cmd/gomobile@"+h); err != nil { diff --git a/colorm/colorm.go b/colorm/colorm.go index a51cc7298..601888f5b 100644 --- a/colorm/colorm.go +++ b/colorm/colorm.go @@ -66,7 +66,7 @@ func (c *ColorM) Apply(clr color.Color) color.Color { } // Concat multiplies a color matrix with the other color matrix. -// This is same as muptiplying the matrix other and the matrix c in this order. +// This is same as multiplying the matrix other and the matrix c in this order. func (c *ColorM) Concat(other ColorM) { o := other.impl if o == nil { diff --git a/colorm/colorm_test.go b/colorm/colorm_test.go index d84f5eb42..b8b14f6a5 100644 --- a/colorm/colorm_test.go +++ b/colorm/colorm_test.go @@ -195,32 +195,32 @@ func TestColorMApply(t *testing.T) { }{ { ColorM: colorm.ColorM{}, - In: color.RGBA{1, 2, 3, 4}, - Out: color.RGBA{1, 2, 3, 4}, + In: color.RGBA{R: 1, G: 2, B: 3, A: 4}, + Out: color.RGBA{R: 1, G: 2, B: 3, A: 4}, Delta: 0x101, }, { ColorM: mono, - In: color.NRGBA{0xff, 0xff, 0xff, 0}, + In: color.NRGBA{R: 0xff, G: 0xff, B: 0xff}, Out: color.Transparent, Delta: 0x101, }, { ColorM: mono, - In: color.RGBA{0xff, 0, 0, 0xff}, - Out: color.RGBA{0x4c, 0x4c, 0x4c, 0xff}, + In: color.RGBA{R: 0xff, A: 0xff}, + Out: color.RGBA{R: 0x4c, G: 0x4c, B: 0x4c, A: 0xff}, Delta: 0x101, }, { ColorM: shiny, - In: color.RGBA{0x80, 0x90, 0xa0, 0xb0}, - Out: color.RGBA{0xb0, 0xb0, 0xb0, 0xb0}, + In: color.RGBA{R: 0x80, G: 0x90, B: 0xa0, A: 0xb0}, + Out: color.RGBA{R: 0xb0, G: 0xb0, B: 0xb0, A: 0xb0}, Delta: 1, }, { ColorM: shift, - In: color.RGBA{0x00, 0x00, 0x00, 0x00}, - Out: color.RGBA{0x40, 0x40, 0x40, 0x80}, + In: color.RGBA{}, + Out: color.RGBA{R: 0x40, G: 0x40, B: 0x40, A: 0x80}, Delta: 0x101, }, } diff --git a/colorm/draw_test.go b/colorm/draw_test.go index 1ccc2f285..1863262df 100644 --- a/colorm/draw_test.go +++ b/colorm/draw_test.go @@ -190,7 +190,7 @@ func TestColorMAndScale(t *testing.T) { const w, h = 16, 16 src := ebiten.NewImage(w, h) - src.Fill(color.RGBA{0x80, 0x80, 0x80, 0x80}) + src.Fill(color.RGBA{R: 0x80, G: 0x80, B: 0x80, A: 0x80}) vs := []ebiten.Vertex{ { SrcX: 0, @@ -255,17 +255,17 @@ func TestColorMAndScale(t *testing.T) { switch format { case ebiten.ColorScaleModeStraightAlpha: want = color.RGBA{ - byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.5 * 0.75)), - byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.25 * 0.75)), - byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.5 * 0.75)), - byte(math.Floor(0xff * alphaBeforeScale * 0.75)), + R: byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.5 * 0.75)), + G: byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.25 * 0.75)), + B: byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.5 * 0.75)), + A: byte(math.Floor(0xff * alphaBeforeScale * 0.75)), } case ebiten.ColorScaleModePremultipliedAlpha: want = color.RGBA{ - byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.5)), - byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.25)), - byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.5)), - byte(math.Floor(0xff * alphaBeforeScale * 0.75)), + R: byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.5)), + G: byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.25)), + B: byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.5)), + A: byte(math.Floor(0xff * alphaBeforeScale * 0.75)), } } if !sameColors(got, want, 2) { @@ -291,7 +291,7 @@ func TestColorMCopy(t *testing.T) { for j := 0; j < h; j++ { for i := 0; i < w; i++ { got := dst.At(i, j).(color.RGBA) - want := color.RGBA{byte(k), byte(k), byte(k), byte(k)} + want := color.RGBA{R: byte(k), G: byte(k), B: byte(k), A: byte(k)} if !sameColors(got, want, 1) { t.Fatalf("dst.At(%d, %d), k: %d: got %v, want %v", i, j, k, got, want) } diff --git a/colorscale.go b/colorscale.go index 1bb21bb68..2a67a0071 100644 --- a/colorscale.go +++ b/colorscale.go @@ -29,7 +29,7 @@ type ColorScale struct { r_1, g_1, b_1, a_1 float32 } -// String returns a string represeting the color scale. +// String returns a string representing the color scale. func (c *ColorScale) String() string { return fmt.Sprintf("(%f,%f,%f,%f)", c.r_1+1, c.g_1+1, c.b_1+1, c.a_1+1) } diff --git a/cursor.go b/cursor.go index b5771811d..4781f07a2 100644 --- a/cursor.go +++ b/cursor.go @@ -23,9 +23,9 @@ type CursorModeType = ui.CursorMode // CursorModeTypes const ( - CursorModeVisible CursorModeType = CursorModeType(ui.CursorModeVisible) - CursorModeHidden CursorModeType = CursorModeType(ui.CursorModeHidden) - CursorModeCaptured CursorModeType = CursorModeType(ui.CursorModeCaptured) + CursorModeVisible CursorModeType = ui.CursorModeVisible + CursorModeHidden CursorModeType = ui.CursorModeHidden + CursorModeCaptured CursorModeType = ui.CursorModeCaptured ) // CursorShapeType represents a shape of a mouse cursor. @@ -33,10 +33,10 @@ type CursorShapeType = ui.CursorShape // CursorShapeTypes const ( - CursorShapeDefault CursorShapeType = CursorShapeType(ui.CursorShapeDefault) - CursorShapeText CursorShapeType = CursorShapeType(ui.CursorShapeText) - CursorShapeCrosshair CursorShapeType = CursorShapeType(ui.CursorShapeCrosshair) - CursorShapePointer CursorShapeType = CursorShapeType(ui.CursorShapePointer) - CursorShapeEWResize CursorShapeType = CursorShapeType(ui.CursorShapeEWResize) - CursorShapeNSResize CursorShapeType = CursorShapeType(ui.CursorShapeNSResize) + CursorShapeDefault CursorShapeType = ui.CursorShapeDefault + CursorShapeText CursorShapeType = ui.CursorShapeText + CursorShapeCrosshair CursorShapeType = ui.CursorShapeCrosshair + CursorShapePointer CursorShapeType = ui.CursorShapePointer + CursorShapeEWResize CursorShapeType = ui.CursorShapeEWResize + CursorShapeNSResize CursorShapeType = ui.CursorShapeNSResize ) diff --git a/genevents.go b/genevents.go index 98fcbb507..85b5b6742 100644 --- a/genevents.go +++ b/genevents.go @@ -113,7 +113,7 @@ var ( Type: "float32", }, { - Comment: "Deltay is the change in Y since last touch event. This value is expressed in device independent pixels.", + Comment: "DeltaY is the change in Y since last touch event. This value is expressed in device independent pixels.", Type: "float32", }, { diff --git a/genkeys.go b/genkeys.go index 7781c26d9..ff9dae1ab 100644 --- a/genkeys.go +++ b/genkeys.go @@ -403,7 +403,7 @@ import ( ) // A Key represents a keyboard key. -// These keys represent pysical keys of US keyboard. +// These keys represent physical keys of US keyboard. // For example, KeyQ represents Q key on US keyboards and ' (quote) key on Dvorak keyboards. type Key int diff --git a/graphics.go b/graphics.go index eb7a21b1b..b753217d3 100644 --- a/graphics.go +++ b/graphics.go @@ -21,7 +21,7 @@ import ( "github.com/hajimehoshi/ebiten/v2/internal/ui" ) -// Filter represents the type of texture filter to be used when an image is maginified or minified. +// Filter represents the type of texture filter to be used when an image is magnified or minified. type Filter int const ( @@ -126,7 +126,7 @@ func (c CompositeMode) blend() Blend { } } -// GraphicsLibrary represets graphics libraries supported by the engine. +// GraphicsLibrary represents graphics libraries supported by the engine. type GraphicsLibrary int const ( diff --git a/image.go b/image.go index df5158d1e..f649b1243 100644 --- a/image.go +++ b/image.go @@ -279,7 +279,7 @@ type Vertex struct { // SrcX and SrcY represents a point on a source image. // Be careful that SrcX/SrcY coordinates are on the image's bounds. - // This means that a upper-left point of a sub-image might not be (0, 0). + // This means that an upper-left point of a sub-image might not be (0, 0). SrcX float32 SrcY float32 @@ -292,7 +292,7 @@ type Vertex struct { // Vertex colors are converted to premultiplied-alpha internally and // interpolated linearly respecting alpha. // - DrawTrianglesShader: arbitrary floating point values sent to the shader. - // These are interpolated linearly and independently from each other. + // These are interpolated linearly and independently of each other. ColorR float32 ColorG float32 ColorB float32 @@ -303,7 +303,7 @@ type Vertex struct { type Address int const ( - // AddressUnsafe means there is no guarantee when the texture coodinates are out of range. + // AddressUnsafe means there is no guarantee when the texture coordinates are out of range. AddressUnsafe Address = Address(builtinshader.AddressUnsafe) // AddressClampToZero means that out-of-range texture coordinates return 0 (transparent). @@ -321,7 +321,7 @@ const ( FillAll FillRule = iota // EvenOdd means that triangles are rendered based on the even-odd rule. - // If and only if the number of overlappings is odd, the region is rendered. + // If and only if the number of overlaps is odd, the region is rendered. EvenOdd ) @@ -333,7 +333,7 @@ const ( // straight-alpha encoded color multiplier. ColorScaleModeStraightAlpha ColorScaleMode = iota - // ColorScaleModeStraightAlpha indicates color scales in vertices are + // ColorScaleModePremultipliedAlpha indicates color scales in vertices are // premultiplied-alpha encoded color multiplier. ColorScaleModePremultipliedAlpha ) @@ -872,7 +872,7 @@ func (i *Image) ReadPixels(pixels []byte) { // At can't be called outside the main loop (ebiten.Run's updating function) starts. func (i *Image) At(x, y int) color.Color { r, g, b, a := i.at(x, y) - return color.RGBA{r, g, b, a} + return color.RGBA{R: r, G: g, B: b, A: a} } // RGBA64At implements the standard image.RGBA64Image's RGBA64At. @@ -888,7 +888,7 @@ func (i *Image) At(x, y int) color.Color { // RGBA64At can't be called outside the main loop (ebiten.Run's updating function) starts. func (i *Image) RGBA64At(x, y int) color.RGBA64 { r, g, b, a := i.at(x, y) - return color.RGBA64{uint16(r) * 0x101, uint16(g) * 0x101, uint16(b) * 0x101, uint16(a) * 0x101} + return color.RGBA64{R: uint16(r) * 0x101, G: uint16(g) * 0x101, B: uint16(b) * 0x101, A: uint16(a) * 0x101} } func (i *Image) at(x, y int) (r, g, b, a byte) { @@ -928,14 +928,14 @@ func (i *Image) Set(x, y int, clr color.Color) { } // Dispose disposes the image data. -// After disposing, most of image functions do nothing and returns meaningless values. +// After disposing, most of the image functions do nothing and returns meaningless values. // // Calling Dispose is not mandatory. GC automatically collects internal resources that no objects refer to. // However, calling Dispose explicitly is helpful if memory usage matters. // // If the image is a sub-image, Dispose does nothing. // -// When the image is disposed, Dipose does nothing. +// When the image is disposed, Dispose does nothing. func (i *Image) Dispose() { i.copyCheck() @@ -1011,7 +1011,7 @@ type NewImageOptions struct { // // The rendering origin position is (0, 0) of the given bounds. // If DrawImage is called on a new image created by NewImageOptions, -// for example, the center of scaling and rotating is (0, 0), that might not be a upper-left position. +// for example, the center of scaling and rotating is (0, 0), that might not be an upper-left position. // // If options is nil, the default setting is used. // @@ -1122,7 +1122,7 @@ func NewImageFromImageWithOptions(source image.Image, options *NewImageFromImage return i } -// colorMToScale returns a new color matrix and color sclaes that equal to the given matrix in terms of the effect. +// colorMToScale returns a new color matrix and color scales that equal to the given matrix in terms of the effect. // // If the given matrix is merely a scaling matrix, colorMToScale returns // an identity matrix and its scaling factors in premultiplied-alpha format. diff --git a/image_test.go b/image_test.go index 75eef8294..f73dcc943 100644 --- a/image_test.go +++ b/image_test.go @@ -121,7 +121,7 @@ func TestImagePixels(t *testing.T) { for j := 0; j < h; j++ { for i := 0; i < w; i++ { idx := 4 * (j*w + i) - got := color.RGBA{pix[idx], pix[idx+1], pix[idx+2], pix[idx+3]} + got := color.RGBA{R: pix[idx], G: pix[idx+1], B: pix[idx+2], A: pix[idx+3]} want := color.RGBAModel.Convert(img.At(i, j)) if got != want { t.Errorf("(%d, %d): got %v; want %v", i, j, got, want) @@ -131,8 +131,8 @@ func TestImagePixels(t *testing.T) { } func TestImageComposition(t *testing.T) { - img2Color := color.NRGBA{0x24, 0x3f, 0x6a, 0x88} - img3Color := color.NRGBA{0x85, 0xa3, 0x08, 0xd3} + img2Color := color.NRGBA{R: 0x24, G: 0x3f, B: 0x6a, A: 0x88} + img3Color := color.NRGBA{R: 0x85, G: 0xa3, B: 0x08, A: 0xd3} // TODO: Rename this to img0 img1, _, err := openEbitenImage() @@ -178,7 +178,7 @@ func TestImageComposition(t *testing.T) { } func TestImageSelf(t *testing.T) { - // Note that mutex usages: without defer, unlocking is not called when panicing. + // Note that mutex usages: without defer, unlocking is not called when panicking. defer func() { if r := recover(); r == nil { t.Errorf("DrawImage must panic but not") @@ -267,7 +267,7 @@ func TestImageDotByDotInversion(t *testing.T) { } func TestImageWritePixels(t *testing.T) { - // Create a dummy image so that the shared texture is used and origImg's position is shfited. + // Create a dummy image so that the shared texture is used and origImg's position is shifted. dummyImg := ebiten.NewImageFromImage(image.NewRGBA(image.Rect(0, 0, 16, 16))) defer dummyImg.Dispose() @@ -306,7 +306,7 @@ func TestImageWritePixels(t *testing.T) { for j := 0; j < img0.Bounds().Dy(); j++ { for i := 0; i < img0.Bounds().Dx(); i++ { got := img0.At(i, j) - want := color.RGBA{0x80, 0x80, 0x80, 0x80} + want := color.RGBA{R: 0x80, G: 0x80, B: 0x80, A: 0x80} if got != want { t.Errorf("img0 At(%d, %d): got %v; want %v", i, j, got, want) } @@ -356,7 +356,7 @@ func TestImageBlendLighter(t *testing.T) { w, h := img0.Bounds().Dx(), img0.Bounds().Dy() img1 := ebiten.NewImage(w, h) - img1.Fill(color.RGBA{0x01, 0x02, 0x03, 0x04}) + img1.Fill(color.RGBA{R: 0x01, G: 0x02, B: 0x03, A: 0x04}) op := &ebiten.DrawImageOptions{} op.Blend = ebiten.BlendLighter img1.DrawImage(img0, op) @@ -429,7 +429,7 @@ func TestImageFill(t *testing.T) { for j := 0; j < h; j++ { for i := 0; i < w; i++ { got := img.At(i, j) - want := color.RGBA{0x80, 0x80, 0x80, 0x80} + want := color.RGBA{R: 0x80, G: 0x80, B: 0x80, A: 0x80} if got != want { t.Errorf("img At(%d, %d): got %v; want %v", i, j, got, want) } @@ -445,7 +445,7 @@ func TestImageClear(t *testing.T) { for j := 0; j < h; j++ { for i := 0; i < w; i++ { got := img.At(i, j) - want := color.RGBA{0xff, 0xff, 0xff, 0xff} + want := color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff} if got != want { t.Errorf("img At(%d, %d): got %v; want %v", i, j, got, want) } @@ -493,8 +493,8 @@ func TestImageEdge(t *testing.T) { } img0.WritePixels(pixels) img1 := ebiten.NewImage(img1Width, img1Height) - red := color.RGBA{0xff, 0, 0, 0xff} - transparent := color.RGBA{0, 0, 0, 0} + red := color.RGBA{R: 0xff, A: 0xff} + transparent := color.RGBA{} angles := []float64{} for a := 0; a < 1440; a++ { @@ -616,7 +616,7 @@ func TestImageTooManyFill(t *testing.T) { dst := ebiten.NewImage(width, 1) for i := 0; i < width; i++ { c := indexToColor(i) - src.Fill(color.RGBA{c, c, c, 0xff}) + src.Fill(color.RGBA{R: c, G: c, B: c, A: 0xff}) op := &ebiten.DrawImageOptions{} op.GeoM.Translate(float64(i), 0) dst.DrawImage(src, op) @@ -625,7 +625,7 @@ func TestImageTooManyFill(t *testing.T) { for i := 0; i < width; i++ { c := indexToColor(i) got := dst.At(i, 0).(color.RGBA) - want := color.RGBA{c, c, c, 0xff} + want := color.RGBA{R: c, G: c, B: c, A: 0xff} if !sameColors(got, want, 1) { t.Errorf("dst.At(%d, %d): got %v, want: %v", i, 0, got, want) } @@ -671,7 +671,7 @@ func TestImageLinearGraduation(t *testing.T) { func TestImageOutside(t *testing.T) { src := ebiten.NewImage(5, 10) // internal texture size is 8x16. dst := ebiten.NewImage(4, 4) - src.Fill(color.RGBA{0xff, 0, 0, 0xff}) + src.Fill(color.RGBA{R: 0xff, A: 0xff}) cases := []struct { X, Y, Width, Height int @@ -701,7 +701,7 @@ func TestImageOutside(t *testing.T) { for j := 0; j < 4; j++ { for i := 0; i < 4; i++ { got := dst.At(i, j).(color.RGBA) - want := color.RGBA{0, 0, 0, 0} + want := color.RGBA{} if got != want { t.Errorf("src(x: %d, y: %d, w: %d, h: %d), dst At(%d, %d): got %v, want: %v", c.X, c.Y, c.Width, c.Height, i, j, got, want) } @@ -714,7 +714,7 @@ func TestImageOutsideUpperLeft(t *testing.T) { src := ebiten.NewImage(4, 4) dst1 := ebiten.NewImage(16, 16) dst2 := ebiten.NewImage(16, 16) - src.Fill(color.RGBA{0xff, 0, 0, 0xff}) + src.Fill(color.RGBA{R: 0xff, A: 0xff}) op := &ebiten.DrawImageOptions{} op.GeoM.Rotate(math.Pi / 4) @@ -756,7 +756,7 @@ func TestImageSize1(t *testing.T) { src.Fill(color.White) dst.DrawImage(src, nil) got := src.At(0, 0).(color.RGBA) - want := color.RGBA{0xff, 0xff, 0xff, 0xff} + want := color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff} if !sameColors(got, want, 1) { t.Errorf("got: %v, want: %v", got, want) } @@ -788,7 +788,7 @@ func Skip_TestImageSize4096(t *testing.T) { for i := 4095; i < 4096; i++ { j := 4095 got := dst.At(i, j).(color.RGBA) - want := color.RGBA{uint8(i + j), uint8((i + j) >> 8), uint8((i + j) >> 16), 0xff} + want := color.RGBA{R: uint8(i + j), G: uint8((i + j) >> 8), B: uint8((i + j) >> 16), A: 0xff} if got != want { t.Errorf("At(%d, %d): got: %v, want: %v", i, j, got, want) } @@ -796,7 +796,7 @@ func Skip_TestImageSize4096(t *testing.T) { for j := 4095; j < 4096; j++ { i := 4095 got := dst.At(i, j).(color.RGBA) - want := color.RGBA{uint8(i + j), uint8((i + j) >> 8), uint8((i + j) >> 16), 0xff} + want := color.RGBA{R: uint8(i + j), G: uint8((i + j) >> 8), B: uint8((i + j) >> 16), A: 0xff} if got != want { t.Errorf("At(%d, %d): got: %v, want: %v", i, j, got, want) } @@ -848,7 +848,7 @@ loop: got := dst.At(0, i+j).(color.RGBA) want := color.RGBA{} if j < 0 { - want = color.RGBA{0xff, 0, 0, 0xff} + want = color.RGBA{R: 0xff, A: 0xff} } if got != want { t.Errorf("At(%d, %d) (height=%d, scale=%d/%d): got: %v, want: %v", 0, i+j, h, i, h, got, want) @@ -874,7 +874,7 @@ func TestImageSprites(t *testing.T) { ) src := ebiten.NewImage(4, 4) - src.Fill(color.RGBA{0xff, 0xff, 0xff, 0xff}) + src.Fill(color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}) dst := ebiten.NewImage(width, height) for j := 0; j < height/4; j++ { for i := 0; i < width/4; i++ { @@ -887,7 +887,7 @@ func TestImageSprites(t *testing.T) { for j := 0; j < height/4; j++ { for i := 0; i < width/4; i++ { got := dst.At(i*4, j*4).(color.RGBA) - want := color.RGBA{0xff, 0xff, 0xff, 0xff} + want := color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff} if !sameColors(got, want, 1) { t.Errorf("dst.At(%d, %d): got %v, want: %v", i*4, j*4, got, want) } @@ -1017,7 +1017,7 @@ func TestImageMipmapColor(t *testing.T) { op.ColorScale.Scale(0, 1, 1, 1) img0.DrawImage(img1, op) - want := color.RGBA{0, 0xff, 0xff, 0xff} + want := color.RGBA{G: 0xff, B: 0xff, A: 0xff} got := img0.At(128, 0) if got != want { t.Errorf("want: %v, got: %v", want, got) @@ -1032,14 +1032,14 @@ func TestImageMiamapAndDrawTriangle(t *testing.T) { img2 := ebiten.NewImage(128, 128) // Fill img1 red and create img1's mipmap - img1.Fill(color.RGBA{0xff, 0, 0, 0xff}) + img1.Fill(color.RGBA{R: 0xff, A: 0xff}) op := &ebiten.DrawImageOptions{} op.GeoM.Scale(0.25, 0.25) op.Filter = ebiten.FilterLinear img0.DrawImage(img1, op) // Call DrawTriangle on img1 and fill it with green - img2.Fill(color.RGBA{0, 0xff, 0, 0xff}) + img2.Fill(color.RGBA{G: 0xff, A: 0xff}) vs := []ebiten.Vertex{ { DstX: 0, @@ -1104,7 +1104,7 @@ func TestImageMiamapAndDrawTriangle(t *testing.T) { func TestImageSubImageAt(t *testing.T) { img := ebiten.NewImage(16, 16) - img.Fill(color.RGBA{0xff, 0, 0, 0xff}) + img.Fill(color.RGBA{R: 0xff, A: 0xff}) got := img.SubImage(image.Rect(1, 1, 16, 16)).At(0, 0).(color.RGBA) want := color.RGBA{} @@ -1113,7 +1113,7 @@ func TestImageSubImageAt(t *testing.T) { } got = img.SubImage(image.Rect(1, 1, 16, 16)).At(1, 1).(color.RGBA) - want = color.RGBA{0xff, 0, 0, 0xff} + want = color.RGBA{R: 0xff, A: 0xff} if got != want { t.Errorf("got: %v, want: %v", got, want) } @@ -1121,7 +1121,7 @@ func TestImageSubImageAt(t *testing.T) { func TestImageSubImageSize(t *testing.T) { img := ebiten.NewImage(16, 16) - img.Fill(color.RGBA{0xff, 0, 0, 0xff}) + img.Fill(color.RGBA{R: 0xff, A: 0xff}) got := img.SubImage(image.Rect(1, 1, 16, 16)).Bounds().Dx() want := 15 @@ -1136,11 +1136,11 @@ func TestImageDrawImmediately(t *testing.T) { img1 := ebiten.NewImage(w, h) // Do not manipulate img0 here. - img0.Fill(color.RGBA{0xff, 0, 0, 0xff}) + img0.Fill(color.RGBA{R: 0xff, A: 0xff}) for j := 0; j < h; j++ { for i := 0; i < w; i++ { got := img0.At(i, j).(color.RGBA) - want := color.RGBA{0xff, 0, 0, 0xff} + want := color.RGBA{R: 0xff, A: 0xff} if got != want { t.Errorf("img0.At(%d, %d): got %v, want: %v", i, j, got, want) } @@ -1152,7 +1152,7 @@ func TestImageDrawImmediately(t *testing.T) { for j := 0; j < h; j++ { for i := 0; i < w; i++ { got := img0.At(i, j).(color.RGBA) - want := color.RGBA{0xff, 0, 0, 0xff} + want := color.RGBA{R: 0xff, A: 0xff} if got != want { t.Errorf("img0.At(%d, %d): got %v, want: %v", i, j, got, want) } @@ -1198,9 +1198,9 @@ func TestImageLinearFilterGlitch(t *testing.T) { got := dst.At(i, j).(color.RGBA) var want color.RGBA if j < 3 { - want = color.RGBA{0xff, 0xff, 0xff, 0xff} + want = color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff} } else { - want = color.RGBA{0, 0, 0, 0xff} + want = color.RGBA{A: 0xff} } if got != want { t.Errorf("dst.At(%d, %d): filter: %d, got: %v, want: %v", i, j, f, got, want) @@ -1245,9 +1245,9 @@ func TestImageLinearFilterGlitch2(t *testing.T) { got := dst.At(i, j).(color.RGBA) var want color.RGBA if i+j < 100 { - want = color.RGBA{0, 0, 0, 0xff} + want = color.RGBA{A: 0xff} } else { - want = color.RGBA{0xff, 0xff, 0xff, 0xff} + want = color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff} } if !sameColors(got, want, 1) { t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want) @@ -1329,7 +1329,7 @@ func TestImageAddressRepeat(t *testing.T) { for j := 0; j < h; j++ { for i := 0; i < w; i++ { got := dst.At(i, j).(color.RGBA) - want := color.RGBA{byte(i%4) * 0x10, byte(j%4) * 0x10, 0, 0xff} + want := color.RGBA{R: byte(i%4) * 0x10, G: byte(j%4) * 0x10, A: 0xff} if !sameColors(got, want, 1) { t.Errorf("dst.At(%d, %d): got %v, want: %v", i, j, got, want) } @@ -1410,7 +1410,7 @@ func TestImageAddressRepeatNegativePosition(t *testing.T) { for j := 0; j < h; j++ { for i := 0; i < w; i++ { got := dst.At(i, j).(color.RGBA) - want := color.RGBA{byte(i%4) * 0x10, byte(j%4) * 0x10, 0, 0xff} + want := color.RGBA{R: byte(i%4) * 0x10, G: byte(j%4) * 0x10, A: 0xff} if !sameColors(got, want, 1) { t.Errorf("dst.At(%d, %d): got %v, want: %v", i, j, got, want) } @@ -1683,8 +1683,8 @@ func TestImageAtAfterDisposingSubImage(t *testing.T) { img.SubImage(image.Rect(0, 0, 16, 16)) runtime.GC() - want := color.RGBA{0xff, 0xff, 0xff, 0xff} - want64 := color.RGBA64{0xffff, 0xffff, 0xffff, 0xffff} + want := color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff} + want64 := color.RGBA64{R: 0xffff, G: 0xffff, B: 0xffff, A: 0xffff} got := img.At(0, 0) if got != want { t.Errorf("At(0,0) got: %v, want: %v", got, want) @@ -1726,7 +1726,7 @@ func TestImageSubImageSubImage(t *testing.T) { { X: 4, Y: 4, - Color: color.RGBA{0xff, 0xff, 0xff, 0xff}, + Color: color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}, }, { X: 15, @@ -1755,7 +1755,7 @@ func TestImageTooSmallMipmap(t *testing.T) { op.Filter = ebiten.FilterLinear dst.DrawImage(src.SubImage(image.Rect(5, 0, 6, 16)).(*ebiten.Image), op) got := dst.At(0, 0).(color.RGBA) - want := color.RGBA{0xff, 0xff, 0xff, 0xff} + want := color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff} if got != want { t.Errorf("got: %v, want: %v", got, want) } @@ -1792,9 +1792,9 @@ func TestImageFillingAndEdges(t *testing.T) { for j := 0; j < dsth; j++ { for i := 0; i < dstw; i++ { got := dst.At(i, j).(color.RGBA) - want := color.RGBA{0xff, 0xff, 0xff, 0xff} + want := color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff} if i == 0 || i == dstw-1 || j == 0 || j == dsth-1 { - want = color.RGBA{0, 0, 0, 0xff} + want = color.RGBA{A: 0xff} } if got != want { t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want) @@ -1807,7 +1807,7 @@ func TestImageDrawTrianglesAndMutateArgs(t *testing.T) { const w, h = 16, 16 dst := ebiten.NewImage(w, h) src := ebiten.NewImage(w, h) - clr := color.RGBA{0xff, 0, 0, 0xff} + clr := color.RGBA{R: 0xff, A: 0xff} src.Fill(clr) vs := []ebiten.Vertex{ @@ -1871,7 +1871,7 @@ func TestImageDrawTrianglesAndMutateArgs(t *testing.T) { func TestImageWritePixelsOnSubImage(t *testing.T) { dst := ebiten.NewImage(17, 31) - dst.Fill(color.RGBA{0xff, 0, 0, 0xff}) + dst.Fill(color.RGBA{R: 0xff, A: 0xff}) pix0 := make([]byte, 4*5*3) idx := 0 @@ -1916,13 +1916,13 @@ func TestImageWritePixelsOnSubImage(t *testing.T) { for j := 0; j < 31; j++ { for i := 0; i < 17; i++ { got := dst.At(i, j).(color.RGBA) - want := color.RGBA{0xff, 0, 0, 0xff} + want := color.RGBA{R: 0xff, A: 0xff} p := image.Pt(i, j) switch { case p.In(r0): - want = color.RGBA{0, 0xff, 0, 0xff} + want = color.RGBA{G: 0xff, A: 0xff} case p.In(r1): - want = color.RGBA{0, 0, 0xff, 0xff} + want = color.RGBA{B: 0xff, A: 0xff} } if got != want { t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want) @@ -2120,7 +2120,7 @@ func TestImageDrawTrianglesInterpolatesColors(t *testing.T) { format := format t.Run(fmt.Sprintf("format%d", format), func(t *testing.T) { dst := ebiten.NewImage(w, h) - dst.Fill(color.RGBA{0x00, 0x00, 0xff, 0xff}) + dst.Fill(color.RGBA{B: 0xff, A: 0xff}) op := &ebiten.DrawTrianglesOptions{} op.ColorScaleMode = format @@ -2135,9 +2135,9 @@ func TestImageDrawTrianglesInterpolatesColors(t *testing.T) { var want color.RGBA switch format { case ebiten.ColorScaleModeStraightAlpha: - want = color.RGBA{0x00, 0x80, 0x80, 0xff} + want = color.RGBA{G: 0x80, B: 0x80, A: 0xff} case ebiten.ColorScaleModePremultipliedAlpha: - want = color.RGBA{0x80, 0x80, 0x80, 0xff} + want = color.RGBA{R: 0x80, G: 0x80, B: 0x80, A: 0xff} } if !sameColors(got, want, 2) { @@ -2195,7 +2195,7 @@ func TestImageDrawTrianglesShaderInterpolatesValues(t *testing.T) { ColorA: 1, }, } - dst.Fill(color.RGBA{0x00, 0x00, 0xff, 0xff}) + dst.Fill(color.RGBA{B: 0xff, A: 0xff}) op := &ebiten.DrawTrianglesShaderOptions{ Images: [4]*ebiten.Image{src, nil, nil, nil}, } @@ -2214,7 +2214,7 @@ func TestImageDrawTrianglesShaderInterpolatesValues(t *testing.T) { got := dst.At(1, 0).(color.RGBA) // Shaders get each color value interpolated independently. - want := color.RGBA{0x80, 0x80, 0x80, 0xff} + want := color.RGBA{R: 0x80, G: 0x80, B: 0x80, A: 0xff} if !sameColors(got, want, 2) { t.Errorf("At(1, 0): got: %v, want: %v", got, want) @@ -2228,13 +2228,13 @@ func TestImageDrawOver(t *testing.T) { h = 240 ) dst := ebiten.NewImage(w, h) - src := image.NewUniform(color.RGBA{0xff, 0, 0, 0xff}) + src := image.NewUniform(color.RGBA{R: 0xff, A: 0xff}) // This must not cause infinite-loop. draw.Draw(dst, dst.Bounds(), src, image.ZP, draw.Over) for j := 0; j < h; j++ { for i := 0; i < w; i++ { got := dst.At(i, j) - want := color.RGBA{0xff, 0, 0, 0xff} + want := color.RGBA{R: 0xff, A: 0xff} if got != want { t.Errorf("At(%d, %d): got: %v, want: %v", i, j, got, want) } @@ -2288,7 +2288,7 @@ func TestImageFloatTranslate(t *testing.T) { t.Run(fmt.Sprintf("scale%d", s), func(t *testing.T) { check := func(src *ebiten.Image) { dst := ebiten.NewImage(w*(s+1), h*(s+1)) - dst.Fill(color.RGBA{0xff, 0, 0, 0xff}) + dst.Fill(color.RGBA{R: 0xff, A: 0xff}) op := &ebiten.DrawImageOptions{} op.GeoM.Scale(float64(s), float64(s)) @@ -2302,7 +2302,7 @@ func TestImageFloatTranslate(t *testing.T) { if j > 0 { x = (byte(j) - 1) / byte(s) } - want := color.RGBA{x, 0, 0, 0xff} + want := color.RGBA{R: x, A: 0xff} if got != want { t.Errorf("At(%d, %d): got: %v, want: %v", i, j, got, want) } @@ -2354,7 +2354,7 @@ func TestImageColorMCopy(t *testing.T) { for j := 0; j < h; j++ { for i := 0; i < w; i++ { got := dst.At(i, j).(color.RGBA) - want := color.RGBA{byte(k), byte(k), byte(k), byte(k)} + want := color.RGBA{R: byte(k), G: byte(k), B: byte(k), A: byte(k)} if !sameColors(got, want, 1) { t.Fatalf("dst.At(%d, %d), k: %d: got %v, want %v", i, j, k, got, want) } @@ -2399,7 +2399,7 @@ func TestImageWritePixelsAndModifyPixels(t *testing.T) { for j := 0; j < h; j++ { for i := 0; i < w; i++ { got := src.At(i, j).(color.RGBA) - want := color.RGBA{0xff, 0, 0, 0xff} + want := color.RGBA{R: 0xff, A: 0xff} if got != want { t.Errorf("src.At(%d, %d): got: %v, want: %v", i, j, got, want) } @@ -2412,8 +2412,8 @@ func TestImageCompositeModeMultiply(t *testing.T) { dst := ebiten.NewImage(w, h) src := ebiten.NewImage(w, h) - dst.Fill(color.RGBA{0x10, 0x20, 0x30, 0x40}) - src.Fill(color.RGBA{0x50, 0x60, 0x70, 0x80}) + dst.Fill(color.RGBA{R: 0x10, G: 0x20, B: 0x30, A: 0x40}) + src.Fill(color.RGBA{R: 0x50, G: 0x60, B: 0x70, A: 0x80}) op := &ebiten.DrawImageOptions{} op.CompositeMode = ebiten.CompositeModeMultiply @@ -2507,16 +2507,16 @@ func TestImageClip(t *testing.T) { dst := ebiten.NewImage(w, h) src := ebiten.NewImage(w, h) - dst.Fill(color.RGBA{0xff, 0, 0, 0xff}) - src.Fill(color.RGBA{0, 0xff, 0, 0xff}) + dst.Fill(color.RGBA{R: 0xff, A: 0xff}) + src.Fill(color.RGBA{G: 0xff, A: 0xff}) dst.SubImage(image.Rect(4, 5, 12, 14)).(*ebiten.Image).DrawImage(src, nil) for j := 0; j < h; j++ { for i := 0; i < w; i++ { got := dst.At(i, j).(color.RGBA) - want := color.RGBA{0xff, 0, 0, 0xff} + want := color.RGBA{R: 0xff, A: 0xff} if 4 <= i && i < 12 && 5 <= j && j < 14 { - want = color.RGBA{0, 0xff, 0, 0xff} + want = color.RGBA{G: 0xff, A: 0xff} } if got != want { t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want) @@ -2534,7 +2534,7 @@ func TestImageSubImageFill(t *testing.T) { got := dst.At(i, j) var want color.RGBA if i == 1 && j == 1 { - want = color.RGBA{0xff, 0xff, 0xff, 0xff} + want = color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff} } if got != want { t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want) @@ -2549,7 +2549,7 @@ func TestImageSubImageFill(t *testing.T) { got := dst.At(i, j) var want color.RGBA if 3 <= i && i < 8 && 4 <= j && j < 10 { - want = color.RGBA{0xff, 0xff, 0xff, 0xff} + want = color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff} } if got != want { t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want) @@ -2635,13 +2635,13 @@ func TestImageEvenOdd(t *testing.T) { var want color.RGBA switch { case 3 <= i && i < 13 && 3 <= j && j < 13: - want = color.RGBA{0, 0, 0xff, 0xff} + want = color.RGBA{B: 0xff, A: 0xff} case 2 <= i && i < 14 && 2 <= j && j < 14: - want = color.RGBA{0, 0, 0, 0} + want = color.RGBA{} case 1 <= i && i < 15 && 1 <= j && j < 15: - want = color.RGBA{0xff, 0, 0, 0xff} + want = color.RGBA{R: 0xff, A: 0xff} default: - want = color.RGBA{0, 0, 0, 0} + want = color.RGBA{} } if got != want { t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want) @@ -2670,13 +2670,13 @@ func TestImageEvenOdd(t *testing.T) { var want color.RGBA switch { case 4 <= i && i < 14 && 4 <= j && j < 14: - want = color.RGBA{0, 0, 0xff, 0xff} + want = color.RGBA{B: 0xff, A: 0xff} case 3 <= i && i < 15 && 3 <= j && j < 15: - want = color.RGBA{0, 0, 0, 0} + want = color.RGBA{} case 2 <= i && i < 16 && 2 <= j && j < 16: - want = color.RGBA{0xff, 0, 0, 0xff} + want = color.RGBA{R: 0xff, A: 0xff} default: - want = color.RGBA{0, 0, 0, 0} + want = color.RGBA{} } if got != want { t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want) @@ -2708,13 +2708,13 @@ func TestImageEvenOdd(t *testing.T) { var want color.RGBA switch { case 3 <= i && i < 13 && 3 <= j && j < 13: - want = color.RGBA{0, 0, 0xff, 0xff} + want = color.RGBA{B: 0xff, A: 0xff} case 2 <= i && i < 14 && 2 <= j && j < 14: - want = color.RGBA{0, 0xff, 0, 0xff} + want = color.RGBA{G: 0xff, A: 0xff} case 1 <= i && i < 15 && 1 <= j && j < 15: - want = color.RGBA{0xff, 0, 0, 0xff} + want = color.RGBA{R: 0xff, A: 0xff} default: - want = color.RGBA{0, 0, 0, 0} + want = color.RGBA{} } if got != want { t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want) @@ -2799,7 +2799,7 @@ func TestIndicesOverflow(t *testing.T) { for j := 0; j < h; j++ { for i := 0; i < w; i++ { got := dst.At(i, j) - want := color.RGBA{0xff, 0xff, 0xff, 0xff} + want := color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff} if got != want { t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want) } @@ -2871,7 +2871,7 @@ func TestVerticesOverflow(t *testing.T) { for j := 0; j < h; j++ { for i := 0; i < w; i++ { got := dst.At(i, j) - want := color.RGBA{0xff, 0xff, 0xff, 0xff} + want := color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff} if got != want { t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want) } @@ -2923,7 +2923,7 @@ func TestImageNewImageFromEbitenImage(t *testing.T) { for j := 0; j < h; j++ { for i := 0; i < w; i++ { got := img1.At(i, j) - want := color.RGBA{byte(i), byte(j), 0, 0xff} + want := color.RGBA{R: byte(i), G: byte(j), A: 0xff} if got != want { t.Errorf("img1.At(%d, %d): got: %v, want: %v", i, j, got, want) } @@ -2934,7 +2934,7 @@ func TestImageNewImageFromEbitenImage(t *testing.T) { for j := 0; j < h/2; j++ { for i := 0; i < w/2; i++ { got := img2.At(i, j) - want := color.RGBA{byte(i + 4), byte(j + 4), 0, 0xff} + want := color.RGBA{R: byte(i + 4), G: byte(j + 4), A: 0xff} if got != want { t.Errorf("img1.At(%d, %d): got: %v, want: %v", i, j, got, want) } @@ -2968,7 +2968,7 @@ func TestImageOptionsUnmanaged(t *testing.T) { for j := 0; j < h; j++ { for i := 0; i < w; i++ { got := img.At(i, j) - want := color.RGBA{byte(i), byte(j), 0, 0xff} + want := color.RGBA{R: byte(i), G: byte(j), A: 0xff} if got != want { t.Errorf("img.At(%d, %d): got: %v, want: %v", i, j, got, want) } @@ -3000,7 +3000,7 @@ func TestImageOptionsNegativeBoundsWritePixels(t *testing.T) { for j := offset; j < h+offset; j++ { for i := offset; i < w+offset; i++ { got := img.At(i, j) - want := color.RGBA{byte(i - offset), byte(j - offset), 0, 0xff} + want := color.RGBA{R: byte(i - offset), G: byte(j - offset), A: 0xff} if got != want { t.Errorf("img.At(%d, %d): got: %v, want: %v", i, j, got, want) } @@ -3024,9 +3024,9 @@ func TestImageOptionsNegativeBoundsWritePixels(t *testing.T) { for j := offset; j < h+offset; j++ { for i := offset; i < w+offset; i++ { got := img.At(i, j) - want := color.RGBA{byte(i - offset), byte(j - offset), 0, 0xff} + want := color.RGBA{R: byte(i - offset), G: byte(j - offset), A: 0xff} if image.Pt(i, j).In(sub) { - want = color.RGBA{0, 0, 0xff, 0xff} + want = color.RGBA{B: 0xff, A: 0xff} } if got != want { t.Errorf("img.At(%d, %d): got: %v, want: %v", i, j, got, want) @@ -3055,14 +3055,14 @@ func TestImageOptionsNegativeBoundsSet(t *testing.T) { const offset = -8 img := ebiten.NewImageWithOptions(image.Rect(offset, offset, w+offset, h+offset), nil) img.WritePixels(pix0) - img.Set(-1, -2, color.RGBA{0, 0, 0, 0}) + img.Set(-1, -2, color.RGBA{}) for j := offset; j < h+offset; j++ { for i := offset; i < w+offset; i++ { got := img.At(i, j) - want := color.RGBA{byte(i - offset), byte(j - offset), 0, 0xff} + want := color.RGBA{R: byte(i - offset), G: byte(j - offset), A: 0xff} if i == -1 && j == -2 { - want = color.RGBA{0, 0, 0, 0} + want = color.RGBA{} } if got != want { t.Errorf("img.At(%d, %d): got: %v, want: %v", i, j, got, want) @@ -3094,7 +3094,7 @@ func TestImageOptionsNegativeBoundsDrawImage(t *testing.T) { got := dst.At(i, j) var want color.RGBA if -2 <= i && i < 2 && -3 <= j && j < 3 { - want = color.RGBA{0xff, 0xff, 0xff, 0xff} + want = color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff} } if got != want { t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want) @@ -3165,7 +3165,7 @@ func TestImageOptionsNegativeBoundsDrawTriangles(t *testing.T) { got := dst.At(i, j) var want color.RGBA if -2 <= i && i < 2 && -3 <= j && j < 3 { - want = color.RGBA{0xff, 0xff, 0xff, 0xff} + want = color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff} } if got != want { t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want) @@ -3197,7 +3197,7 @@ func TestImageFromImageOptions(t *testing.T) { for j := r.Min.Y; j < r.Max.Y; j++ { for i := r.Min.X; i < r.Max.X; i++ { got := img.At(i, j) - want := color.RGBA{0xff, 0xff, 0xff, 0xff} + want := color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff} if got != want { t.Errorf("img.At(%d, %d): got: %v, want: %v", i, j, got, want) } @@ -3225,7 +3225,7 @@ func TestImageFromEbitenImageOptions(t *testing.T) { for j := r.Min.Y; j < r.Max.Y; j++ { for i := r.Min.X; i < r.Max.X; i++ { got := img.At(i, j) - want := color.RGBA{0xff, 0xff, 0xff, 0xff} + want := color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff} if got != want { t.Errorf("img.At(%d, %d): got: %v, want: %v", i, j, got, want) } @@ -3237,11 +3237,11 @@ func TestImageFromEbitenImageOptions(t *testing.T) { func TestImageOptionsFill(t *testing.T) { r0 := image.Rect(-2, -3, 4, 5) img := ebiten.NewImageWithOptions(r0, nil) - img.Fill(color.RGBA{0xff, 0, 0, 0xff}) + img.Fill(color.RGBA{R: 0xff, A: 0xff}) for j := r0.Min.Y; j < r0.Max.Y; j++ { for i := r0.Min.X; i < r0.Max.X; i++ { got := img.At(i, j) - want := color.RGBA{0xff, 0, 0, 0xff} + want := color.RGBA{R: 0xff, A: 0xff} if got != want { t.Errorf("img.At(%d, %d): got: %v, want: %v", i, j, got, want) } @@ -3249,13 +3249,13 @@ func TestImageOptionsFill(t *testing.T) { } r1 := image.Rect(-1, -2, 3, 4) - img.SubImage(r1).(*ebiten.Image).Fill(color.RGBA{0, 0xff, 0, 0xff}) + img.SubImage(r1).(*ebiten.Image).Fill(color.RGBA{G: 0xff, A: 0xff}) for j := r0.Min.Y; j < r0.Max.Y; j++ { for i := r0.Min.X; i < r0.Max.X; i++ { got := img.At(i, j) - want := color.RGBA{0xff, 0, 0, 0xff} + want := color.RGBA{R: 0xff, A: 0xff} if image.Pt(i, j).In(r1) { - want = color.RGBA{0, 0xff, 0, 0xff} + want = color.RGBA{G: 0xff, A: 0xff} } if got != want { t.Errorf("img.At(%d, %d): got: %v, want: %v", i, j, got, want) @@ -3268,27 +3268,27 @@ func TestImageOptionsFill(t *testing.T) { func TestImageOptionsClear(t *testing.T) { r0 := image.Rect(-2, -3, 4, 5) img := ebiten.NewImageWithOptions(r0, nil) - img.Fill(color.RGBA{0xff, 0, 0, 0xff}) + img.Fill(color.RGBA{R: 0xff, A: 0xff}) img.Clear() for j := r0.Min.Y; j < r0.Max.Y; j++ { for i := r0.Min.X; i < r0.Max.X; i++ { got := img.At(i, j) - want := color.RGBA{0, 0, 0, 0} + want := color.RGBA{} if got != want { t.Errorf("img.At(%d, %d): got: %v, want: %v", i, j, got, want) } } } - img.Fill(color.RGBA{0xff, 0, 0, 0xff}) + img.Fill(color.RGBA{R: 0xff, A: 0xff}) r1 := image.Rect(-1, -2, 3, 4) img.SubImage(r1).(*ebiten.Image).Clear() for j := r0.Min.Y; j < r0.Max.Y; j++ { for i := r0.Min.X; i < r0.Max.X; i++ { got := img.At(i, j) - want := color.RGBA{0xff, 0, 0, 0xff} + want := color.RGBA{R: 0xff, A: 0xff} if image.Pt(i, j).In(r1) { - want = color.RGBA{0, 0, 0, 0} + want = color.RGBA{} } if got != want { t.Errorf("img.At(%d, %d): got: %v, want: %v", i, j, got, want) @@ -3300,7 +3300,7 @@ func TestImageOptionsClear(t *testing.T) { // Issue #2178 func TestImageTooManyDrawImage(t *testing.T) { src := ebiten.NewImage(1, 1) - src.Fill(color.RGBA{0xff, 0xff, 0xff, 0xff}) + src.Fill(color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}) const ( w = 256 @@ -3319,7 +3319,7 @@ func TestImageTooManyDrawImage(t *testing.T) { for j := 0; j < h; j++ { for i := 0; i < w; i++ { - if got, want := dst.At(i, j), (color.RGBA{0xff, 0xff, 0xff, 0xff}); got != want { + if got, want := dst.At(i, j), (color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}); got != want { t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want) } } @@ -3329,7 +3329,7 @@ func TestImageTooManyDrawImage(t *testing.T) { // Issue #2178 func TestImageTooManyDrawTriangles(t *testing.T) { img := ebiten.NewImage(3, 3) - img.Fill(color.RGBA{0xff, 0xff, 0xff, 0xff}) + img.Fill(color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}) src := img.SubImage(image.Rect(1, 1, 2, 2)).(*ebiten.Image) const ( @@ -3392,7 +3392,7 @@ func TestImageTooManyDrawTriangles(t *testing.T) { for j := 0; j < h; j++ { for i := 0; i < w; i++ { - if got, want := dst.At(i, j), (color.RGBA{0xff, 0xff, 0xff, 0xff}); got != want { + if got, want := dst.At(i, j), (color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}); got != want { t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want) } } @@ -3401,26 +3401,26 @@ func TestImageTooManyDrawTriangles(t *testing.T) { func TestImageSetOverSet(t *testing.T) { img := ebiten.NewImage(1, 1) - img.Set(0, 0, color.RGBA{0xff, 0xff, 0xff, 0xff}) - if got, want := img.At(0, 0), (color.RGBA{0xff, 0xff, 0xff, 0xff}); got != want { + img.Set(0, 0, color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}) + if got, want := img.At(0, 0), (color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}); got != want { t.Errorf("got: %v, want: %v", got, want) } // Apply the change by 'Set' by calling DrawImage. dummy := ebiten.NewImage(1, 1) img.DrawImage(dummy, nil) - if got, want := img.At(0, 0), (color.RGBA{0xff, 0xff, 0xff, 0xff}); got != want { + if got, want := img.At(0, 0), (color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}); got != want { t.Errorf("got: %v, want: %v", got, want) } - img.Set(0, 0, color.RGBA{0x80, 0x80, 0x80, 0x80}) - if got, want := img.At(0, 0), (color.RGBA{0x80, 0x80, 0x80, 0x80}); got != want { + img.Set(0, 0, color.RGBA{R: 0x80, G: 0x80, B: 0x80, A: 0x80}) + if got, want := img.At(0, 0), (color.RGBA{R: 0x80, G: 0x80, B: 0x80, A: 0x80}); got != want { t.Errorf("got: %v, want: %v", got, want) } // Apply the change by 'Set' again. img.DrawImage(dummy, nil) - if got, want := img.At(0, 0), (color.RGBA{0x80, 0x80, 0x80, 0x80}); got != want { + if got, want := img.At(0, 0), (color.RGBA{R: 0x80, G: 0x80, B: 0x80, A: 0x80}); got != want { t.Errorf("got: %v, want: %v", got, want) } } @@ -3461,10 +3461,10 @@ func TestImageTooManyConstantBuffersInDirectX(t *testing.T) { dst1.DrawTriangles(vs, is, src, op) } - if got, want := dst0.At(0, 0), (color.RGBA{0xff, 0xff, 0xff, 0xff}); got != want { + if got, want := dst0.At(0, 0), (color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}); got != want { t.Errorf("got: %v, want: %v", got, want) } - if got, want := dst1.At(0, 0), (color.RGBA{0xff, 0xff, 0xff, 0xff}); got != want { + if got, want := dst1.At(0, 0), (color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}); got != want { t.Errorf("got: %v, want: %v", got, want) } } @@ -3473,7 +3473,7 @@ func TestImageColorMAndScale(t *testing.T) { const w, h = 16, 16 src := ebiten.NewImage(w, h) - src.Fill(color.RGBA{0x80, 0x80, 0x80, 0x80}) + src.Fill(color.RGBA{R: 0x80, G: 0x80, B: 0x80, A: 0x80}) vs := []ebiten.Vertex{ { SrcX: 0, @@ -3537,17 +3537,17 @@ func TestImageColorMAndScale(t *testing.T) { switch format { case ebiten.ColorScaleModeStraightAlpha: want = color.RGBA{ - byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.5 * 0.75)), - byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.25 * 0.75)), - byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.5 * 0.75)), - byte(math.Floor(0xff * alphaBeforeScale * 0.75)), + R: byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.5 * 0.75)), + G: byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.25 * 0.75)), + B: byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.5 * 0.75)), + A: byte(math.Floor(0xff * alphaBeforeScale * 0.75)), } case ebiten.ColorScaleModePremultipliedAlpha: want = color.RGBA{ - byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.5)), - byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.25)), - byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.5)), - byte(math.Floor(0xff * alphaBeforeScale * 0.75)), + R: byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.5)), + G: byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.25)), + B: byte(math.Floor(0xff * (0.5/alphaBeforeScale + 0.25) * alphaBeforeScale * 0.5)), + A: byte(math.Floor(0xff * alphaBeforeScale * 0.75)), } } if !sameColors(got, want, 2) { @@ -3878,9 +3878,9 @@ func TestImageAntiAliasAndBlend(t *testing.T) { ebiten.BlendCopy, ebiten.BlendSourceOver, } { - dst0.Fill(color.RGBA{0x24, 0x3f, 0x6a, 0x88}) - dst1.Fill(color.RGBA{0x24, 0x3f, 0x6a, 0x88}) - src.Fill(color.RGBA{0x85, 0xa3, 0x08, 0xd3}) + dst0.Fill(color.RGBA{R: 0x24, G: 0x3f, B: 0x6a, A: 0x88}) + dst1.Fill(color.RGBA{R: 0x24, G: 0x3f, B: 0x6a, A: 0x88}) + src.Fill(color.RGBA{R: 0x85, G: 0xa3, B: 0x08, A: 0xd3}) op0 := &ebiten.DrawTrianglesOptions{} op0.Blend = blend @@ -3947,7 +3947,7 @@ func TestImageColorMScale(t *testing.T) { dst0 := ebiten.NewImage(w, h) dst1 := ebiten.NewImage(w, h) src := ebiten.NewImage(w, h) - src.Fill(color.RGBA{0x24, 0x3f, 0x6a, 0x88}) + src.Fill(color.RGBA{R: 0x24, G: 0x3f, B: 0x6a, A: 0x88}) // As the ColorM is a diagonal matrix, a built-in shader for a color matrix is NOT used. op := &ebiten.DrawImageOptions{} @@ -3972,7 +3972,7 @@ func TestImageColorScaleAndColorM(t *testing.T) { dst0 := ebiten.NewImage(w, h) dst1 := ebiten.NewImage(w, h) src := ebiten.NewImage(w, h) - src.Fill(color.RGBA{0x24, 0x3f, 0x6a, 0x88}) + src.Fill(color.RGBA{R: 0x24, G: 0x3f, B: 0x6a, A: 0x88}) // ColorScale is applied to premultiplied-alpha colors. op := &ebiten.DrawImageOptions{} @@ -3995,9 +3995,9 @@ func TestImageColorScaleAndColorM(t *testing.T) { func TestImageSetAndSubImage(t *testing.T) { const w, h = 16, 16 img := ebiten.NewImage(w, h) - img.Set(1, 1, color.RGBA{0xff, 0, 0, 0xff}) + img.Set(1, 1, color.RGBA{R: 0xff, A: 0xff}) got := img.SubImage(image.Rect(0, 0, w, h)).At(1, 1).(color.RGBA) - want := color.RGBA{0xff, 0, 0, 0xff} + want := color.RGBA{R: 0xff, A: 0xff} if got != want { t.Errorf("got: %v, want: %v", got, want) } diff --git a/input.go b/input.go index 6bb43c20e..ded1467ca 100644 --- a/input.go +++ b/input.go @@ -53,7 +53,7 @@ func InputChars() []rune { // If you want to know whether the key started being pressed in the current tick, // use inpututil.IsKeyJustPressed // -// Note that a Key represents a pysical key of US keyboard layout. +// Note that a Key represents a physical key of US keyboard layout. // For example, KeyQ represents Q key on US keyboards and ' (quote) key on Dvorak keyboards. // // Known issue: On Edge browser, some keys don't work well: @@ -73,7 +73,7 @@ func IsKeyPressed(key Key) bool { // KeyName returns a key name for the current keyboard layout. // For example, KeyName(KeyQ) returns 'q' for a QWERTY keyboard, and returns 'a' for an AZERTY keyboard. // -// KeyName returns an empty string if 1) the key doesn't have a phisical key name, 2) the platform doesn't support KeyName, +// KeyName returns an empty string if 1) the key doesn't have a physical key name, 2) the platform doesn't support KeyName, // or 3) the main loop doesn't start yet. // // KeyName is supported by desktops and browsers. @@ -113,7 +113,7 @@ func IsMouseButtonPressed(mouseButton MouseButton) bool { return theInputState.isMouseButtonPressed(mouseButton) } -// GamepadID represents a gamepad's identifier. +// GamepadID represents a gamepad identifier. type GamepadID = gamepad.ID // GamepadSDLID returns a string with the GUID generated in the same way as SDL. @@ -132,7 +132,7 @@ func GamepadSDLID(id GamepadID) string { // GamepadName returns a string with the name. // This function may vary in how it returns descriptions for the same device across platforms. -// for example the following drivers/platforms see a Xbox One controller as the following: +// for example the following drivers/platforms see an Xbox One controller as the following: // // - Windows: "Xbox Controller" // - Chrome: "Xbox 360 Controller (XInput STANDARD GAMEPAD)" @@ -225,7 +225,7 @@ func GamepadButtonNum(id GamepadID) int { // // IsGamepadButtonPressed is concurrent-safe. // -// The relationships between physical buttons and buttion IDs depend on environments. +// The relationships between physical buttons and button IDs depend on environments. // There can be differences even between Chrome and Firefox. func IsGamepadButtonPressed(id GamepadID, button GamepadButton) bool { g := gamepad.Get(id) @@ -385,7 +385,7 @@ func TouchIDs() []TouchID { // // If the touch of the specified ID is not present, TouchPosition returns (0, 0). // -// TouchPosition is cuncurrent-safe. +// TouchPosition is concurrent-safe. func TouchPosition(id TouchID) (int, int) { return theInputState.touchPosition(id) } @@ -427,7 +427,7 @@ func (i *inputState) isKeyPressed(key Key) bool { case KeyMeta: return i.state.KeyPressed[ui.KeyMetaLeft] || i.state.KeyPressed[ui.KeyMetaRight] default: - return i.state.KeyPressed[ui.Key(key)] + return i.state.KeyPressed[key] } } diff --git a/internal/atlas/image.go b/internal/atlas/image.go index 3f6c07a5c..97118f020 100644 --- a/internal/atlas/image.go +++ b/internal/atlas/image.go @@ -47,7 +47,7 @@ func temporaryBytesSize(size int) int { return l } -// alloc allocates the pixels and reutrns it. +// alloc allocates the pixels and returns it. // Be careful that the returned pixels might not be zero-cleared. func (t *temporaryBytes) alloc(size int) []byte { if len(t.pixels) < t.pos+size { @@ -107,7 +107,7 @@ func flushDeferred() { } // baseCountToPutOnAtlas represents the base time duration when the image can be put onto an atlas. -// Actual time duration is increased in an exponential way for each usages as a rendering target. +// Actual time duration is increased in an exponential way for each usage as a rendering target. const baseCountToPutOnAtlas = 10 func putImagesOnAtlas(graphicsDriver graphicsdriver.Graphics) error { @@ -141,7 +141,7 @@ type backend struct { func (b *backend) tryAlloc(width, height int) (*packing.Node, bool) { n := b.page.Alloc(width, height) if n == nil { - // The page can't be extended any more. Return as failure. + // The page can't be extended anymore. Return as failure. return nil, false } @@ -163,7 +163,7 @@ var ( deferred []func() - // deferredM is a mutext for the slice operations. This must not be used for other usages. + // deferredM is a mutex for the slice operations. This must not be used for other usages. deferredM sync.Mutex ) @@ -218,13 +218,13 @@ type Image struct { // moveTo moves its content to the given image dst. // After moveTo is called, the image i is no longer available. // -// moveTo is smilar to C++'s move semantics. +// moveTo is similar to C++'s move semantics. func (i *Image) moveTo(dst *Image) { dst.dispose(false) *dst = *i // i is no longer available but Dispose must not be called - // since i and dst have the same values like node. + // since i and dst have the same values as node. runtime.SetFinalizer(i, nil) } @@ -421,7 +421,7 @@ func (i *Image) drawTriangles(srcs [graphics.ShaderImageCount]*Image, vertices [ vertices[i+2] = (vertices[i+2] + oxf) / swf vertices[i+3] = (vertices[i+3] + oyf) / shf } - // srcRegion can be delibarately empty when this is not needed in order to avoid unexpected + // srcRegion can be deliberately empty when this is not needed in order to avoid unexpected // performance issue (#1293). if srcRegion.Width != 0 && srcRegion.Height != 0 { srcRegion.X += oxf @@ -461,7 +461,7 @@ func (i *Image) drawTriangles(srcs [graphics.ShaderImageCount]*Image, vertices [ continue } if !src.isOnAtlas() && src.canBePutOnAtlas() { - // src might already registered, but assiging it again is not harmful. + // src might already registered, but assigning it again is not harmful. imagesToPutOnAtlas[src] = struct{}{} } } diff --git a/internal/atlas/image_test.go b/internal/atlas/image_test.go index b5e6ca3e1..972f31dee 100644 --- a/internal/atlas/image_test.go +++ b/internal/atlas/image_test.go @@ -134,11 +134,11 @@ func TestEnsureIsolated(t *testing.T) { g := pix[4*(size*j+i)+1] b := pix[4*(size*j+i)+2] a := pix[4*(size*j+i)+3] - got := color.RGBA{r, g, b, a} + got := color.RGBA{R: r, G: g, B: b, A: a} var want color.RGBA if i < dx0 || dx1 <= i || j < dy0 || dy1 <= j { c := byte(i + j) - want = color.RGBA{c, c, c, c} + want = color.RGBA{R: c, G: c, B: c, A: c} } if got != want { t.Errorf("at(%d, %d): got: %v, want: %v", i, j, got, want) @@ -202,7 +202,7 @@ func TestReputOnAtlas(t *testing.T) { // Use img1 as a render source. // Use the doubled count since img1 was on a texture atlas and became an isolated image once. - // Then, img1 requires longer time to recover to be on a textur atlas again. + // Then, img1 requires longer time to recover to be on a texture atlas again. for i := 0; i < atlas.BaseCountToPutOnAtlas*2; i++ { if err := atlas.PutImagesOnAtlasForTesting(ui.GraphicsDriverForTesting()); err != nil { t.Fatal(err) @@ -222,12 +222,12 @@ func TestReputOnAtlas(t *testing.T) { } for j := 0; j < size; j++ { for i := 0; i < size; i++ { - want := color.RGBA{byte(i + j), byte(i + j), byte(i + j), byte(i + j)} + want := color.RGBA{R: byte(i + j), G: byte(i + j), B: byte(i + j), A: byte(i + j)} r := pix[4*(size*j+i)] g := pix[4*(size*j+i)+1] b := pix[4*(size*j+i)+2] a := pix[4*(size*j+i)+3] - got := color.RGBA{r, g, b, a} + got := color.RGBA{R: r, G: g, B: b, A: a} if got != want { t.Errorf("At(%d, %d): got: %v, want: %v", i, j, got, want) } @@ -246,12 +246,12 @@ func TestReputOnAtlas(t *testing.T) { } for j := 0; j < size; j++ { for i := 0; i < size; i++ { - want := color.RGBA{byte(i + j), byte(i + j), byte(i + j), byte(i + j)} + want := color.RGBA{R: byte(i + j), G: byte(i + j), B: byte(i + j), A: byte(i + j)} r := pix[4*(size*j+i)] g := pix[4*(size*j+i)+1] b := pix[4*(size*j+i)+2] a := pix[4*(size*j+i)+3] - got := color.RGBA{r, g, b, a} + got := color.RGBA{R: r, G: g, B: b, A: a} if got != want { t.Errorf("At(%d, %d): got: %v, want: %v", i, j, got, want) } @@ -338,9 +338,9 @@ func TestExtend(t *testing.T) { g := pix0[4*(w0*j+i)+1] b := pix0[4*(w0*j+i)+2] a := pix0[4*(w0*j+i)+3] - got := color.RGBA{r, g, b, a} + got := color.RGBA{R: r, G: g, B: b, A: a} c := byte(i + w0*j) - want := color.RGBA{c, c, c, c} + want := color.RGBA{R: c, G: c, B: c, A: c} if got != want { t.Errorf("at(%d, %d): got: %v, want: %v", i, j, got, want) } @@ -357,9 +357,9 @@ func TestExtend(t *testing.T) { g := pix1[4*(w1*j+i)+1] b := pix1[4*(w1*j+i)+2] a := pix1[4*(w1*j+i)+3] - got := color.RGBA{r, g, b, a} + got := color.RGBA{R: r, G: g, B: b, A: a} c := byte(i + w1*j) - want := color.RGBA{c, c, c, c} + want := color.RGBA{R: c, G: c, B: c, A: c} if got != want { t.Errorf("at(%d, %d): got: %v, want: %v", i, j, got, want) } @@ -404,9 +404,9 @@ func TestWritePixelsAfterDrawTriangles(t *testing.T) { g := pix[4*(w*j+i)+1] b := pix[4*(w*j+i)+2] a := pix[4*(w*j+i)+3] - got := color.RGBA{r, g, b, a} + got := color.RGBA{R: r, G: g, B: b, A: a} c := byte(i + w*j) - want := color.RGBA{c, c, c, c} + want := color.RGBA{R: c, G: c, B: c, A: c} if got != want { t.Errorf("at(%d, %d): got %v, want: %v", i, j, got, want) } @@ -562,7 +562,7 @@ func Disable_TestMinImageSize(t *testing.T) { func TestMaxImageSizeJust(t *testing.T) { s := maxImageSizeForTesting - // An unmanged image never belongs to an atlas and doesn't have its paddings. + // An unmanaged image never belongs to an atlas and doesn't have its paddings. // TODO: Should we allow such this size for ImageTypeRegular? img := atlas.NewImage(s, s, atlas.ImageTypeUnmanaged) defer img.MarkDisposed() @@ -620,7 +620,7 @@ func TestDisposedAndReputOnAtlas(t *testing.T) { } } - // Before PutImaegsOnAtlasForTesting, dispose the image. + // Before PutImagesOnAtlasForTesting, dispose the image. src.MarkDisposed() // Force to dispose the image. @@ -722,12 +722,12 @@ func TestImageWritePixelsModify(t *testing.T) { } for j := 0; j < size; j++ { for i := 0; i < size; i++ { - want := color.RGBA{byte(i + j), byte(i + j), byte(i + j), byte(i + j)} + want := color.RGBA{R: byte(i + j), G: byte(i + j), B: byte(i + j), A: byte(i + j)} r := pix[4*(size*j+i)] g := pix[4*(size*j+i)+1] b := pix[4*(size*j+i)+2] a := pix[4*(size*j+i)+3] - got := color.RGBA{r, g, b, a} + got := color.RGBA{R: r, G: g, B: b, A: a} if got != want { t.Errorf("Type: %d, At(%d, %d): got: %v, want: %v", typ, i, j, got, want) } diff --git a/internal/atlas/shader_test.go b/internal/atlas/shader_test.go index 7f9336515..1c4f28243 100644 --- a/internal/atlas/shader_test.go +++ b/internal/atlas/shader_test.go @@ -51,7 +51,7 @@ func TestShaderFillTwice(t *testing.T) { if err := dst.ReadPixels(g, pix); err != nil { t.Error(err) } - if got, want := (color.RGBA{pix[0], pix[1], pix[2], pix[3]}), (color.RGBA{0x80, 0x80, 0x80, 0xff}); got != want { + if got, want := (color.RGBA{R: pix[0], G: pix[1], B: pix[2], A: pix[3]}), (color.RGBA{R: 0x80, G: 0x80, B: 0x80, A: 0xff}); got != want { t.Errorf("got: %v, want: %v", got, want) } } @@ -83,7 +83,7 @@ func TestImageDrawTwice(t *testing.T) { if err := dst.ReadPixels(ui.GraphicsDriverForTesting(), pix); err != nil { t.Error(err) } - if got, want := (color.RGBA{pix[0], pix[1], pix[2], pix[3]}), (color.RGBA{0x80, 0x80, 0x80, 0xff}); got != want { + if got, want := (color.RGBA{R: pix[0], G: pix[1], B: pix[2], A: pix[3]}), (color.RGBA{R: 0x80, G: 0x80, B: 0x80, A: 0xff}); got != want { t.Errorf("got: %v, want: %v", got, want) } } diff --git a/internal/buffered/command.go b/internal/buffered/command.go index afe9b4ea9..67aea1ea8 100644 --- a/internal/buffered/command.go +++ b/internal/buffered/command.go @@ -62,7 +62,7 @@ func getDelayedFuncsAndClearSlow() []func() { // maybeCanAddDelayedCommand returns false if the delayed commands cannot be added. // Otherwise, maybeCanAddDelayedCommand's returning value is not determined. -// For example, maybeCanAddDelayedCommand can return true even when flusing is being processed. +// For example, maybeCanAddDelayedCommand can return true even when flushing is being processed. func maybeCanAddDelayedCommand() bool { return atomic.LoadUint32(&delayedCommandsFlushed) == 0 } diff --git a/internal/buffered/image_test.go b/internal/buffered/image_test.go index 7a6a11f8a..c07388369 100644 --- a/internal/buffered/image_test.go +++ b/internal/buffered/image_test.go @@ -83,7 +83,7 @@ type testResult struct { } var testSetBeforeMainResult = func() testResult { - clr := color.RGBA{1, 2, 3, 4} + clr := color.RGBA{R: 1, G: 2, B: 3, A: 4} img := ebiten.NewImage(16, 16) img.Set(0, 0, clr) @@ -124,7 +124,7 @@ var testDrawImageBeforeMainResult = func() testResult { }() return testResult{ - want: color.RGBA{0xff, 0xff, 0xff, 0xff}, + want: color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}, got: ch, } }() @@ -185,7 +185,7 @@ var testDrawTrianglesBeforeMainResult = func() testResult { }() return testResult{ - want: color.RGBA{0xff, 0xff, 0xff, 0xff}, + want: color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}, got: ch, } }() @@ -200,10 +200,10 @@ func TestDrawTrianglesBeforeMain(t *testing.T) { } var testSetAndFillBeforeMainResult = func() testResult { - clr := color.RGBA{1, 2, 3, 4} + clr := color.RGBA{R: 1, G: 2, B: 3, A: 4} img := ebiten.NewImage(16, 16) img.Set(0, 0, clr) - img.Fill(color.RGBA{5, 6, 7, 8}) + img.Fill(color.RGBA{R: 5, G: 6, B: 7, A: 8}) img.Set(1, 0, clr) ch := make(chan color.RGBA, 1) @@ -214,7 +214,7 @@ var testSetAndFillBeforeMainResult = func() testResult { }() return testResult{ - want: color.RGBA{5, 6, 7, 8}, + want: color.RGBA{R: 5, G: 6, B: 7, A: 8}, got: ch, } }() @@ -229,7 +229,7 @@ func TestSetAndFillBeforeMain(t *testing.T) { } var testSetAndWritePixelsBeforeMainResult = func() testResult { - clr := color.RGBA{1, 2, 3, 4} + clr := color.RGBA{R: 1, G: 2, B: 3, A: 4} img := ebiten.NewImage(16, 16) img.Set(0, 0, clr) pix := make([]byte, 4*16*16) @@ -250,7 +250,7 @@ var testSetAndWritePixelsBeforeMainResult = func() testResult { }() return testResult{ - want: color.RGBA{5, 6, 7, 8}, + want: color.RGBA{R: 5, G: 6, B: 7, A: 8}, got: ch, } }() @@ -290,7 +290,7 @@ var testWritePixelsAndModifyBeforeMainResult = func() testResult { }() return testResult{ - want: color.RGBA{1, 2, 3, 4}, + want: color.RGBA{R: 1, G: 2, B: 3, A: 4}, got: ch, } }() diff --git a/internal/cocoa/api_cocoa_darwin.go b/internal/cocoa/api_cocoa_darwin.go index f11cb131c..96a32394d 100644 --- a/internal/cocoa/api_cocoa_darwin.go +++ b/internal/cocoa/api_cocoa_darwin.go @@ -138,7 +138,7 @@ func (w NSWindow) SetBackgroundColor(color NSColor) { w.Send(sel_setBackgroundColor, color.ID) } -func (w NSWindow) IsVisibile() bool { +func (w NSWindow) IsVisible() bool { return w.Send(sel_isVisible) != 0 } diff --git a/internal/devicescale/devicescale.go b/internal/devicescale/devicescale.go index a3b725474..fd35dc9f0 100644 --- a/internal/devicescale/devicescale.go +++ b/internal/devicescale/devicescale.go @@ -40,7 +40,7 @@ func GetAt(x, y int) float64 { return s } -// CelarCache clears the cache. +// ClearCache clears the cache. // This should be called when monitors are changed by connecting or disconnecting. func ClearCache() { // TODO: This should be called not only when monitors are changed but also a monitor's scales are changed. diff --git a/internal/devicescale/impl_desktop.go b/internal/devicescale/impl_desktop.go index 3237b8e53..565e7e8cf 100644 --- a/internal/devicescale/impl_desktop.go +++ b/internal/devicescale/impl_desktop.go @@ -35,7 +35,7 @@ func monitorAt(x, y int) *glfw.Monitor { func impl(x, y int) float64 { // Keep calling GetContentScale until the returned scale is 0 (#2051). - // Retry this at most 5 times to avoid an inifinite loop. + // Retry this at most 5 times to avoid an infinite loop. for i := 0; i < 5; i++ { // An error can happen e.g. when entering a screensaver on Windows (#2488). sx, _, err := monitorAt(x, y).GetContentScale() diff --git a/internal/gamepad/gamepad.go b/internal/gamepad/gamepad.go index fb1b451a2..ea098b162 100644 --- a/internal/gamepad/gamepad.go +++ b/internal/gamepad/gamepad.go @@ -99,7 +99,7 @@ func (g *gamepads) update() error { } // A gamepad can be detected even though there are not. Apparently, some special devices are - // recognized as gamepads by OSes. In this case, the number of the 'buttons' can exceeds the + // recognized as gamepads by OSes. In this case, the number of the 'buttons' can exceed the // maximum. Skip such devices as a tentative solution (#1173, #2039). g.remove(func(gamepad *Gamepad) bool { return gamepad.ButtonCount() > ButtonCount diff --git a/internal/gamepad/gamepad_darwin.go b/internal/gamepad/gamepad_darwin.go index 977b8c382..fa457447a 100644 --- a/internal/gamepad/gamepad_darwin.go +++ b/internal/gamepad/gamepad_darwin.go @@ -146,24 +146,24 @@ func (g *nativeGamepadsImpl) addDevice(device _IOHIDDeviceRef, gamepads *gamepad } name := "Unknown" - if prop := _IOHIDDeviceGetProperty(_IOHIDDeviceRef(device), _CFStringCreateWithCString(kCFAllocatorDefault, kIOHIDProductKey, kCFStringEncodingUTF8)); prop != 0 { + if prop := _IOHIDDeviceGetProperty(device, _CFStringCreateWithCString(kCFAllocatorDefault, kIOHIDProductKey, kCFStringEncodingUTF8)); prop != 0 { var cstr [256]byte _CFStringGetCString(_CFStringRef(prop), cstr[:], kCFStringEncodingUTF8) name = strings.TrimRight(string(cstr[:]), "\x00") } var vendor uint32 - if prop := _IOHIDDeviceGetProperty(_IOHIDDeviceRef(device), _CFStringCreateWithCString(kCFAllocatorDefault, kIOHIDVendorIDKey, kCFStringEncodingUTF8)); prop != 0 { + if prop := _IOHIDDeviceGetProperty(device, _CFStringCreateWithCString(kCFAllocatorDefault, kIOHIDVendorIDKey, kCFStringEncodingUTF8)); prop != 0 { _CFNumberGetValue(_CFNumberRef(prop), kCFNumberSInt32Type, unsafe.Pointer(&vendor)) } var product uint32 - if prop := _IOHIDDeviceGetProperty(_IOHIDDeviceRef(device), _CFStringCreateWithCString(kCFAllocatorDefault, kIOHIDProductIDKey, kCFStringEncodingUTF8)); prop != 0 { + if prop := _IOHIDDeviceGetProperty(device, _CFStringCreateWithCString(kCFAllocatorDefault, kIOHIDProductIDKey, kCFStringEncodingUTF8)); prop != 0 { _CFNumberGetValue(_CFNumberRef(prop), kCFNumberSInt32Type, unsafe.Pointer(&product)) } var version uint32 - if prop := _IOHIDDeviceGetProperty(_IOHIDDeviceRef(device), _CFStringCreateWithCString(kCFAllocatorDefault, kIOHIDVersionNumberKey, kCFStringEncodingUTF8)); prop != 0 { + if prop := _IOHIDDeviceGetProperty(device, _CFStringCreateWithCString(kCFAllocatorDefault, kIOHIDVersionNumberKey, kCFStringEncodingUTF8)); prop != 0 { _CFNumberGetValue(_CFNumberRef(prop), kCFNumberSInt32Type, unsafe.Pointer(&version)) } @@ -191,8 +191,8 @@ func (g *nativeGamepadsImpl) addDevice(device _IOHIDDeviceRef, gamepads *gamepad gp := gamepads.add(name, sdlID) gp.native = n - for i := _CFIndex(0); i < _CFArrayGetCount(_CFArrayRef(elements)); i++ { - native := (_IOHIDElementRef)(_CFArrayGetValueAtIndex(_CFArrayRef(elements), i)) + for i := _CFIndex(0); i < _CFArrayGetCount(elements); i++ { + native := (_IOHIDElementRef)(_CFArrayGetValueAtIndex(elements, i)) if _CFGetTypeID(_CFTypeRef(native)) != _IOHIDElementGetTypeID() { continue } diff --git a/internal/gamepad/gamepad_linux.go b/internal/gamepad/gamepad_linux.go index 77259dd97..e88164062 100644 --- a/internal/gamepad/gamepad_linux.go +++ b/internal/gamepad/gamepad_linux.go @@ -251,7 +251,7 @@ func (g *nativeGamepadsImpl) update(gamepads *gamepads) error { Cookie: uint32(buf[8]) | uint32(buf[9])<<8 | uint32(buf[10])<<16 | uint32(buf[11])<<24, Len: uint32(buf[12]) | uint32(buf[13])<<8 | uint32(buf[14])<<16 | uint32(buf[15])<<24, } - name := unix.ByteSliceToString(buf[16 : 16+e.Len-1]) // len includes the null termiinate. + name := unix.ByteSliceToString(buf[16 : 16+e.Len-1]) // len includes the null terminate. buf = buf[16+e.Len:] if !reEvent.MatchString(name) { continue diff --git a/internal/gamepad/gamepad_nintendosdk.cpp b/internal/gamepad/gamepad_nintendosdk.cpp index b6ce69ea0..836fe05ba 100644 --- a/internal/gamepad/gamepad_nintendosdk.cpp +++ b/internal/gamepad/gamepad_nintendosdk.cpp @@ -14,7 +14,7 @@ //go:build nintendosdk -// The actual implementaiton will be provided by -overlay. +// The actual implementation will be provided by -overlay. #include "gamepad_nintendosdk.h" diff --git a/internal/gamepaddb/gamepaddb_test.go b/internal/gamepaddb/gamepaddb_test.go index 42f2149cb..eb2fec887 100644 --- a/internal/gamepaddb/gamepaddb_test.go +++ b/internal/gamepaddb/gamepaddb_test.go @@ -46,7 +46,7 @@ func TestUpdate(t *testing.T) { Err: true, }, { - Input: "00000000000000000000000000000000,foo,pltform:Foo", + Input: "00000000000000000000000000000000,foo,platform:Foo", Err: true, }, { diff --git a/internal/goglfw/api_windows.go b/internal/goglfw/api_windows.go index ffbedde36..d0af82142 100644 --- a/internal/goglfw/api_windows.go +++ b/internal/goglfw/api_windows.go @@ -1651,7 +1651,7 @@ func _SetWindowPos(hWnd windows.HWND, hWndInsertAfter windows.HWND, x, y, cx, cy } func _SetWindowTextW(hWnd windows.HWND, str string) error { - // An empty string is also a valid value. Always create a uint16 pointer. + // An empty string is also a valid value. Always create an uint16 pointer. lpString, err := windows.UTF16PtrFromString(str) if err != nil { panic("goglfw: str must not include a NUL character") diff --git a/internal/graphics/vertex.go b/internal/graphics/vertex.go index cd5809fe5..20a6fd3fd 100644 --- a/internal/graphics/vertex.go +++ b/internal/graphics/vertex.go @@ -67,7 +67,7 @@ func QuadVertices(dst []float32, sx0, sy0, sx1, sy1 float32, a, b, c, d, tx, ty x := sx1 - sx0 y := sy1 - sy0 ax, by, cx, dy := a*x, b*y, c*x, d*y - u0, v0, u1, v1 := float32(sx0), float32(sy0), float32(sx1), float32(sy1) + u0, v0, u1, v1 := sx0, sy0, sx1, sy1 // This function is very performance-sensitive and implement in a very dumb way. _ = dst[:4*VertexFloatCount] diff --git a/internal/graphicscommand/command.go b/internal/graphicscommand/command.go index e79eb6f58..09dd2fb18 100644 --- a/internal/graphicscommand/command.go +++ b/internal/graphicscommand/command.go @@ -29,7 +29,7 @@ import ( // // A command for drawing that is created when Image functions are called like DrawTriangles, // or Fill. -// A command is not immediately executed after created. Instaed, it is queued after created, +// A command is not immediately executed after created. Instead, it is queued after created, // and executed only when necessary. type command interface { fmt.Stringer @@ -603,12 +603,12 @@ func (q *commandQueue) prependPreservedUniforms(uniforms []uint32, shader *Shade idx += len(srcs) * 2 // Set the destination region. - uniforms[idx+0] = math.Float32bits(float32(dstRegion.X) / float32(dw)) - uniforms[idx+1] = math.Float32bits(float32(dstRegion.Y) / float32(dh)) + uniforms[idx+0] = math.Float32bits(dstRegion.X / float32(dw)) + uniforms[idx+1] = math.Float32bits(dstRegion.Y / float32(dh)) idx += 2 - uniforms[idx+0] = math.Float32bits(float32(dstRegion.Width) / float32(dw)) - uniforms[idx+1] = math.Float32bits(float32(dstRegion.Height) / float32(dh)) + uniforms[idx+0] = math.Float32bits(dstRegion.Width / float32(dw)) + uniforms[idx+1] = math.Float32bits(dstRegion.Height / float32(dh)) idx += 2 if srcs[0] != nil { @@ -631,12 +631,12 @@ func (q *commandQueue) prependPreservedUniforms(uniforms []uint32, shader *Shade idx += len(offsets) * 2 // Set the source region of texture0. - uniforms[idx+0] = math.Float32bits(float32(srcRegion.X)) - uniforms[idx+1] = math.Float32bits(float32(srcRegion.Y)) + uniforms[idx+0] = math.Float32bits(srcRegion.X) + uniforms[idx+1] = math.Float32bits(srcRegion.Y) idx += 2 - uniforms[idx+0] = math.Float32bits(float32(srcRegion.Width)) - uniforms[idx+1] = math.Float32bits(float32(srcRegion.Height)) + uniforms[idx+0] = math.Float32bits(srcRegion.Width) + uniforms[idx+1] = math.Float32bits(srcRegion.Height) idx += 2 uniforms[idx+0] = math.Float32bits(2 / float32(dw)) diff --git a/internal/graphicscommand/image.go b/internal/graphicscommand/image.go index 6c2510da9..e3148b969 100644 --- a/internal/graphicscommand/image.go +++ b/internal/graphicscommand/image.go @@ -37,7 +37,7 @@ type Image struct { internalHeight int screen bool - // id is an indentifier for the image. This is used only when dummping the information. + // id is an identifier for the image. This is used only when dumping the information. // // This is duplicated with graphicsdriver.Image's ID, but this id is still necessary because this image might not // have its graphicsdriver.Image. diff --git a/internal/graphicscommand/image_test.go b/internal/graphicscommand/image_test.go index 676033a91..72d7d7fa2 100644 --- a/internal/graphicscommand/image_test.go +++ b/internal/graphicscommand/image_test.go @@ -74,7 +74,7 @@ func TestClear(t *testing.T) { for j := 0; j < h/2; j++ { for i := 0; i < w/2; i++ { idx := 4 * (i + w*j) - got := color.RGBA{pix[idx], pix[idx+1], pix[idx+2], pix[idx+3]} + got := color.RGBA{R: pix[idx], G: pix[idx+1], B: pix[idx+2], A: pix[idx+3]} want := color.RGBA{} if got != want { t.Errorf("dst.At(%d, %d) after DrawTriangles: got %v, want: %v", i, j, got, want) @@ -128,8 +128,8 @@ func TestShader(t *testing.T) { for j := 0; j < h; j++ { for i := 0; i < w; i++ { idx := 4 * (i + w*j) - got := color.RGBA{pix[idx], pix[idx+1], pix[idx+2], pix[idx+3]} - want := color.RGBA{0xff, 0, 0, 0xff} + got := color.RGBA{R: pix[idx], G: pix[idx+1], B: pix[idx+2], A: pix[idx+3]} + want := color.RGBA{R: 0xff, A: 0xff} if got != want { t.Errorf("dst.At(%d, %d) after DrawTriangles: got %v, want: %v", i, j, got, want) } diff --git a/internal/graphicsdriver/directx/pipeline_windows.go b/internal/graphicsdriver/directx/pipeline_windows.go index 15c728de7..9527e7c17 100644 --- a/internal/graphicsdriver/directx/pipeline_windows.go +++ b/internal/graphicsdriver/directx/pipeline_windows.go @@ -162,10 +162,10 @@ func (p *pipelineStates) drawTriangles(device *_ID3D12Device, commandList *_ID3D p.constantBufferMaps[frameIndex] = append(p.constantBufferMaps[frameIndex], 0) } - const bufferSizeAlignement = 256 + const bufferSizeAlignment = 256 bufferSize := uint32(unsafe.Sizeof(uint32(0))) * uint32(len(uniforms)) if bufferSize > 0 { - bufferSize = ((bufferSize-1)/bufferSizeAlignement + 1) * bufferSizeAlignement + bufferSize = ((bufferSize-1)/bufferSizeAlignment + 1) * bufferSizeAlignment } cb := p.constantBuffers[frameIndex][idx] diff --git a/internal/graphicsdriver/metal/graphics_darwin.go b/internal/graphicsdriver/metal/graphics_darwin.go index 8afb0c0ca..fb733eddf 100644 --- a/internal/graphicsdriver/metal/graphics_darwin.go +++ b/internal/graphicsdriver/metal/graphics_darwin.go @@ -452,7 +452,7 @@ func (g *Graphics) flushRenderCommandEncoderIfNeeded() { } func (g *Graphics) draw(dst *Image, dstRegions []graphicsdriver.DstRegion, srcs [graphics.ShaderImageCount]*Image, indexOffset int, shader *Shader, uniforms [][]uint32, blend graphicsdriver.Blend, evenOdd bool) error { - // When prepareing a stencil buffer, flush the current render command encoder + // When preparing a stencil buffer, flush the current render command encoder // to make sure the stencil buffer is cleared when loading. // TODO: What about clearing the stencil buffer by vertices? if g.lastDst != dst || g.lastEvenOdd != evenOdd || evenOdd { @@ -850,7 +850,7 @@ func (i *Image) WritePixels(args []*graphicsdriver.WritePixelsArgs) error { w := maxX - minX h := maxY - minY - // Use a temporary texture to send pixels asynchrounsly, whichever the memory is shared (e.g., iOS) or + // Use a temporary texture to send pixels asynchronously, whichever the memory is shared (e.g., iOS) or // managed (e.g., macOS). A temporary texture is needed since ReplaceRegion tries to sync the pixel // data between CPU and GPU, and doing it on the existing texture is inefficient (#1418). // The texture cannot be reused until sending the pixels finishes, then create new ones for each call. diff --git a/internal/graphicsdriver/metal/mtl/mtl_darwin.go b/internal/graphicsdriver/metal/mtl/mtl_darwin.go index ea2ca5eda..822ea02e0 100644 --- a/internal/graphicsdriver/metal/mtl/mtl_darwin.go +++ b/internal/graphicsdriver/metal/mtl/mtl_darwin.go @@ -158,7 +158,7 @@ const ( StoreActionCustomSampleDepthStore StoreAction = 5 ) -// StorageMode defines defines the memory location and access permissions of a resource. +// StorageMode defines the memory location and access permissions of a resource. // // Reference: https://developer.apple.com/documentation/metal/mtlstoragemode. type StorageMode uint8 diff --git a/internal/graphicsdriver/opengl/gl/procaddr_others.go b/internal/graphicsdriver/opengl/gl/procaddr_others.go index adb3ed353..6da1c8619 100644 --- a/internal/graphicsdriver/opengl/gl/procaddr_others.go +++ b/internal/graphicsdriver/opengl/gl/procaddr_others.go @@ -65,7 +65,7 @@ func (c *defaultContext) init() error { } } - // Try OpenGL first. OpenGL is preferrable as this doesn't cause context losts. + // Try OpenGL first. OpenGL is preferable as this doesn't cause context losses. if !preferES { // Usually libGL.so or libGL.so.1 is used. libGL.so.2 might exist only on NetBSD. for _, name := range []string{"libGL.so", "libGL.so.2", "libGL.so.1", "libGL.so.0"} { diff --git a/internal/graphicsdriver/opengl/graphics.go b/internal/graphicsdriver/opengl/graphics.go index 1d33fd861..16f5d048b 100644 --- a/internal/graphicsdriver/opengl/graphics.go +++ b/internal/graphicsdriver/opengl/graphics.go @@ -70,7 +70,7 @@ func (g *Graphics) End(present bool) error { } func (g *Graphics) SetTransparent(transparent bool) { - // Do nothings. + // Do nothing. } func (g *Graphics) checkSize(width, height int) { diff --git a/internal/jsutil/buf_js.go b/internal/jsutil/buf_js.go index 31b838f44..50c334a20 100644 --- a/internal/jsutil/buf_js.go +++ b/internal/jsutil/buf_js.go @@ -57,7 +57,7 @@ func ensureTemporaryArrayBufferSize(byteLength int) { } } -// TemporaryUint8ArrayFromUint8Slice returns a Uint8Array whose length is at least minLength from a uint8 slice. +// TemporaryUint8ArrayFromUint8Slice returns a Uint8Array whose length is at least minLength from an uint8 slice. // Be careful that the length can exceed the given minLength. // data must be a slice of a numeric type for initialization, or nil if you don't need initialization. func TemporaryUint8ArrayFromUint8Slice(minLength int, data []uint8) js.Value { @@ -66,7 +66,7 @@ func TemporaryUint8ArrayFromUint8Slice(minLength int, data []uint8) js.Value { return temporaryUint8Array } -// TemporaryUint8ArrayFromUint16Slice returns a Uint8Array whose length is at least minLength from a uint16 slice. +// TemporaryUint8ArrayFromUint16Slice returns a Uint8Array whose length is at least minLength from an uint16 slice. // Be careful that the length can exceed the given minLength. // data must be a slice of a numeric type for initialization, or nil if you don't need initialization. func TemporaryUint8ArrayFromUint16Slice(minLength int, data []uint16) js.Value { diff --git a/internal/packing/packing.go b/internal/packing/packing.go index b61504cf5..e2a4d1484 100644 --- a/internal/packing/packing.go +++ b/internal/packing/packing.go @@ -159,7 +159,7 @@ func alloc(n *Node, width, height int) *Node { parent: n, } } else { - // Split holizontally + // Split horizontally n.child0 = &Node{ x: n.x, y: n.y, diff --git a/internal/processtest/testdata/issue1753.go b/internal/processtest/testdata/issue1753.go index 3e702df2a..5ca4ee0d4 100644 --- a/internal/processtest/testdata/issue1753.go +++ b/internal/processtest/testdata/issue1753.go @@ -58,7 +58,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { // Dispose the shader. When a new shader is created in the next phase, the underlying shader ID might be reused. // This test checks that the new shader works in this situation. - // The actual disposal will happen after this frame and before the next frame in the current implmentation. + // The actual disposal will happen after this frame and before the next frame in the current implementation. s.Dispose() g.phase++ diff --git a/internal/restorable/doc.go b/internal/restorable/doc.go index 731fb5277..9d23d7364 100644 --- a/internal/restorable/doc.go +++ b/internal/restorable/doc.go @@ -46,7 +46,7 @@ // // After any of the drawing functions is called, the target image can't be depended on by // any other images. For example, if an image A depends on an image B, and B is changed -// by a Fill call after that, the image A can't depend on the image B any more. +// by a Fill call after that, the image A can't depend on the image B anymore. // In this case, as the image B can no longer be used to restore the image A, // the image A becomes 'stale'. // As all the stale images are resolved before context lost happens, diff --git a/internal/restorable/image.go b/internal/restorable/image.go index 2402df0e1..41703c1bd 100644 --- a/internal/restorable/image.go +++ b/internal/restorable/image.go @@ -97,7 +97,7 @@ const ( // // Regular non-volatile images need to record drawing history or read its pixels from GPU if necessary so that all // the images can be restored automatically from the context lost. However, such recording the drawing history or - // reading pixels from GPU are expensive operations. Volatile images can skip such oprations, but the image content + // reading pixels from GPU are expensive operations. Volatile images can skip such operations, but the image content // is cleared every frame instead. ImageTypeVolatile ) @@ -168,7 +168,7 @@ func ensureWhiteImage() *Image { return whiteImage } -// NewImage creates an white image with the given size. +// NewImage creates a white image with the given size. // // The returned image is cleared. // @@ -302,7 +302,7 @@ func (i *Image) WritePixels(pixels []byte, x, y, width, height int) { } // TODO: Avoid making other images stale if possible. (#514) - // For this purpuse, images should remember which part of that is used for DrawTriangles. + // For this purpose, images should remember which part of that is used for DrawTriangles. theImages.makeStaleIfDependingOn(i) if pixels != nil { @@ -550,7 +550,7 @@ func (i *Image) dependsOnShader(shader *Shader) bool { return false } -// dependingImages returns all images that is depended by the image. +// dependingImages returns all images that is depended on the image. func (i *Image) dependingImages() map[*Image]struct{} { r := map[*Image]struct{}{} for _, c := range i.drawTrianglesHistory { diff --git a/internal/restorable/images.go b/internal/restorable/images.go index 53f747ba5..6730bac7d 100644 --- a/internal/restorable/images.go +++ b/internal/restorable/images.go @@ -235,7 +235,7 @@ func (i *images) restore(graphicsDriver graphicsdriver.Graphics) error { } } for len(images) > 0 { - // current repesents images that have no incoming edges. + // current represents images that have no incoming edges. current := map[*Image]struct{}{} for i := range images { current[i] = struct{}{} diff --git a/internal/restorable/images_test.go b/internal/restorable/images_test.go index f8b22a73e..2d742aad6 100644 --- a/internal/restorable/images_test.go +++ b/internal/restorable/images_test.go @@ -34,7 +34,7 @@ func TestMain(m *testing.M) { func pixelsToColor(p *restorable.Pixels, i, j, imageWidth, imageHeight int) color.RGBA { var pix [4]byte p.ReadPixels(pix[:], i, j, 1, 1, imageWidth, imageHeight) - return color.RGBA{pix[0], pix[1], pix[2], pix[3]} + return color.RGBA{R: pix[0], G: pix[1], B: pix[2], A: pix[3]} } func abs(x int) int { @@ -60,7 +60,7 @@ func TestRestore(t *testing.T) { img0 := restorable.NewImage(1, 1, restorable.ImageTypeRegular) defer img0.Dispose() - clr0 := color.RGBA{0x00, 0x00, 0x00, 0xff} + clr0 := color.RGBA{A: 0xff} img0.WritePixels([]byte{clr0.R, clr0.G, clr0.B, clr0.A}, 0, 0, 1, 1) if err := restorable.ResolveStaleImages(ui.GraphicsDriverForTesting(), false); err != nil { t.Fatal(err) @@ -90,7 +90,7 @@ func TestRestoreWithoutDraw(t *testing.T) { for j := 0; j < 1024; j++ { for i := 0; i < 1024; i++ { - want := color.RGBA{0x00, 0x00, 0x00, 0x00} + want := color.RGBA{} got := pixelsToColor(img0.BasePixelsForTesting(), i, j, 1024, 1024) if !sameColors(got, want, 0) { t.Errorf("got %v, want %v", got, want) @@ -134,7 +134,7 @@ func TestRestoreChain(t *testing.T) { img.Dispose() } }() - clr := color.RGBA{0x00, 0x00, 0x00, 0xff} + clr := color.RGBA{A: 0xff} imgs[0].WritePixels([]byte{clr.R, clr.G, clr.B, clr.A}, 0, 0, 1, 1) for i := 0; i < num-1; i++ { vs := quadVertices(imgs[i], 1, 1, 0, 0) @@ -179,11 +179,11 @@ func TestRestoreChain2(t *testing.T) { } }() - clr0 := color.RGBA{0xff, 0x00, 0x00, 0xff} + clr0 := color.RGBA{R: 0xff, A: 0xff} imgs[0].WritePixels([]byte{clr0.R, clr0.G, clr0.B, clr0.A}, 0, 0, w, h) - clr7 := color.RGBA{0x00, 0xff, 0x00, 0xff} + clr7 := color.RGBA{G: 0xff, A: 0xff} imgs[7].WritePixels([]byte{clr7.R, clr7.G, clr7.B, clr7.A}, 0, 0, w, h) - clr8 := color.RGBA{0x00, 0x00, 0xff, 0xff} + clr8 := color.RGBA{B: 0xff, A: 0xff} imgs[8].WritePixels([]byte{clr8.R, clr8.G, clr8.B, clr8.A}, 0, 0, w, h) is := graphics.QuadIndices() @@ -232,8 +232,8 @@ func TestRestoreOverrideSource(t *testing.T) { img1.Dispose() img0.Dispose() }() - clr0 := color.RGBA{0x00, 0x00, 0x00, 0xff} - clr1 := color.RGBA{0x00, 0x00, 0x01, 0xff} + clr0 := color.RGBA{A: 0xff} + clr1 := color.RGBA{B: 0x01, A: 0xff} img1.WritePixels([]byte{clr0.R, clr0.G, clr0.B, clr0.A}, 0, 0, w, h) is := graphics.QuadIndices() dr := graphicsdriver.Region{ @@ -404,7 +404,7 @@ func TestRestoreComplexGraph(t *testing.T) { for i := 0; i < 4; i++ { want := color.RGBA{} if c.out[i] == '*' { - want = color.RGBA{0xff, 0xff, 0xff, 0xff} + want = color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff} } got := pixelsToColor(c.image.BasePixelsForTesting(), i, 0, w, h) if !sameColors(got, want, 1) { @@ -473,7 +473,7 @@ func TestRestoreRecursive(t *testing.T) { for i := 0; i < 4; i++ { want := color.RGBA{} if c.out[i] == '*' { - want = color.RGBA{0xff, 0xff, 0xff, 0xff} + want = color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff} } got := pixelsToColor(c.image.BasePixelsForTesting(), i, 0, w, h) if !sameColors(got, want, 1) { @@ -492,7 +492,7 @@ func TestWritePixels(t *testing.T) { pix[i] = 0xff } img.WritePixels(pix, 5, 7, 4, 4) - // Check the region (5, 7)-(9, 11). Outside state is indeterministic. + // Check the region (5, 7)-(9, 11). Outside state is indeterminate. for i := range pix { pix[i] = 0 } @@ -502,8 +502,8 @@ func TestWritePixels(t *testing.T) { for j := 7; j < 11; j++ { for i := 5; i < 9; i++ { idx := 4 * ((j-7)*4 + i - 5) - got := color.RGBA{pix[idx], pix[idx+1], pix[idx+2], pix[idx+3]} - want := color.RGBA{0xff, 0xff, 0xff, 0xff} + got := color.RGBA{R: pix[idx], G: pix[idx+1], B: pix[idx+2], A: pix[idx+3]} + want := color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff} if got != want { t.Errorf("(%d, %d): got: %v, want: %v", i, j, got, want) } @@ -521,8 +521,8 @@ func TestWritePixels(t *testing.T) { for j := 7; j < 11; j++ { for i := 5; i < 9; i++ { idx := 4 * ((j-7)*4 + i - 5) - got := color.RGBA{pix[idx], pix[idx+1], pix[idx+2], pix[idx+3]} - want := color.RGBA{0xff, 0xff, 0xff, 0xff} + got := color.RGBA{R: pix[idx], G: pix[idx+1], B: pix[idx+2], A: pix[idx+3]} + want := color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff} if got != want { t.Errorf("(%d, %d): got: %v, want: %v", i, j, got, want) } @@ -562,8 +562,8 @@ func TestDrawTrianglesAndWritePixels(t *testing.T) { if err := img1.ReadPixels(ui.GraphicsDriverForTesting(), pix[:], 0, 0, 1, 1); err != nil { t.Fatal(err) } - got := color.RGBA{pix[0], pix[1], pix[2], pix[3]} - want := color.RGBA{0xff, 0xff, 0xff, 0xff} + got := color.RGBA{R: pix[0], G: pix[1], B: pix[2], A: pix[3]} + want := color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff} if !sameColors(got, want, 1) { t.Errorf("got: %v, want: %v", got, want) } @@ -606,8 +606,8 @@ func TestDispose(t *testing.T) { if err := img0.ReadPixels(ui.GraphicsDriverForTesting(), pix[:], 0, 0, 1, 1); err != nil { t.Fatal(err) } - got := color.RGBA{pix[0], pix[1], pix[2], pix[3]} - want := color.RGBA{0xff, 0xff, 0xff, 0xff} + got := color.RGBA{R: pix[0], G: pix[1], B: pix[2], A: pix[3]} + want := color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff} if !sameColors(got, want, 1) { t.Errorf("got: %v, want: %v", got, want) } @@ -631,52 +631,52 @@ func TestWritePixelsPart(t *testing.T) { { i: 0, j: 0, - want: color.RGBA{0, 0, 0, 0}, + want: color.RGBA{}, }, { i: 3, j: 0, - want: color.RGBA{0, 0, 0, 0}, + want: color.RGBA{}, }, { i: 0, j: 1, - want: color.RGBA{0, 0, 0, 0}, + want: color.RGBA{}, }, { i: 1, j: 1, - want: color.RGBA{0xff, 0xff, 0xff, 0xff}, + want: color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}, }, { i: 3, j: 1, - want: color.RGBA{0, 0, 0, 0}, + want: color.RGBA{}, }, { i: 0, j: 2, - want: color.RGBA{0, 0, 0, 0}, + want: color.RGBA{}, }, { i: 2, j: 2, - want: color.RGBA{0xff, 0xff, 0xff, 0xff}, + want: color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}, }, { i: 3, j: 2, - want: color.RGBA{0, 0, 0, 0}, + want: color.RGBA{}, }, { i: 0, j: 3, - want: color.RGBA{0, 0, 0, 0}, + want: color.RGBA{}, }, { i: 3, j: 3, - want: color.RGBA{0, 0, 0, 0}, + want: color.RGBA{}, }, } for _, c := range cases { @@ -717,9 +717,9 @@ func TestWritePixelsOnly(t *testing.T) { var want color.RGBA switch { case idx == 0: - want = color.RGBA{5, 6, 7, 8} + want = color.RGBA{R: 5, G: 6, B: 7, A: 8} case idx%5 == 0: - want = color.RGBA{1, 2, 3, 4} + want = color.RGBA{R: 1, G: 2, B: 3, A: 4} } got := pixelsToColor(img0.BasePixelsForTesting(), i, j, w, h) if !sameColors(got, want, 0) { @@ -734,7 +734,7 @@ func TestWritePixelsOnly(t *testing.T) { if err := restorable.RestoreIfNeeded(ui.GraphicsDriverForTesting()); err != nil { t.Fatal(err) } - want := color.RGBA{1, 2, 3, 4} + want := color.RGBA{R: 1, G: 2, B: 3, A: 4} got := pixelsToColor(img1.BasePixelsForTesting(), 0, 0, w, h) if !sameColors(got, want, 0) { t.Errorf("got %v, want %v", got, want) @@ -836,10 +836,10 @@ func TestAllowWritePixelsForPartAfterDrawTriangles(t *testing.T) { } for j := 0; j < h; j++ { for i := 0; i < w; i++ { - got := color.RGBA{result[4*(j*w+i)], result[4*(j*w+i)+1], result[4*(j*w+i)+2], result[4*(j*w+i)+3]} + got := color.RGBA{R: result[4*(j*w+i)], G: result[4*(j*w+i)+1], B: result[4*(j*w+i)+2], A: result[4*(j*w+i)+3]} var want color.RGBA if i >= 2 || j >= 2 { - want = color.RGBA{0xff, 0xff, 0xff, 0xff} + want = color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff} } if got != want { t.Errorf("color at (%d, %d): got: %v, want: %v", i, j, got, want) @@ -948,8 +948,8 @@ func TestMutateSlices(t *testing.T) { for j := 0; j < h; j++ { for i := 0; i < w; i++ { idx := 4 * (j*w + i) - want := color.RGBA{srcPix[idx], srcPix[idx+1], srcPix[idx+2], srcPix[idx+3]} - got := color.RGBA{dstPix[idx], dstPix[idx+1], dstPix[idx+2], dstPix[idx+3]} + want := color.RGBA{R: srcPix[idx], G: srcPix[idx+1], B: srcPix[idx+2], A: srcPix[idx+3]} + got := color.RGBA{R: dstPix[idx], G: dstPix[idx+1], B: dstPix[idx+2], A: dstPix[idx+3]} if !sameColors(got, want, 1) { t.Errorf("(%d, %d): got %v, want %v", i, j, got, want) } @@ -1005,7 +1005,7 @@ func TestOverlappedPixels(t *testing.T) { for j := 0; j < 3; j++ { for i := 0; i < 3; i++ { idx := 4 * (j*3 + i) - got := color.RGBA{result[idx], result[idx+1], result[idx+2], result[idx+3]} + got := color.RGBA{R: result[idx], G: result[idx+1], B: result[idx+2], A: result[idx+3]} want := wantColors[3*j+i] if got != want { t.Errorf("color at (%d, %d): got %v, want: %v", i, j, got, want) @@ -1034,7 +1034,7 @@ func TestOverlappedPixels(t *testing.T) { for j := 0; j < 3; j++ { for i := 0; i < 3; i++ { idx := 4 * (j*3 + i) - got := color.RGBA{result[idx], result[idx+1], result[idx+2], result[idx+3]} + got := color.RGBA{R: result[idx], G: result[idx+1], B: result[idx+2], A: result[idx+3]} want := wantColors[3*j+i] if got != want { t.Errorf("color at (%d, %d): got %v, want: %v", i, j, got, want) @@ -1073,7 +1073,7 @@ func TestOverlappedPixels(t *testing.T) { for j := 0; j < 3; j++ { for i := 0; i < 3; i++ { idx := 4 * (j*3 + i) - got := color.RGBA{result[idx], result[idx+1], result[idx+2], result[idx+3]} + got := color.RGBA{R: result[idx], G: result[idx+1], B: result[idx+2], A: result[idx+3]} want := wantColors[3*j+i] if got != want { t.Errorf("color at (%d, %d): got %v, want: %v", i, j, got, want) @@ -1094,7 +1094,7 @@ func TestOverlappedPixels(t *testing.T) { for j := 0; j < 3; j++ { for i := 0; i < 3; i++ { idx := 4 * (j*3 + i) - got := color.RGBA{result[idx], result[idx+1], result[idx+2], result[idx+3]} + got := color.RGBA{R: result[idx], G: result[idx+1], B: result[idx+2], A: result[idx+3]} want := wantColors[3*j+i] if got != want { t.Errorf("color at (%d, %d): got %v, want: %v", i, j, got, want) @@ -1125,7 +1125,7 @@ func TestDrawTrianglesAndReadPixels(t *testing.T) { if err := dst.ReadPixels(ui.GraphicsDriverForTesting(), pix, 0, 0, w, h); err != nil { t.Fatal(err) } - if got, want := (color.RGBA{pix[0], pix[1], pix[2], pix[3]}), (color.RGBA{0x80, 0x80, 0x80, 0x80}); !sameColors(got, want, 1) { + if got, want := (color.RGBA{R: pix[0], G: pix[1], B: pix[2], A: pix[3]}), (color.RGBA{R: 0x80, G: 0x80, B: 0x80, A: 0x80}); !sameColors(got, want, 1) { t.Errorf("got: %v, want: %v", got, want) } } diff --git a/internal/restorable/shader_test.go b/internal/restorable/shader_test.go index 82666db20..7b423e8c7 100644 --- a/internal/restorable/shader_test.go +++ b/internal/restorable/shader_test.go @@ -73,7 +73,7 @@ func TestShader(t *testing.T) { t.Fatal(err) } - want := color.RGBA{0xff, 0, 0, 0xff} + want := color.RGBA{R: 0xff, A: 0xff} got := pixelsToColor(img.BasePixelsForTesting(), 0, 0, 1, 1) if !sameColors(got, want, 1) { t.Errorf("got %v, want %v", got, want) @@ -110,7 +110,7 @@ func TestShaderChain(t *testing.T) { } for i, img := range imgs { - want := color.RGBA{0xff, 0, 0, 0xff} + want := color.RGBA{R: 0xff, A: 0xff} got := pixelsToColor(img.BasePixelsForTesting(), 0, 0, 1, 1) if !sameColors(got, want, 1) { t.Errorf("%d: got %v, want %v", i, got, want) @@ -149,7 +149,7 @@ func TestShaderMultipleSources(t *testing.T) { t.Fatal(err) } - want := color.RGBA{0x40, 0x80, 0xc0, 0xff} + want := color.RGBA{R: 0x40, G: 0x80, B: 0xc0, A: 0xff} got := pixelsToColor(dst.BasePixelsForTesting(), 0, 0, 1, 1) if !sameColors(got, want, 1) { t.Errorf("got %v, want %v", got, want) @@ -190,7 +190,7 @@ func TestShaderMultipleSourcesOnOneTexture(t *testing.T) { t.Fatal(err) } - want := color.RGBA{0x40, 0x80, 0xc0, 0xff} + want := color.RGBA{R: 0x40, G: 0x80, B: 0xc0, A: 0xff} got := pixelsToColor(dst.BasePixelsForTesting(), 0, 0, 1, 1) if !sameColors(got, want, 1) { t.Errorf("got %v, want %v", got, want) @@ -210,7 +210,7 @@ func TestShaderDispose(t *testing.T) { } img.DrawTriangles([graphics.ShaderImageCount]*restorable.Image{}, [graphics.ShaderImageCount - 1][2]float32{}, quadVertices(nil, 1, 1, 0, 0), graphics.QuadIndices(), graphicsdriver.BlendCopy, dr, graphicsdriver.Region{}, s, nil, false) - // Dispose the shader. This should invalidates all the images using this shader i.e., all the images become + // Dispose the shader. This should invalidate all the images using this shader i.e., all the images become // stale. s.Dispose() @@ -221,7 +221,7 @@ func TestShaderDispose(t *testing.T) { t.Fatal(err) } - want := color.RGBA{0xff, 0, 0, 0xff} + want := color.RGBA{R: 0xff, A: 0xff} got := pixelsToColor(img.BasePixelsForTesting(), 0, 0, 1, 1) if !sameColors(got, want, 1) { t.Errorf("got %v, want %v", got, want) diff --git a/internal/shader/syntax_test.go b/internal/shader/syntax_test.go index eab4aec62..5c085bbf3 100644 --- a/internal/shader/syntax_test.go +++ b/internal/shader/syntax_test.go @@ -308,7 +308,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { } } -func TestSyntaxUnspportedSyntax(t *testing.T) { +func TestSyntaxUnsupportedSyntax(t *testing.T) { if _, err := compileToIR([]byte(`package main func Fragment(position vec4, texCoord vec2, color vec4) vec4 { diff --git a/internal/shaderir/program.go b/internal/shaderir/program.go index 38074552b..bad3b7a66 100644 --- a/internal/shaderir/program.go +++ b/internal/shaderir/program.go @@ -46,7 +46,7 @@ type Func struct { // VertexFunc takes pseudo params, and the number if len(attributes) + len(varyings) + 1. // If 0 <= index < len(attributes), the params are in-params and represent attribute variables. -// If index == len(attributes), the param is an out-param and repesents the position in vec4 (gl_Position in GLSL) +// If index == len(attributes), the param is an out-param and represents the position in vec4 (gl_Position in GLSL) // If len(attributes) + 1 <= index < len(attributes) + len(varyings) + 1, the params are out-params and represent // varying variables. type VertexFunc struct { @@ -55,7 +55,7 @@ type VertexFunc struct { // FragmentFunc takes pseudo params, and the number is len(varyings) + 2. // If index == 0, the param represents the coordinate of the fragment (gl_FragCoord in GLSL). -// If 0 < index <= len(varyings), the param represents (index-1)th verying variable. +// If 0 < index <= len(varyings), the param represents (index-1)th varying variable. type FragmentFunc struct { Block *Block } diff --git a/internal/ui/egl_nintendosdk.go b/internal/ui/egl_nintendosdk.go index 6e734baf5..47e6e96b1 100644 --- a/internal/ui/egl_nintendosdk.go +++ b/internal/ui/egl_nintendosdk.go @@ -70,7 +70,7 @@ func (e *egl) init(nativeWindowHandle C.NativeWindowType) error { // Create new context and set it as current. contextAttribs := []C.EGLint{ - // Set target garaphics api version. + // Set target graphics api version. C.EGL_CONTEXT_MAJOR_VERSION, 2, C.EGL_CONTEXT_MINOR_VERSION, 1, // For debug callback diff --git a/internal/ui/ui_glfw_darwin.go b/internal/ui/ui_glfw_darwin.go index e255912a1..6b254343b 100644 --- a/internal/ui/ui_glfw_darwin.go +++ b/internal/ui/ui_glfw_darwin.go @@ -33,13 +33,13 @@ var ( class_EbitengineWindowDelegate objc.Class ) -type windowDelgate struct { +type windowDelegate struct { isa objc.Class `objc:"EbitengineWindowDelegate : NSObject "` origDelegate objc.ID origResizable bool } -func (w *windowDelgate) pushResizableState(win objc.ID) { +func (w *windowDelegate) pushResizableState(win objc.ID) { window := cocoa.NSWindow{ID: win} w.origResizable = window.StyleMask()&cocoa.NSWindowStyleMaskResizable != 0 if !w.origResizable { @@ -47,7 +47,7 @@ func (w *windowDelgate) pushResizableState(win objc.ID) { } } -func (w *windowDelgate) popResizableState(win objc.ID) { +func (w *windowDelegate) popResizableState(win objc.ID) { if !w.origResizable { window := cocoa.NSWindow{ID: win} window.SetStyleMask(window.StyleMask() & ^uint(cocoa.NSWindowStyleMaskResizable)) @@ -55,10 +55,10 @@ func (w *windowDelgate) popResizableState(win objc.ID) { w.origResizable = false } -func (w *windowDelgate) InitWithOrigDelegate(cmd objc.SEL, origDelegate objc.ID) objc.ID { +func (w *windowDelegate) InitWithOrigDelegate(cmd objc.SEL, origDelegate objc.ID) objc.ID { self := objc.ID(unsafe.Pointer(w)).SendSuper(sel_init) if self != 0 { - w = *(**windowDelgate)(unsafe.Pointer(&self)) + w = *(**windowDelegate)(unsafe.Pointer(&self)) w.origDelegate = origDelegate } return self @@ -67,56 +67,56 @@ func (w *windowDelgate) InitWithOrigDelegate(cmd objc.SEL, origDelegate objc.ID) // The method set of origDelegate_ must sync with GLFWWindowDelegate's implementation. // See cocoa_window.m in GLFW. -func (w *windowDelgate) WindowShouldClose(cmd objc.SEL, notification objc.ID) bool { +func (w *windowDelegate) WindowShouldClose(cmd objc.SEL, notification objc.ID) bool { return w.origDelegate.Send(cmd, notification) != 0 } -func (w *windowDelgate) WindowDidResize(cmd objc.SEL, notification objc.ID) { +func (w *windowDelegate) WindowDidResize(cmd objc.SEL, notification objc.ID) { w.origDelegate.Send(cmd, notification) } -func (w *windowDelgate) WindowDidMove(cmd objc.SEL, notification objc.ID) { +func (w *windowDelegate) WindowDidMove(cmd objc.SEL, notification objc.ID) { w.origDelegate.Send(cmd, notification) } -func (w *windowDelgate) WindowDidMiniaturize(cmd objc.SEL, notification objc.ID) { +func (w *windowDelegate) WindowDidMiniaturize(cmd objc.SEL, notification objc.ID) { w.origDelegate.Send(cmd, notification) } -func (w *windowDelgate) WindowDidDeminiaturize(cmd objc.SEL, notification objc.ID) { +func (w *windowDelegate) WindowDidDeminiaturize(cmd objc.SEL, notification objc.ID) { w.origDelegate.Send(cmd, notification) } -func (w *windowDelgate) WindowDidBecomeKey(cmd objc.SEL, notification objc.ID) { +func (w *windowDelegate) WindowDidBecomeKey(cmd objc.SEL, notification objc.ID) { w.origDelegate.Send(cmd, notification) } -func (w *windowDelgate) WindowDidResignKey(cmd objc.SEL, notification objc.ID) { +func (w *windowDelegate) WindowDidResignKey(cmd objc.SEL, notification objc.ID) { w.origDelegate.Send(cmd, notification) } -func (w *windowDelgate) WindowDidChangeOcclusionState(cmd objc.SEL, notification objc.ID) { +func (w *windowDelegate) WindowDidChangeOcclusionState(cmd objc.SEL, notification objc.ID) { w.origDelegate.Send(cmd, notification) } -func (w *windowDelgate) WindowWillEnterFullScreen(cmd objc.SEL, notification objc.ID) { +func (w *windowDelegate) WindowWillEnterFullScreen(cmd objc.SEL, notification objc.ID) { w.pushResizableState(cocoa.NSNotification{ID: notification}.Object()) } -func (w *windowDelgate) WindowDidEnterFullScreen(cmd objc.SEL, notification objc.ID) { +func (w *windowDelegate) WindowDidEnterFullScreen(cmd objc.SEL, notification objc.ID) { w.popResizableState(cocoa.NSNotification{ID: notification}.Object()) } -func (w *windowDelgate) WindowWillExitFullScreen(cmd objc.SEL, notification objc.ID) { +func (w *windowDelegate) WindowWillExitFullScreen(cmd objc.SEL, notification objc.ID) { w.pushResizableState(cocoa.NSNotification{ID: notification}.Object()) } -func (w *windowDelgate) WindowDidExitFullScreen(cmd objc.SEL, notification objc.ID) { +func (w *windowDelegate) WindowDidExitFullScreen(cmd objc.SEL, notification objc.ID) { w.popResizableState(cocoa.NSNotification{ID: notification}.Object()) // Do not call setFrame here (#2295). setFrame here causes unexpected results. } -func (w *windowDelgate) Selector(cmd string) objc.SEL { +func (w *windowDelegate) Selector(cmd string) objc.SEL { switch cmd { case "InitWithOrigDelegate": return sel_initWithOrigDelegate @@ -151,7 +151,7 @@ func (w *windowDelgate) Selector(cmd string) objc.SEL { func init() { var err error - class_EbitengineWindowDelegate, err = objc.RegisterClass(&windowDelgate{}) + class_EbitengineWindowDelegate, err = objc.RegisterClass(&windowDelegate{}) if err != nil { panic(err) } @@ -278,7 +278,7 @@ func monitorFromWindowByOS(w *glfw.Window) *glfw.Monitor { window := cocoa.NSWindow{ID: objc.ID(w.GetCocoaWindow())} pool := cocoa.NSAutoreleasePool_new() screen := cocoa.NSScreen_mainScreen() - if window.ID != 0 && window.IsVisibile() { + if window.ID != 0 && window.IsVisible() { // When the window is visible, the window is already initialized. // [NSScreen mainScreen] sometimes tells a lie when the window is put across monitors (#703). screen = window.Screen() diff --git a/internal/ui/ui_glfw_unix.go b/internal/ui/ui_glfw_unix.go index 0060c958d..64d0bad3a 100644 --- a/internal/ui/ui_glfw_unix.go +++ b/internal/ui/ui_glfw_unix.go @@ -90,7 +90,7 @@ func videoModeScaleUncached(m *glfw.Monitor) float64 { // Note: GLFW currently returns physical pixel sizes, // but we need to predict the window system-side size of the fullscreen window // for Ebiten's `ScreenSizeInFullscreen` public API. - // Also at the moment we need this prior to switching to fullscreen, but that might be replacable. + // Also at the moment we need this prior to switching to fullscreen, but that might be replaceable. // So this function computes the ratio of physical per logical pixels. xconn, err := xgb.NewConn() if err != nil { diff --git a/internal/ui/ui_glfw_windows.go b/internal/ui/ui_glfw_windows.go index 6cb8ba846..496f241a7 100644 --- a/internal/ui/ui_glfw_windows.go +++ b/internal/ui/ui_glfw_windows.go @@ -135,7 +135,7 @@ func monitorFromWindowByOS(w *glfw.Window) *glfw.Monitor { func monitorFromWin32Window(w windows.HWND) *glfw.Monitor { // Get the current monitor by the window handle instead of the window position. It is because the window - // position is not relaiable in some cases e.g. when the window is put across multiple monitors. + // position is not reliable in some cases e.g. when the window is put across multiple monitors. m := _MonitorFromWindow(w, _MONITOR_DEFAULTTONEAREST) if m == 0 { diff --git a/run.go b/run.go index 658ef1c41..98bf929fd 100644 --- a/run.go +++ b/run.go @@ -120,7 +120,7 @@ type FinalScreenDrawer interface { // // geoM is the default geometry matrix to render the offscreen onto the final screen. // geoM scales the offscreen to fit the final screen without changing the aspect ratio, and - // translates the offscreen to put it on the center of the final screen. + // translates the offscreen to put it in the center of the final screen. DrawFinalScreen(screen FinalScreen, offscreen *Image, geoM GeoM) } @@ -201,7 +201,7 @@ var Termination = ui.RegularTermination // // If game implements FinalScreenDrawer, its DrawFinalScreen is called after Draw. // The argument screen represents the final screen. The argument offscreen is an offscreen modified at Draw. -// If game does not implement FinalScreenDrawer, the dafault rendering for the final screen is used. +// If game does not implement FinalScreenDrawer, the default rendering for the final screen is used. // // game's functions are called on the same goroutine. // @@ -229,7 +229,7 @@ func RunGame(game Game) error { return RunGameWithOptions(game, nil) } -// RungameOptions represents options for RunGameWithOptions. +// RunGameOptions represents options for RunGameWithOptions. type RunGameOptions struct { // GraphicsLibrary is a graphics library Ebitengine will use. // @@ -264,7 +264,7 @@ type RunGameOptions struct { // // If game implements FinalScreenDrawer, its DrawFinalScreen is called after Draw. // The argument screen represents the final screen. The argument offscreen is an offscreen modified at Draw. -// If game does not implement FinalScreenDrawer, the dafault rendering for the final screen is used. +// If game does not implement FinalScreenDrawer, the default rendering for the final screen is used. // // game's functions are called on the same goroutine. // @@ -638,7 +638,7 @@ var screenTransparent int32 = 0 // // SetInitFocused panics if this is called after the main loop. // -// SetInitFocused is cuncurrent-safe. +// SetInitFocused is concurrent-safe. // // Deprecated: as of v2.5. Use RunGameWithOptions instead. func SetInitFocused(focused bool) { diff --git a/shader.go b/shader.go index a2af7443d..358572f2f 100644 --- a/shader.go +++ b/shader.go @@ -30,7 +30,7 @@ type Shader struct { shader *ui.Shader } -// NewShader compiles a shader program in the shading language Kage, and retruns the result. +// NewShader compiles a shader program in the shading language Kage, and returns the result. // // If the compilation fails, NewShader returns an error. // diff --git a/shader_test.go b/shader_test.go index f847f7a6d..e1d63ff86 100644 --- a/shader_test.go +++ b/shader_test.go @@ -45,7 +45,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { got := dst.At(i, j).(color.RGBA) var want color.RGBA if i < w/2 && j < h/2 { - want = color.RGBA{0xff, 0, 0, 0xff} + want = color.RGBA{R: 0xff, A: 0xff} } if got != want { t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want) @@ -78,7 +78,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { got := dst.At(i, j).(color.RGBA) var want color.RGBA if i < w/2 && j < h/2 { - want = color.RGBA{0xff, 0, 0, 0xff} + want = color.RGBA{R: 0xff, A: 0xff} } if got != want { t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want) @@ -104,9 +104,9 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { } src0 := ebiten.NewImageWithOptions(rect, &ebiten.NewImageOptions{Unmanaged: true}) - src0.Fill(color.RGBA{25, 0xff, 25, 0xff}) + src0.Fill(color.RGBA{R: 25, G: 0xff, B: 25, A: 0xff}) src1 := ebiten.NewImageWithOptions(rect, &ebiten.NewImageOptions{Unmanaged: true}) - src1.Fill(color.RGBA{0xff, 0, 0, 0xff}) + src1.Fill(color.RGBA{R: 0xff, A: 0xff}) op := &ebiten.DrawRectShaderOptions{} op.CompositeMode = ebiten.CompositeModeCopy op.Images[0] = src0 @@ -132,7 +132,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { for j := 0; j < h; j++ { for i := 0; i < w; i++ { got := dst.At(i, j).(color.RGBA) - want := color.RGBA{0xff, 0, 0, 0xff} + want := color.RGBA{R: 0xff, A: 0xff} if got != want { t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want) } @@ -149,7 +149,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { for j := 0; j < h; j++ { for i := 0; i < w; i++ { got := dst.At(i, j).(color.RGBA) - want := color.RGBA{25, 0xff, 25, 0xff} + want := color.RGBA{R: 25, G: 0xff, B: 25, A: 0xff} if got != want { t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want) } @@ -224,7 +224,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { for j := 0; j < h; j++ { for i := 0; i < w; i++ { got := dst.At(i, j).(color.RGBA) - want := color.RGBA{0xff, 0, 0, 0xff} + want := color.RGBA{R: 0xff, A: 0xff} if got != want { t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want) } @@ -255,7 +255,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { for j := 0; j < h; j++ { for i := 0; i < w; i++ { got := dst.At(i, j).(color.RGBA) - want := color.RGBA{0xff, 0, 0, 0xff} + want := color.RGBA{R: 0xff, A: 0xff} if got != want { t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want) } @@ -323,7 +323,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { for j := 0; j < h; j++ { for i := 0; i < w; i++ { got := dst.At(i, j).(color.RGBA) - want := color.RGBA{87, 82, 71, 255} + want := color.RGBA{R: 87, G: 82, B: 71, A: 255} if got != want { t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want) } @@ -382,7 +382,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { got := dst.At(i, j).(color.RGBA) var want color.RGBA if i < w/2 && j < h/2 { - want = color.RGBA{0xff, 0xff, 0, 0xff} + want = color.RGBA{R: 0xff, G: 0xff, A: 0xff} } if got != want { t.Errorf("%s dst.At(%d, %d): got: %v, want: %v", testname, i, j, got, want) @@ -493,7 +493,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { for j := 1; j < h-1; j++ { for i := 1; i < w-1; i++ { got := dst.At(i, j).(color.RGBA) - want := color.RGBA{0, 0, 0, 0xff} + want := color.RGBA{A: 0xff} if i == w/2-1 || i == w/2 { want.R = 0xff } @@ -551,7 +551,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { for j := 1; j < h-1; j++ { for i := 1; i < w-1; i++ { got := dst.At(i, j).(color.RGBA) - want := color.RGBA{0, 0, 0, 0xff} + want := color.RGBA{A: 0xff} if i == w/2-1 || i == w/2 { want.R = 0xff } @@ -630,7 +630,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { op := &ebiten.DrawRectShaderOptions{} op.Uniforms = shader.Uniforms dst.DrawRectShader(w, h, s, op) - if got, want := dst.At(0, 0), (color.RGBA{0xff, 0xff, 0xff, 0xff}); got != want { + if got, want := dst.At(0, 0), (color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}); got != want { t.Errorf("got: %v, want: %v", got, want) } }) @@ -660,7 +660,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { got := dst.At(i, j).(color.RGBA) var want color.RGBA if i < w/2 && j < h/2 { - want = color.RGBA{0xc0, 0, 0, 0xff} + want = color.RGBA{R: 0xc0, A: 0xff} } if !sameColors(got, want, 2) { t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want) @@ -673,7 +673,7 @@ func TestShaderMatrixInitialize(t *testing.T) { const w, h = 16, 16 src := ebiten.NewImage(w, h) - src.Fill(color.RGBA{0x10, 0x20, 0x30, 0xff}) + src.Fill(color.RGBA{R: 0x10, G: 0x20, B: 0x30, A: 0xff}) dst := ebiten.NewImage(w, h) s, err := ebiten.NewShader([]byte(`package main @@ -693,7 +693,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { for j := 0; j < h; j++ { for i := 0; i < w; i++ { got := dst.At(i, j).(color.RGBA) - want := color.RGBA{0x20, 0x40, 0x60, 0xff} + want := color.RGBA{R: 0x20, G: 0x40, B: 0x60, A: 0xff} if !sameColors(got, want, 2) { t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want) } @@ -722,7 +722,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { for j := 0; j < h; j++ { for i := 0; i < w; i++ { got := dst.At(i, j).(color.RGBA) - want := color.RGBA{0x40, 0, 0x40, 0xff} + want := color.RGBA{R: 0x40, B: 0x40, A: 0xff} if !sameColors(got, want, 2) { t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want) } @@ -734,7 +734,7 @@ func TestShaderTextureAt(t *testing.T) { const w, h = 16, 16 src := ebiten.NewImage(w, h) - src.Fill(color.RGBA{0x10, 0x20, 0x30, 0xff}) + src.Fill(color.RGBA{R: 0x10, G: 0x20, B: 0x30, A: 0xff}) dst := ebiten.NewImage(w, h) s, err := ebiten.NewShader([]byte(`package main @@ -758,7 +758,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { for j := 0; j < h; j++ { for i := 0; i < w; i++ { got := dst.At(i, j).(color.RGBA) - want := color.RGBA{0x10, 0x20, 0x30, 0xff} + want := color.RGBA{R: 0x10, G: 0x20, B: 0x30, A: 0xff} if !sameColors(got, want, 2) { t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want) } @@ -770,7 +770,7 @@ func TestShaderAtan2(t *testing.T) { const w, h = 16, 16 src := ebiten.NewImage(w, h) - src.Fill(color.RGBA{0x10, 0x20, 0x30, 0xff}) + src.Fill(color.RGBA{R: 0x10, G: 0x20, B: 0x30, A: 0xff}) dst := ebiten.NewImage(w, h) s, err := ebiten.NewShader([]byte(`package main @@ -793,7 +793,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { for i := 0; i < w; i++ { got := dst.At(i, j).(color.RGBA) v := byte(math.Floor(0xff * math.Pi / 4)) - want := color.RGBA{v, v, v, v} + want := color.RGBA{R: v, G: v, B: v, A: v} if !sameColors(got, want, 2) { t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want) } @@ -831,7 +831,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { for j := 0; j < h; j++ { for i := 0; i < w; i++ { got := dst.At(i, j).(color.RGBA) - want := color.RGBA{8, 12, 0xff, 0xff} + want := color.RGBA{R: 8, G: 12, B: 0xff, A: 0xff} if !sameColors(got, want, 2) { t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want) } @@ -871,7 +871,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { for j := 0; j < h; j++ { for i := 0; i < w; i++ { got := dst.At(i, j).(color.RGBA) - want := color.RGBA{54, 80, 0xff, 0xff} + want := color.RGBA{R: 54, G: 80, B: 0xff, A: 0xff} if !sameColors(got, want, 2) { t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want) } @@ -910,7 +910,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { for j := 0; j < h; j++ { for i := 0; i < w; i++ { got := dst.At(i, j).(color.RGBA) - want := color.RGBA{24, 30, 36, 0xff} + want := color.RGBA{R: 24, G: 30, B: 36, A: 0xff} if !sameColors(got, want, 2) { t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want) } @@ -952,7 +952,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { for j := 0; j < h; j++ { for i := 0; i < w; i++ { got := dst.At(i, j).(color.RGBA) - want := color.RGBA{6, 8, 9, 0xff} + want := color.RGBA{R: 6, G: 8, B: 9, A: 0xff} if !sameColors(got, want, 2) { t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want) } @@ -992,7 +992,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { for j := 0; j < h; j++ { for i := 0; i < w; i++ { got := dst.At(i, j).(color.RGBA) - want := color.RGBA{112, 128, 143, 159} + want := color.RGBA{R: 112, G: 128, B: 143, A: 159} if !sameColors(got, want, 2) { t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want) } @@ -1036,7 +1036,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { for j := 0; j < h; j++ { for i := 0; i < w; i++ { got := dst.At(i, j).(color.RGBA) - want := color.RGBA{44, 50, 56, 62} + want := color.RGBA{R: 44, G: 50, B: 56, A: 62} if !sameColors(got, want, 2) { t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want) } @@ -1098,7 +1098,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { got := dst.At(i, j).(color.RGBA) var want color.RGBA if 0 <= i && i < w/2 && 0 <= j && j < h/2 { - want = color.RGBA{0xff, 0xff, 0, 0xff} + want = color.RGBA{R: 0xff, G: 0xff, A: 0xff} } if got != want { t.Errorf("%s dst.At(%d, %d): got: %v, want: %v", testname, i, j, got, want) @@ -1196,7 +1196,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { for j := 0; j < h; j++ { for i := 0; i < w; i++ { got := dst.At(i, j).(color.RGBA) - want := color.RGBA{0xff, 0, 0x00, 0xff} + want := color.RGBA{R: 0xff, A: 0xff} if !sameColors(got, want, 2) { t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want) } @@ -1209,7 +1209,7 @@ func TestShaderDiscard(t *testing.T) { const w, h = 16, 16 dst := ebiten.NewImage(w, h) - dst.Fill(color.RGBA{0xff, 0, 0, 0xff}) + dst.Fill(color.RGBA{R: 0xff, A: 0xff}) src := ebiten.NewImage(w, h) pix := make([]byte, 4*w*h) @@ -1245,9 +1245,9 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { for j := 0; j < h; j++ { for i := 0; i < w; i++ { got := dst.At(i, j).(color.RGBA) - want := color.RGBA{0, 0xff, 0x00, 0xff} + want := color.RGBA{G: 0xff, A: 0xff} if i >= w/2 || j >= h/2 { - want = color.RGBA{0xff, 0, 0x00, 0xff} + want = color.RGBA{R: 0xff, A: 0xff} } if !sameColors(got, want, 2) { t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want) @@ -1299,9 +1299,9 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { var want color.RGBA if offsetX <= i && i < offsetX+srcW && offsetY <= j && j < offsetY+srcH { if offsetX+srcW/2 <= i && offsetY+srcH/2 <= j { - want = color.RGBA{0xff, 0, 0, 0xff} + want = color.RGBA{R: 0xff, A: 0xff} } else { - want = color.RGBA{0, 0xff, 0, 0xff} + want = color.RGBA{G: 0xff, A: 0xff} } } if got != want { @@ -1330,13 +1330,13 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { op.ColorScale.SetG(5.0 / 8.0) op.ColorScale.SetB(6.0 / 8.0) op.ColorScale.SetA(7.0 / 8.0) - op.ColorScale.ScaleWithColor(color.RGBA{0x40, 0x80, 0xc0, 0xff}) + op.ColorScale.ScaleWithColor(color.RGBA{R: 0x40, G: 0x80, B: 0xc0, A: 0xff}) dst.DrawRectShader(w, h, s, op) for j := 0; j < h; j++ { for i := 0; i < w; i++ { got := dst.At(i, j).(color.RGBA) - want := color.RGBA{0x20, 0x50, 0x90, 0xe0} + want := color.RGBA{R: 0x20, G: 0x50, B: 0x90, A: 0xe0} if !sameColors(got, want, 1) { t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want) } @@ -1391,7 +1391,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { "U3": 0xff, }, Shader: ints, - Want: color.RGBA{0xff, 0xff, 0xff, 0xff}, + Want: color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}, }, { Name: "int", @@ -1402,7 +1402,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { "U3": int64(0x88), }, Shader: ints, - Want: color.RGBA{0x24, 0x3f, 0x6a, 0x88}, + Want: color.RGBA{R: 0x24, G: 0x3f, B: 0x6a, A: 0x88}, }, { Name: "uint", @@ -1413,7 +1413,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { "U3": uint64(0xd3), }, Shader: ints, - Want: color.RGBA{0x85, 0xa3, 0x08, 0xd3}, + Want: color.RGBA{R: 0x85, G: 0xa3, B: 0x08, A: 0xd3}, }, { Name: "0xff,slice", @@ -1421,7 +1421,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { "U": []int{0xff, 0xff, 0xff, 0xff}, }, Shader: intArray, - Want: color.RGBA{0xff, 0xff, 0xff, 0xff}, + Want: color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}, }, { Name: "int,slice", @@ -1429,7 +1429,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { "U": []int16{0x24, 0x3f, 0x6a, 0x88}, }, Shader: intArray, - Want: color.RGBA{0x24, 0x3f, 0x6a, 0x88}, + Want: color.RGBA{R: 0x24, G: 0x3f, B: 0x6a, A: 0x88}, }, { Name: "uint,slice", @@ -1437,7 +1437,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { "U": []uint8{0x85, 0xa3, 0x08, 0xd3}, }, Shader: intArray, - Want: color.RGBA{0x85, 0xa3, 0x08, 0xd3}, + Want: color.RGBA{R: 0x85, G: 0xa3, B: 0x08, A: 0xd3}, }, { Name: "0xff,array", @@ -1445,7 +1445,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { "U": [...]int{0xff, 0xff, 0xff, 0xff}, }, Shader: intArray, - Want: color.RGBA{0xff, 0xff, 0xff, 0xff}, + Want: color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}, }, { Name: "int,array", @@ -1453,7 +1453,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { "U": [...]int16{0x24, 0x3f, 0x6a, 0x88}, }, Shader: intArray, - Want: color.RGBA{0x24, 0x3f, 0x6a, 0x88}, + Want: color.RGBA{R: 0x24, G: 0x3f, B: 0x6a, A: 0x88}, }, { Name: "uint,array", @@ -1461,7 +1461,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { "U": [...]uint8{0x85, 0xa3, 0x08, 0xd3}, }, Shader: intArray, - Want: color.RGBA{0x85, 0xa3, 0x08, 0xd3}, + Want: color.RGBA{R: 0x85, G: 0xa3, B: 0x08, A: 0xd3}, }, { Name: "0xff,array", @@ -1469,7 +1469,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { "U": [...]int{0xff, 0xff, 0xff, 0xff}, }, Shader: intArray, - Want: color.RGBA{0xff, 0xff, 0xff, 0xff}, + Want: color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}, }, { Name: "int,array", @@ -1477,7 +1477,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { "U": [...]int16{0x24, 0x3f, 0x6a, 0x88}, }, Shader: intArray, - Want: color.RGBA{0x24, 0x3f, 0x6a, 0x88}, + Want: color.RGBA{R: 0x24, G: 0x3f, B: 0x6a, A: 0x88}, }, { Name: "uint,array", @@ -1485,7 +1485,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { "U": [...]uint8{0x85, 0xa3, 0x08, 0xd3}, }, Shader: intArray, - Want: color.RGBA{0x85, 0xa3, 0x08, 0xd3}, + Want: color.RGBA{R: 0x85, G: 0xa3, B: 0x08, A: 0xd3}, }, { Name: "0xff,ivec", @@ -1494,7 +1494,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { "U1": [...]int{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, }, Shader: intVec, - Want: color.RGBA{0xff, 0xff, 0xff, 0xff}, + Want: color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}, }, { Name: "int,ivec", @@ -1503,7 +1503,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { "U1": [...]int16{0x85, 0xa3, 0x08, 0xd3, 0x13, 0x19}, }, Shader: intVec, - Want: color.RGBA{0x24, 0x3f, 0x08, 0xd3}, + Want: color.RGBA{R: 0x24, G: 0x3f, B: 0x08, A: 0xd3}, }, { Name: "uint,ivec", @@ -1512,7 +1512,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { "U1": [...]uint8{0x85, 0xa3, 0x08, 0xd3, 0x13, 0x19}, }, Shader: intVec, - Want: color.RGBA{0x24, 0x3f, 0x08, 0xd3}, + Want: color.RGBA{R: 0x24, G: 0x3f, B: 0x08, A: 0xd3}, }, } for _, tc := range testCases { @@ -1570,7 +1570,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { }, } dst.DrawRectShader(w, h, s, op) - if got, want := dst.At(0, 0).(color.RGBA), (color.RGBA{0x24, 0x85, 0x13, 0x19}); !sameColors(got, want, 1) { + if got, want := dst.At(0, 0).(color.RGBA), (color.RGBA{R: 0x24, G: 0x85, B: 0x13, A: 0x19}); !sameColors(got, want, 1) { t.Errorf("got: %v, want: %v", got, want) } } @@ -1583,31 +1583,31 @@ func TestShaderIVecMod(t *testing.T) { { source: `a := ivec4(0x24, 0x3f, 0x6a, 0x88) return vec4(a)/255`, - want: color.RGBA{0x24, 0x3f, 0x6a, 0x88}, + want: color.RGBA{R: 0x24, G: 0x3f, B: 0x6a, A: 0x88}, }, { source: `a := ivec4(0x24, 0x3f, 0x6a, 0x88) a %= 0x85 return vec4(a)/255`, - want: color.RGBA{0x24, 0x3f, 0x6a, 0x03}, + want: color.RGBA{R: 0x24, G: 0x3f, B: 0x6a, A: 0x03}, }, { source: `a := ivec4(0x24, 0x3f, 0x6a, 0x88) a %= ivec4(0x85, 0xa3, 0x08, 0xd3) return vec4(a)/255`, - want: color.RGBA{0x24, 0x3f, 0x02, 0x88}, + want: color.RGBA{R: 0x24, G: 0x3f, B: 0x02, A: 0x88}, }, { source: `a := ivec4(0x24, 0x3f, 0x6a, 0x88) b := a % 0x85 return vec4(b)/255`, - want: color.RGBA{0x24, 0x3f, 0x6a, 0x03}, + want: color.RGBA{R: 0x24, G: 0x3f, B: 0x6a, A: 0x03}, }, { source: `a := ivec4(0x24, 0x3f, 0x6a, 0x88) b := a % ivec4(0x85, 0xa3, 0x08, 0xd3) return vec4(b)/255`, - want: color.RGBA{0x24, 0x3f, 0x02, 0x88}, + want: color.RGBA{R: 0x24, G: 0x3f, B: 0x02, A: 0x88}, }, } diff --git a/vector/path.go b/vector/path.go index f69ec0f9d..94e41c32e 100644 --- a/vector/path.go +++ b/vector/path.go @@ -448,7 +448,7 @@ const ( LineJoinRound ) -// StokeOptions is options to render a stroke. +// StrokeOptions is options to render a stroke. type StrokeOptions struct { // Width is the stroke width in pixels. // diff --git a/vector/util.go b/vector/util.go index 15e8f738c..558608fac 100644 --- a/vector/util.go +++ b/vector/util.go @@ -91,7 +91,7 @@ func StrokeRect(dst *ebiten.Image, x, y, width, height float32, strokeWidth floa drawVerticesForUtil(dst, vs, is, clr) } -// DrawFilledCircle filles a circle with the specified center position (cx, cy), the radius (r), width and color. +// DrawFilledCircle fills a circle with the specified center position (cx, cy), the radius (r), width and color. func DrawFilledCircle(dst *ebiten.Image, cx, cy, r float32, clr color.Color) { var path Path path.Arc(cx, cy, r, 0, 2*math.Pi, Clockwise) diff --git a/window.go b/window.go index 7325928f8..83528bf23 100644 --- a/window.go +++ b/window.go @@ -30,16 +30,16 @@ type WindowResizingModeType = ui.WindowResizingMode // WindowResizingModeTypes const ( // WindowResizingModeDisabled indicates the mode to disallow resizing the window by a user. - WindowResizingModeDisabled WindowResizingModeType = WindowResizingModeType(ui.WindowResizingModeDisabled) + WindowResizingModeDisabled WindowResizingModeType = ui.WindowResizingModeDisabled // WindowResizingModeOnlyFullscreenEnabled indicates the mode to disallow resizing the window, // but allow to make the window fullscreen by a user. // This works only on macOS so far. // On the other platforms, this is the same as WindowResizingModeDisabled. - WindowResizingModeOnlyFullscreenEnabled WindowResizingModeType = WindowResizingModeType(ui.WindowResizingModeOnlyFullscreenEnabled) + WindowResizingModeOnlyFullscreenEnabled WindowResizingModeType = ui.WindowResizingModeOnlyFullscreenEnabled // WindowResizingModeEnabled indicates the mode to allow resizing the window by a user. - WindowResizingModeEnabled WindowResizingModeType = WindowResizingModeType(ui.WindowResizingModeEnabled) + WindowResizingModeEnabled WindowResizingModeType = ui.WindowResizingModeEnabled ) // IsWindowDecorated reports whether the window is decorated. @@ -67,14 +67,14 @@ func SetWindowDecorated(decorated bool) { // // WindowResizingMode is concurrent-safe. func WindowResizingMode() WindowResizingModeType { - return WindowResizingModeType(ui.Get().Window().ResizingMode()) + return ui.Get().Window().ResizingMode() } // SetWindowResizingMode sets the mode in which a user resizes the window. // // SetWindowResizingMode is concurrent-safe. func SetWindowResizingMode(mode WindowResizingModeType) { - ui.Get().Window().SetResizingMode(ui.WindowResizingMode(mode)) + ui.Get().Window().SetResizingMode(mode) } // IsWindowResizable reports whether the window is resizable by the user's dragging on desktops. @@ -300,7 +300,7 @@ func IsWindowBeingClosed() bool { // SetWindowClosingHandled sets whether the window closing is handled or not on desktops. The default state is false. // // If the window closing is handled, the window is not closed immediately and -// the game can know whether the window is begin closed or not by IsWindowBeingClosed. +// the game can know whether the window is being closed or not by IsWindowBeingClosed. // In this case, the window is not closed automatically. // To end the game, you have to return an error value at the Game's Update function. //