import Graphics.OpenSCAD data Shelf = Shelf { width :: Double, depth :: Double, boardThickness :: Double, shelfHeights :: [Double] } deriving (Show) myShelf :: Shelf myShelf = Shelf { width = 36, depth = 8, boardThickness = 1, shelfHeights = [12, 12, 10, 10, 6, 6, 6] } modelShelf :: Shelf -> [Model3d] modelShelf s = let sidesPos = [(0,0,0), (boardThickness s + width s, 0, 0)] shelvesPos = let ys = scanl (+) 0 [h + boardThickness s|h <- shelfHeights s] in [ (boardThickness s, 0, y) | y <- ys ] place board places = map (\p -> translate p board) places in place sideBoard sidesPos ++ place shelfBoard shelvesPos where shelfHeight = sum (shelfHeights s) + (boardThickness s) * (fromIntegral (length $ shelfHeights s) + 1) sideBoard = box (boardThickness s) (depth s) shelfHeight shelfBoard = box (width s) (depth s) (boardThickness s) main :: IO () main = drawL $ modelShelf myShelf