Added basic raycaster demo. I have no idea why I did this.

This commit is contained in:
2023-02-20 01:52:50 -05:00
parent 0c39c2dd57
commit e9e1ccc35e
5 changed files with 369 additions and 1 deletions

View File

@@ -7,7 +7,7 @@ import "image/color"
// Pattern, color.Color, color.Model, and image.Image interfaces.
type Uniform color.RGBA
// NewUniform returns a new Uniform image of the given color.
// NewUniform returns a new Uniform pattern of the given color.
func NewUniform (c color.Color) (uniform Uniform) {
r, g, b, a := c.RGBA()
uniform.R = uint8(r >> 8)
@@ -17,6 +17,19 @@ func NewUniform (c color.Color) (uniform Uniform) {
return
}
func hex (color uint32) (c color.RGBA) {
c.A = uint8(color)
c.B = uint8(color >> 8)
c.G = uint8(color >> 16)
c.R = uint8(color >> 24)
return
}
// Uhex creates a new Uniform pattern from an RGBA integer value.
func Uhex (color uint32) (uniform Uniform) {
return NewUniform(hex(color))
}
// ColorModel satisfies the image.Image interface.
func (uniform Uniform) ColorModel () (model color.Model) {
return uniform