1
0
Fork 0

draw using color palette rather than RGB directly.

This commit is contained in:
Henrik Hautakoski 2025-06-25 22:15:26 +02:00
parent 82b0b0a386
commit 575791cfc1
5 changed files with 277 additions and 14 deletions

View file

@ -1,7 +1,6 @@
package graphics
import (
"github.com/pnx/go-raytracer/math"
"github.com/veandco/go-sdl2/sdl"
)
@ -19,12 +18,14 @@ func (c Context) Height() int32 {
return c.h
}
func (c Context) DrawLine(x1 int32, y1 int32, x2 int32, y2 int32, color math.Color) {
func (c Context) DrawLine(x1 int32, y1 int32, x2 int32, y2 int32, colorIndex byte) {
color := Palette[colorIndex]
c.renderer.SetDrawColor(color.R, color.G, color.B, color.A)
c.renderer.DrawLine(x1, y1, x2, y2)
}
func (c Context) DrawRect(x, y, w, h int32, color math.Color) {
func (c Context) DrawRect(x, y, w, h int32, colorIndex byte) {
color := Palette[colorIndex]
c.renderer.SetDrawColor(color.R, color.G, color.B, color.A)
c.renderer.FillRect(&sdl.Rect{
X: x,