~alcinnz/Mondrian

eba0f9a2b54b1eb3c95775fd8437e958c0eeb0f4 — Adrian Cochrane 1 year, 4 months ago 4c875d8
Draft background-colour shader.
M Mondrian.cabal => Mondrian.cabal +6 -3
@@ 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


A lib/Graphics/Rendering/Rect.hs => lib/Graphics/Rendering/Rect.hs +6 -0
@@ 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

A lib/Graphics/Rendering/Rect/Backgrounds.hs => lib/Graphics/Rendering/Rect/Backgrounds.hs +21 -0
@@ 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 ()

A lib/Graphics/Rendering/Rect/Types.hs => lib/Graphics/Rendering/Rect/Types.hs +13 -0
@@ 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)