Skip to content

Instantly share code, notes, and snippets.

@themattchan
Created April 24, 2016 01:44
Show Gist options
  • Save themattchan/649a9b1c3d9b51280fb1d27d036a4413 to your computer and use it in GitHub Desktop.
Save themattchan/649a9b1c3d9b51280fb1d27d036a4413 to your computer and use it in GitHub Desktop.
#! /usr/bin/runhaskell
{-# LANGUAGE FlexibleContexts #-}
module Lib where
import Diagrams.Prelude
import Diagrams.Backend.PGF.CmdLine
pipeline :: Diagram PGF
pipeline = foldr1 (|||) labelledBlocks
where
block name color = label name <> (rect 20 10 # fcA color)
label name = text name # bold
# fontSize (local 2)
# font "Computer Modern Teletype L"
# fc white
colours = map (`withOpacity` 0.75)
[ red, orange, green, blue, purple ]
stages = [ "IF", "ID", "EXE", "MEM", "WB" ]
labelledBlocks = zipWith block stages colours
draw :: Diagram PGF -> IO ()
draw = defaultMain . pad 1.1 . scale 3
main :: IO ()
main = draw pipeline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment