Add separate color type for alpha

This commit is contained in:
Kiana Sheibani 2022-11-30 09:50:41 -05:00
parent 454deed731
commit f3bda5d40c
Signed by: toki
GPG key ID: 6CB106C25E86A9F7
4 changed files with 19 additions and 7 deletions

View file

@ -7,4 +7,17 @@ import Data.Vect
public export public export
Color : Type Color : Type
Color = Vect 4 Bits8 Color = Vect 3 Double
public export
ColorAlpha : Type
ColorAlpha = Vect 4 Double
export
withAlpha : Double -> Color -> ColorAlpha
withAlpha a [r,g,b] = [r,g,b,a]
export
toAlpha : Color -> ColorAlpha
toAlpha = withAlpha 1

View file

@ -9,9 +9,9 @@ import Render.Color
public export public export
interface Object' obj where interface Object' obj where
draw : obj -> Camera -> List (Integer, Integer, Color) draw : obj -> Camera -> List (Integer, Integer, ColorAlpha)
export public export
data Object : Type where data Object : Type where
MkObject : Object' obj => obj -> Object MkObject : Object' obj => obj -> Object

View file

@ -14,9 +14,10 @@ public export
record Point where record Point where
constructor MkPoint constructor MkPoint
pos : (Double, Double) pos : (Double, Double)
color : Color color : ColorAlpha
export
Object' Point where Object' Point where
draw (MkPoint pos col) cam = draw (MkPoint pos col) cam =
let (px,py) = pointToPix cam pos let (px,py) = pointToPix cam pos

View file

@ -11,10 +11,8 @@ import Render.Object
public export public export
record Scene where record Scene where
constructor MkScene constructor MkScene
camera : Camera
objects : List Object objects : List Object
bgcolor : Vect 3 Bits8 bgcolor : Color
public export public export