dynamic-graph-0.1.0.5: Draw and update graphs in real time with OpenGL

Safe HaskellNone
LanguageHaskell2010

Graphics.DynamicGraph.Waterfall

Description

Draw and update waterfall plots with OpenGL. Useful for spectrograms.

Example usage:

import Control.Monad
import Control.Monad.Trans.Either
import Control.Concurrent
import Pipes
import qualified Pipes.Prelude as P
import System.Random
import Graphics.Rendering.OpenGL

import Graphics.DynamicGraph.Waterfall

randomVect :: Producer [GLfloat] IO ()
randomVect =  P.repeatM $ do
    res <- replicateM 1000 randomIO
    threadDelay 10000
    return res

main = eitherT putStrLn return $ do
    setupGLFW
    waterfall <- waterfallWindow 1024 480 1000 1000 jet_mod

    lift $ runEffect $ randomVect >-> waterfall

Synopsis

Documentation

waterfallWindow :: IsPixelData a => Int -> Int -> Int -> Int -> [GLfloat] -> EitherT String IO (Consumer a IO ()) Source

(waterfallWindow windowWidth windowHeight width height colormap) creates a window of width windowWidth and height windowHeight for displaying a waterfall plot.

A Consumer is returned for updating the waterfall plot. Feeding an instance of IsPixelData of length width shifts all rows of the waterfall down and updates the top row with the data.

The waterfall is height rows of data high. colorMap is used to map values to display color.

renderWaterfall :: IsPixelData a => Int -> Int -> [GLfloat] -> IO (Consumer a IO ()) Source

(renderWaterfallLine width height colorMap) returns a Consumer that renders a waterfall plot into the current OpenGL context. The Consumer takes data that is an instance of IsPixelData and of length width. The waterfall is height rows of data high.

The fill is drawn with a vertical gradient defined by colorMap.

All OpenGL based initialization of the rendering function (loading of shaders, etc) is performed before the pipe is returned.

setupGLFW :: EitherT String IO () Source

Utility function to setup GLFW for graph drawing