From eba0f9a2b54b1eb3c95775fd8437e958c0eeb0f4 Mon Sep 17 00:00:00 2001 From: Adrian Cochrane Date: Sun, 4 Jun 2023 16:53:16 +1200 Subject: [PATCH] Draft background-colour shader. --- Mondrian.cabal | 9 ++++++--- lib/Graphics/Rendering/Rect.hs | 6 ++++++ lib/Graphics/Rendering/Rect/Backgrounds.hs | 21 +++++++++++++++++++++ lib/Graphics/Rendering/Rect/Types.hs | 13 +++++++++++++ 4 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 lib/Graphics/Rendering/Rect.hs create mode 100644 lib/Graphics/Rendering/Rect/Backgrounds.hs create mode 100644 lib/Graphics/Rendering/Rect/Types.hs diff --git a/Mondrian.cabal b/Mondrian.cabal index c2df221..65c870d 100644 --- a/Mondrian.cabal +++ b/Mondrian.cabal @@ -18,13 +18,16 @@ build-type: Simple extra-source-files: CHANGELOG.md library - exposed-modules: Graphics.Rendering.Rect.CSS, + exposed-modules: Graphics.Rendering.Rect, + Graphics.Rendering.Rect.Backgrounds, + Graphics.Rendering.Rect.CSS, Graphics.Rendering.Rect.CSS.Colour, Graphics.Rendering.Rect.CSS.Background - -- other-modules: + other-modules: Graphics.Rendering.Rect.Types -- other-extensions: build-depends: base >=4.13 && <4.14, stylist-traits >= 0.1.3.1 && < 1, - css-syntax, colour >= 2.3.6 && < 3, scientific, text + css-syntax, colour >= 2.3.6 && < 3, scientific, text, + bytestring hs-source-dirs: lib default-language: Haskell2010 diff --git a/lib/Graphics/Rendering/Rect.hs b/lib/Graphics/Rendering/Rect.hs new file mode 100644 index 0000000..c38e20d --- /dev/null +++ b/lib/Graphics/Rendering/Rect.hs @@ -0,0 +1,6 @@ +module Graphics.Rendering.Rect(Rect(..), Rects(..), + RectStyle(..), colour, Backgrounds(..)) where + +import Graphics.Rendering.Rect.CSS +import Graphics.Rendering.Rect.CSS.Background +import Graphics.Rendering.Rect.Types diff --git a/lib/Graphics/Rendering/Rect/Backgrounds.hs b/lib/Graphics/Rendering/Rect/Backgrounds.hs new file mode 100644 index 0000000..c2cb07e --- /dev/null +++ b/lib/Graphics/Rendering/Rect/Backgrounds.hs @@ -0,0 +1,21 @@ +module Graphics.Rendering.Rect.Backgrounds(Backgrounds(..), renderBackgrounds) where + +import Graphics.Rendering.Rect.CSS.Background +import Graphics.Rendering.Rect.Types +import qualified Data.ByteString.Char8 as B8 + +baseVertexShader = B8.pack $ unlines [ + "#version 330 core;", + "uniform mat4 transform;", + "in vec2 pos;", + "void main() { gl_Position = pos * transform; }" + ] +baseFragmentShader = B8.pack $ unlines [ + "#version 330 core;", + "out vec4 fcolour;", + "in vec4 colour;", + "void main() { fcolour = colour; }" + ] + +renderBackgrounds :: Backgrounds -> Rects -> IO () +renderBackgrounds _ _ = return () diff --git a/lib/Graphics/Rendering/Rect/Types.hs b/lib/Graphics/Rendering/Rect/Types.hs new file mode 100644 index 0000000..c44b856 --- /dev/null +++ b/lib/Graphics/Rendering/Rect/Types.hs @@ -0,0 +1,13 @@ +module Graphics.Rendering.Rect.Types where + +data Rect = Rect { + left :: Double, top :: Double, + right :: Double, bottom :: Double +} deriving (Read, Show, Eq, Ord) + +data Rects = Rects { + content :: Rect, + padding :: Rect, + border :: Rect, + margin :: Rect +} deriving (Read, Show, Eq, Ord) -- 2.30.2