From bb1bb02e1ceac8dc9b8bfe2aca2754b5f234297d Mon Sep 17 00:00:00 2001 From: Tristan Cacqueray Date: Sun, 21 Feb 2021 23:09:07 +0000 Subject: [PATCH] Add setNextPlotLimits --- src/DearImGui/Plot.hs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/DearImGui/Plot.hs b/src/DearImGui/Plot.hs index b9aa479..096ab2b 100644 --- a/src/DearImGui/Plot.hs +++ b/src/DearImGui/Plot.hs @@ -47,3 +47,12 @@ plotLine desc xs ys = liftIO $ do withArray (map realToFrac xs) \xsPtr -> do withArray (map realToFrac ys) \ysPtr -> do [C.exp| void { PlotLine( $(char* descPtr), $(float *xsPtr), $(float *ysPtr), $(int size) ) } |] + +setNextPlotLimits :: MonadIO m => (Double, Double) -> (Double, Double) -> m () +setNextPlotLimits (minX, maxX) (minY, maxY) = + liftIO [C.exp| void { SetNextPlotLimits( $(double minX'), $(double maxX'), $(double minY'), $(double maxY') ) } |] + where + minX' = realToFrac minX + maxX' = realToFrac maxX + minY' = realToFrac minY + maxY' = realToFrac maxY