Skip to content

Commit 4d8d789

Browse files
committed
[refactor] Make defaultPalette a variable
There is no need to have a function. Arrays are by default copied by value.
1 parent d8b6612 commit 4d8d789

File tree

2 files changed

+20
-22
lines changed

2 files changed

+20
-22
lines changed

pi.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ var (
3838
// found, then default 16 color palette is used.
3939
//
4040
// Can be freely read and updated. Changes will be visible immediately.
41-
Palette [256]image.RGB = defaultPalette()
41+
Palette [256]image.RGB = defaultPalette
4242

4343
// SpriteSheetWidth will be used if sprite-sheet.png was not found.
4444
SpriteSheetWidth = defaultSpriteSheetWidth
@@ -84,7 +84,7 @@ func Reset() {
8484
ScreenWidth = defaultScreenWidth
8585
ScreenHeight = defaultScreenHeight
8686
Color = 6
87-
Palette = defaultPalette()
87+
Palette = defaultPalette
8888
}
8989

9090
// Boot initializes the engine based on user parameters such as ScreenWidth and ScreenHeight.

resources.go

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -55,24 +55,22 @@ func useSpriteSheet(b []byte) error {
5555
return nil
5656
}
5757

58-
func defaultPalette() [256]image.RGB {
59-
//nolint:govet
60-
return [256]image.RGB{
61-
{0, 0, 0},
62-
{0x1D, 0x2B, 0x53},
63-
{0x7E, 0x25, 0x53},
64-
{0x00, 0x87, 0x51},
65-
{0xAB, 0x52, 0x36},
66-
{0x5F, 0x57, 0x4F},
67-
{0xC2, 0xC3, 0xC7},
68-
{0xff, 0xf1, 0xe8},
69-
{0xFF, 0x00, 0x4D},
70-
{0xFF, 0xA3, 0x00},
71-
{0xFF, 0xEC, 0x27},
72-
{0x00, 0xE4, 0x36},
73-
{0x29, 0xAD, 0xFF},
74-
{0x83, 0x76, 0x9C},
75-
{0xFF, 0x77, 0xA8},
76-
{0xFF, 0xCC, 0xAA},
77-
}
58+
//nolint:govet
59+
var defaultPalette = [256]image.RGB{
60+
{0, 0, 0},
61+
{0x1D, 0x2B, 0x53},
62+
{0x7E, 0x25, 0x53},
63+
{0x00, 0x87, 0x51},
64+
{0xAB, 0x52, 0x36},
65+
{0x5F, 0x57, 0x4F},
66+
{0xC2, 0xC3, 0xC7},
67+
{0xff, 0xf1, 0xe8},
68+
{0xFF, 0x00, 0x4D},
69+
{0xFF, 0xA3, 0x00},
70+
{0xFF, 0xEC, 0x27},
71+
{0x00, 0xE4, 0x36},
72+
{0x29, 0xAD, 0xFF},
73+
{0x83, 0x76, 0x9C},
74+
{0xFF, 0x77, 0xA8},
75+
{0xFF, 0xCC, 0xAA},
7876
}

0 commit comments

Comments
 (0)