Problem with Diagrams.rasterific and atop

9 views
Skip to first unread message

Jorge Devoto

unread,
Mar 7, 2019, 9:34:11 AM3/7/19
to diagrams-discuss
Hi

I have the following program


----------------------------------------------------------------------------------------------------------------------------------------
{-# LANGUAGE NoMonomorphismRestriction #-}
{-# LANGUAGE FlexibleContexts          #-}
{-# LANGUAGE TypeFamilies              #-}


import Diagrams.Prelude
import Diagrams.Backend.Rasterific.CmdLine

type Dia = Diagram B

-- Horizontal line
xaxis :: Double -> Double -> Dia
xaxis xmin xmax = fromVertices lims # strokeLine # lc white
  where
    vert = [(xmin -1, 0), (xmax + 1, 0)]
    lims = map p2 vert

-- vertical line
yaxis :: Double -> Double -> Dia
yaxis ymin ymax = fromVertices lims # strokeLine # lc white
  where
    vert = [(0, ymin -1), (0, ymax + 1)]
    lims = map p2 vert

-- reference frame
refFrame :: Double -> Double -> Double -> Double -> Dia
refFrame xmin xmax ymin ymax = atop (xaxis xmin xmax)  (yaxis ymin ymax)


ss = mkSizeSpec2D (Just 800) (Just 800)
--------------------------------------------------------------------------------------------------------------------------------------


If I put

main :: IO ()
main = renderRasterific "tt2.jpg" ss  (xaxis (-1) 1)

I get a horizontal line as i want.

if i put


main :: IO ()
main = renderRasterific "tt2.jpg" ss  (xaxis (-1) 1)

I get a vertical line. The problem is that if i put

main :: IO ()
main = renderRasterific "tt2.jpg" ss  (refFrame (-1) 1 (-1) 1)

I only get a black square.

I am doing something wrong?

Any help is welcomed

Jorge


Ryan Yates

unread,
Mar 7, 2019, 10:45:47 AM3/7/19
to Jorge Devoto, diagrams-discuss
Hi Jorge,

There is a lot of polymorphism with `fromVerticies`.  The `strokeLine` function causes your points to be interpreted as a trail that is not located.  To keep the positional information, use `strokeLocTrail`.

Hope this helps!

Ryan


--
You received this message because you are subscribed to the Google Groups "diagrams-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to diagrams-discu...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jorge Devoto

unread,
Mar 10, 2019, 8:41:15 AM3/10/19
to diagrams-discuss
It worked. Thank you

Best

Jorge
Reply all
Reply to author
Forward
0 new messages