Add Rectangle object
This commit is contained in:
parent
fb18cce4ec
commit
f5edad4b66
|
@ -13,6 +13,7 @@ public export
|
|||
ColorAlpha : Type
|
||||
ColorAlpha = Vect 4 Double
|
||||
|
||||
|
||||
export
|
||||
withAlpha : Double -> Color -> ColorAlpha
|
||||
withAlpha a [r,g,b] = [r,g,b,a]
|
||||
|
|
|
@ -5,6 +5,7 @@ import Render.Camera
|
|||
import Render.Color
|
||||
import public Render.Object.Interface
|
||||
import public Render.Object.Point
|
||||
import public Render.Object.Rectangle
|
||||
|
||||
%default total
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ module Render.Object.Point
|
|||
import Data.Vect
|
||||
import Render.Color
|
||||
import Render.Camera
|
||||
import Render.Picture
|
||||
import Render.Object.Interface
|
||||
|
||||
%default total
|
||||
|
|
25
src/Render/Object/Rectangle.idr
Normal file
25
src/Render/Object/Rectangle.idr
Normal file
|
@ -0,0 +1,25 @@
|
|||
module Render.Object.Rectangle
|
||||
|
||||
import Data.Vect
|
||||
import Render.Color
|
||||
import Render.Camera
|
||||
import Render.Object.Interface
|
||||
|
||||
%default total
|
||||
|
||||
|
||||
public export
|
||||
record Rectangle where
|
||||
constructor MkRect
|
||||
pos : (Double, Double)
|
||||
width, height : Double
|
||||
color : ColorAlpha
|
||||
|
||||
|
||||
export
|
||||
IsObject Rectangle where
|
||||
draw (MkRect pos w h col) cam =
|
||||
let (px,py) = pointToPix cam pos
|
||||
pw = cast (w / cam.scenew * cast cam.pixw)
|
||||
ph = cast (h / cam.sceneh * cast cam.pixh)
|
||||
in (,,col) <$> [px..px+pw-1] <*> [py..py+ph-1]
|
Loading…
Reference in a new issue