From 25c48aa1e384036e6dbc31a0579c9422f9cc3482 Mon Sep 17 00:00:00 2001 From: Francesco <7frapar@gmail.com> Date: Fri, 29 Jul 2022 16:32:45 +0200 Subject: [PATCH] set up initial project, ready to work --- amaranth.cabal | 1 + app/Main.hs | 4 ++-- src/Canvas.hs | 22 ++++++++++++++++++++++ src/Lib.hs | 18 +++++++++++++----- 4 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 src/Canvas.hs diff --git a/amaranth.cabal b/amaranth.cabal index ac6ab2e..0c242d0 100644 --- a/amaranth.cabal +++ b/amaranth.cabal @@ -25,6 +25,7 @@ source-repository head library exposed-modules: + Canvas Lib other-modules: Paths_amaranth diff --git a/app/Main.hs b/app/Main.hs index de1c1ab..0fd53fc 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -1,6 +1,6 @@ module Main where -import Lib +import Lib as L main :: IO () -main = someFunc +main = L.app diff --git a/src/Canvas.hs b/src/Canvas.hs new file mode 100644 index 0000000..457bc79 --- /dev/null +++ b/src/Canvas.hs @@ -0,0 +1,22 @@ +module Canvas where + +import Graphics.Gloss.Data.Picture ( Picture, pictures ) +import Graphics.Gloss.Interface.IO.Interact ( Event ) + +newtype Canvas = Canvas { + items :: [Picture] +} + +initial :: Canvas +initial = Canvas { + items = [] +} + +render :: Canvas -> Picture +render canvas = pictures ( items canvas ) + +handle :: Event -> Canvas -> Canvas +handle _ _ = initial + +update :: Float -> Canvas -> Canvas +update _ _ = initial \ No newline at end of file diff --git a/src/Lib.hs b/src/Lib.hs index d36ff27..5393e8f 100644 --- a/src/Lib.hs +++ b/src/Lib.hs @@ -1,6 +1,14 @@ -module Lib - ( someFunc - ) where +module Lib where -someFunc :: IO () -someFunc = putStrLn "someFunc" +import Graphics.Gloss +import Canvas as C + +-- Variables +display :: Display +display = InWindow "Amaranth" (500, 500) (0,0) + +background :: Color +background = white + +app :: IO () +app = play Lib.display background 60 C.initial C.render C.handle C.update