Fill out core architecture
This commit is contained in:
parent
7e4888af48
commit
454deed731
22
src/Render/Camera.idr
Normal file
22
src/Render/Camera.idr
Normal file
|
@ -0,0 +1,22 @@
|
|||
module Render.Camera
|
||||
|
||||
import Data.Nat
|
||||
import Render.Color
|
||||
|
||||
%default total
|
||||
|
||||
public export
|
||||
record Camera where
|
||||
constructor MkCamera
|
||||
center : (Double, Double)
|
||||
scenew, sceneh : Double
|
||||
pixw, pixh : Nat
|
||||
|
||||
|
||||
export
|
||||
pointToPix : Camera -> (Double, Double) -> (Integer, Integer)
|
||||
pointToPix (MkCamera (cx,cy) sw sh pw ph) (x,y) =
|
||||
let pw' = cast pw
|
||||
ph' = cast ph
|
||||
in (cast ((x - cx) / sw * pw' + pw' / 2),
|
||||
cast ((y - cy) / sh * ph' + ph' / 2))
|
10
src/Render/Color.idr
Normal file
10
src/Render/Color.idr
Normal file
|
@ -0,0 +1,10 @@
|
|||
module Render.Color
|
||||
|
||||
import Data.Vect
|
||||
|
||||
%default total
|
||||
|
||||
|
||||
public export
|
||||
Color : Type
|
||||
Color = Vect 4 Bits8
|
17
src/Render/Object.idr
Normal file
17
src/Render/Object.idr
Normal file
|
@ -0,0 +1,17 @@
|
|||
module Render.Object
|
||||
|
||||
import Data.Vect
|
||||
import Render.Camera
|
||||
import Render.Color
|
||||
|
||||
%default total
|
||||
|
||||
|
||||
public export
|
||||
interface Object' obj where
|
||||
draw : obj -> Camera -> List (Integer, Integer, Color)
|
||||
|
||||
|
||||
export
|
||||
data Object : Type where
|
||||
MkObject : Object' obj => obj -> Object
|
23
src/Render/Object/Point.idr
Normal file
23
src/Render/Object/Point.idr
Normal file
|
@ -0,0 +1,23 @@
|
|||
module Render.Object.Point
|
||||
|
||||
import Data.Vect
|
||||
import Render.Color
|
||||
import Render.Camera
|
||||
import Render.Picture
|
||||
import Render.Object
|
||||
|
||||
%default total
|
||||
|
||||
|
||||
|
||||
public export
|
||||
record Point where
|
||||
constructor MkPoint
|
||||
pos : (Double, Double)
|
||||
color : Color
|
||||
|
||||
|
||||
Object' Point where
|
||||
draw (MkPoint pos col) cam =
|
||||
let (px,py) = pointToPix cam pos
|
||||
in [(px,py,col)]
|
25
src/Render/Scene.idr
Normal file
25
src/Render/Scene.idr
Normal file
|
@ -0,0 +1,25 @@
|
|||
module Render.Scene
|
||||
|
||||
import Data.Vect
|
||||
import Render.Color
|
||||
import Render.Camera
|
||||
import Render.Object
|
||||
|
||||
%default total
|
||||
|
||||
|
||||
public export
|
||||
record Scene where
|
||||
constructor MkScene
|
||||
|
||||
camera : Camera
|
||||
objects : List Object
|
||||
bgcolor : Vect 3 Bits8
|
||||
|
||||
|
||||
public export
|
||||
PictureType : Scene -> Type
|
||||
PictureType sc = Vect sc.camera.pixh (Vect sc.camera.pixw (Vect 3 Bits8))
|
||||
|
||||
|
||||
|
Loading…
Reference in a new issue