drawGraph :: Context -> CFloat -> CFloat -> CFloat -> CFloat -> CFloat -> IO ()
drawGraph c x y w h t =
  do bg <- linearGradient c x y x (y+h) (rgba 0 16 192 0) (rgba 0 160 192 64)
     beginPath c
     moveTo c (sx V.! 0) (sy V.! 0)
     forM_ [1..5] $ \i ->
       bezierTo c (sx V.! (i-1) + dx*0.5) (sy V.! (i-1)) (sx V.! i - dx*0.5) (sy V.! i) (sx V.! i) (sy V.! i)
     lineTo c (x+w) (y+h)
     lineTo c x (y+h)
     fillPaint c bg
     fill c

     beginPath c
     moveTo c (sx V.! 0) (sy V.! 0 + 2)
     forM_ [1..5] $ \i ->
       bezierTo c (sx V.! (i-1)+dx*0.5) (sy V.! (i-1)+2) (sx V.! i - dx*0.5) (sy V.! i + 2) (sx V.! i) (sy V.! i + 2)
     strokeColor c (rgba 0 0 0 32)
     strokeWidth c 3
     stroke c

     beginPath c
     moveTo c (sx V.! 0) (sy V.! 0)
     forM_ [1..5] $ \i ->
       bezierTo c (sx V.! (i-1)+dx*0.5) (sy V.! (i-1)) (sx V.! i - dx*0.5) (sy V.! i) (sx V.! i) (sy V.! i)
     strokeColor c (rgba 0 160 192 255)
     strokeWidth c 3
     stroke c

     V.forM_ (V.zip sx sy) $ \(x,y) ->
       do bg <- radialGradient c x (y+2) 3 8 (rgba 0 0 0 32) (rgba 0 0 0 0)
          beginPath c
          rect c (x-10) (y-10+2) 20 20
          fillPaint c bg
          fill c

     beginPath c
     V.forM_ (V.zip sx sy) $ \(x,y) -> circle c x y 4
     fillColor c (rgba 0 160 192 255)
     fill c
     beginPath c
     V.forM_ (V.zip sx sy) $ \(x,y) -> circle c x y 2
     fillColor c (rgba 220 220 220 255)
     fill c
     
     strokeWidth c 1
  where samples :: V.Vector CFloat
        samples =
          V.fromList
            [(1 + sin (t * 1.2345 + cos (t * 0.33457) * 0.44)) * 0.5
            ,(1 + sin (t * 0.68363 + cos (t * 1.3) * 1.55)) * 0.5
            ,(1 + sin (t * 1.1642 + cos (t * 0.33457) * 1.24)) * 0.5
            ,(1 + sin (t * 0.56345 + cos (t * 1.63) * 0.14)) * 0.5
            ,(1 + sin (t * 1.6245 + cos (t * 0.254) * 0.3)) * 0.5
            ,(1 + sin (t * 0.345 + cos (t * 0.03) * 0.6)) * 0.5]
        dx = w / 5
        sx :: V.Vector CFloat
        sx =
          V.generate 6
                     (\i -> x + fromIntegral i * dx)
        sy :: V.Vector CFloat
        sy = V.map (\s -> y + h * s * 0.8) samples
drawGraph :: Context -> CFloat -> CFloat -> CFloat -> CFloat -> CFloat -> IO ()
drawGraph c x y w h t =
  do bg <- linearGradient c x y x (y+h) (rgba 0 16 192 0) (rgba 0 160 192 64)
     beginPath c
     moveTo c (sx V.! 0) (sy V.! 0)
     forM_ [1..5] $ \i ->
       bezierTo c (sx V.! (i-1) + dx*0.5) (sy V.! (i-1)) (sx V.! i - dx*0.5) (sy V.! i) (sx V.! i) (sy V.! i)
     lineTo c (x+w) (y+h)
     lineTo c x (y+h)
     fillPaint c bg
     fill c

     beginPath c
     moveTo c (sx V.! 0) (sy V.! 0 + 2)
     forM_ [1..5] $ \i ->
       bezierTo c (sx V.! (i-1)+dx*0.5) (sy V.! (i-1)+2) (sx V.! i - dx*0.5) (sy V.! i + 2) (sx V.! i) (sy V.! i + 2)
     strokeColor c (rgba 0 0 0 32)
     strokeWidth c 3
     stroke c

     beginPath c
     moveTo c (sx V.! 0) (sy V.! 0)
     forM_ [1..5] $ \i ->
       bezierTo c (sx V.! (i-1)+dx*0.5) (sy V.! (i-1)) (sx V.! i - dx*0.5) (sy V.! i) (sx V.! i) (sy V.! i)
     strokeColor c (rgba 0 160 192 255)
     strokeWidth c 3
     stroke c

     V.forM_ (V.zip sx sy) $ \(x,y) ->
       do bg <- radialGradient c x (y+2) 3 8 (rgba 0 0 0 32) (rgba 0 0 0 0)
          beginPath c
          rect c (x-10) (y-10+2) 20 20
          fillPaint c bg
          fill c

     beginPath c
     V.forM_ (V.zip sx sy) $ \(x,y) -> circle c x y 4
     fillColor c (rgba 0 160 192 255)
     fill c
     beginPath c
     V.forM_ (V.zip sx sy) $ \(x,y) -> circle c x y 2
     fillColor c (rgba 220 220 220 255)
     fill c
     
     strokeWidth c 1
  where samples :: V.Vector CFloat
        samples =
          V.fromList
            [(1 + sin (t * 1.2345 + cos (t * 0.33457) * 0.44)) * 0.5
            ,(1 + sin (t * 0.68363 + cos (t * 1.3) * 1.55)) * 0.5
            ,(1 + sin (t * 1.1642 + cos (t * 0.33457) * 1.24)) * 0.5
            ,(1 + sin (t * 0.56345 + cos (t * 1.63) * 0.14)) * 0.5
            ,(1 + sin (t * 1.6245 + cos (t * 0.254) * 0.3)) * 0.5
            ,(1 + sin (t * 0.345 + cos (t * 0.03) * 0.6)) * 0.5]
        dx = w / 5
        sx :: V.Vector CFloat
        sx =
          V.generate 6
                     (\i -> x + fromIntegral i * dx)
        sy :: V.Vector CFloat
        sy = V.map (\s -> y + h * s * 0.8) samples
drawGraph c x y w h t =
  do bg <- linearGradient c x y x (y+h) (rgba 0 16 192 0) (rgba 0 160 192 64)
     beginPath c
     moveTo c (sx V.! 0) (sy V.! 0)
     forM_ [1..5] $ \i ->
       bezierTo c (sx V.! (i-1) + dx*0.5) (sy V.! (i-1)) (sx V.! i - dx*0.5) (sy V.! i) (sx V.! i) (sy V.! i)
     lineTo c (x+w) (y+h)
     lineTo c x (y+h)
     fillPaint c bg
     fill c

     beginPath c
     moveTo c (sx V.! 0) (sy V.! 0 + 2)
     forM_ [1..5] $ \i ->
       bezierTo c (sx V.! (i-1)+dx*0.5) (sy V.! (i-1)+2) (sx V.! i - dx*0.5) (sy V.! i + 2) (sx V.! i) (sy V.! i + 2)
     strokeColor c (rgba 0 0 0 32)
     strokeWidth c 3
     stroke c

     beginPath c
     moveTo c (sx V.! 0) (sy V.! 0)
     forM_ [1..5] $ \i ->
       bezierTo c (sx V.! (i-1)+dx*0.5) (sy V.! (i-1)) (sx V.! i - dx*0.5) (sy V.! i) (sx V.! i) (sy V.! i)
     strokeColor c (rgba 0 160 192 255)
     strokeWidth c 3
     stroke c

     V.forM_ (V.zip sx sy) $ \(x,y) ->
       do bg <- radialGradient c x (y+2) 3 8 (rgba 0 0 0 32) (rgba 0 0 0 0)
          beginPath c
          rect c (x-10) (y-10+2) 20 20
          fillPaint c bg
          fill c

     beginPath c
     V.forM_ (V.zip sx sy) $ \(x,y) -> circle c x y 4
     fillColor c (rgba 0 160 192 255)
     fill c
     beginPath c
     V.forM_ (V.zip sx sy) $ \(x,y) -> circle c x y 2
     fillColor c (rgba 220 220 220 255)
     fill c
     
     strokeWidth c 1
  where samples :: V.Vector CFloat
        samples =
          V.fromList
            [(1 + sin (t * 1.2345 + cos (t * 0.33457) * 0.44)) * 0.5
            ,(1 + sin (t * 0.68363 + cos (t * 1.3) * 1.55)) * 0.5
            ,(1 + sin (t * 1.1642 + cos (t * 0.33457) * 1.24)) * 0.5
            ,(1 + sin (t * 0.56345 + cos (t * 1.63) * 0.14)) * 0.5
            ,(1 + sin (t * 1.6245 + cos (t * 0.254) * 0.3)) * 0.5
            ,(1 + sin (t * 0.345 + cos (t * 0.03) * 0.6)) * 0.5]
        dx = w / 5
        sx :: V.Vector CFloat
        sx =
          V.generate 6
                     (\i -> x + fromIntegral i * dx)
        sy :: V.Vector CFloat
        sy = V.map (\s -> y + h * s * 0.8) samples