Permalink
Browse files

Use a two dimensional Array for palette

It used to be a struct but it only had one field left
  • Loading branch information...
sebashwa committed Oct 21, 2017
1 parent eee74b0 commit af0d99793ba7a6620a57cc5661794c05a1693838
Showing with 6 additions and 8 deletions.
  1. +1 −1 actions/paint/paint.go
  2. +3 −3 drawing/drawing.go
  3. +1 −1 factory/factory.go
  4. +1 −3 types/types.go
@@ -23,7 +23,7 @@ func SelectColor() {
position := state.Cursor.Position
if state.CurrentMode == modes.PaletteMode {
state.SelectedColor = state.Palette.Values[position.X][position.Y]
state.SelectedColor = state.Palette[position.X][position.Y]
} else {
state.SelectedColor = state.Canvas.Values[position.X][position.Y]
}
@@ -18,9 +18,9 @@ func DrawCanvas() {
}
func DrawPalette() {
for x, column := range state.Palette.Values {
for x, column := range state.Palette {
for y := range column {
color := termbox.Attribute(state.Palette.Values[x][y])
color := termbox.Attribute(state.Palette[x][y])
termbox.SetCell(x, y, ' ', color, color)
}
}
@@ -87,7 +87,7 @@ func drawCursor(x, y int) {
var backgroundColor termbox.Attribute
if state.CurrentMode == modes.PaletteMode {
backgroundColor = state.Palette.Values[x][y]
backgroundColor = state.Palette[x][y]
} else {
backgroundColor = state.Canvas.Values[x][y]
}
@@ -26,7 +26,7 @@ loop:
}
}
return types.Palette{Values: values}
return values
}
func CreateCanvas(columns, rows int) types.Canvas {
@@ -4,9 +4,7 @@ import (
"github.com/nsf/termbox-go"
)
type Palette struct {
Values [][]termbox.Attribute
}
type Palette [][]termbox.Attribute
type StatusBar struct {
Position int

0 comments on commit af0d997

Please sign in to comment.