Skip to content

sordina/Diagrams-AST

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Diagrams AST (Abstract Syntax Tree)

Bar-Chart Example

Diagrams AST provides a data oriented interface to the Graphics.Rendering.Diagrams package.

This can be useful as it allows inspection and modification of diagrams. For example: Automatic Optimizations

Example:

import Graphics.Rendering.Diagrams.AST
import System.Random
import Control.Applicative
import Data.List (sort)

main = do
  heights <- fmap (sort . take 100) $ (zipWith (+)) <$> range (0,10) <*> range (0,10)
  outputImage ("chart.png") 400 300 $ barchart heights

barchart = Modifier (Changes [Align C, Pad 1.2]) . Images . Horizontal . map bar

bar y = Modifier (Changes [Align B, Foreground blue, Scale 1 (5*y)]) (Shape Square)

range b = fmap (randomRs b) newStdGen

blue = RGBA 0.2 0.3 1 1

To-do:

  • Move rendering code to a separate package
  • Move Gloss dependency to separate package
  • Complete function definitions

About

Abstract Syntax Tree for the Haskell Diagrams Package

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published