Accurate colours?

24 views
Skip to first unread message

Edsko de Vries

unread,
Jul 9, 2018, 8:28:50 AM7/9/18
to diagrams-discuss
Hi all,

I'm using the cairo backend to generate animations (and tried it with rasterize also, with the same results). I'm using the `bgFrame` combinator to specify a background color for my animation, but the colour in the generated PNGs is off (not by much, but off nonetheless) (when specifying #272727 I get #2B2B2B). Any ideas why this might be happening and how I might address it?

Thanks!

-Edsko

Brent Yorgey

unread,
Jul 27, 2018, 12:04:02 PM7/27/18
to Edsko de Vries, diagrams-discuss
Hi Edsko,

Apologies for the long delay in responding.  This is curious.  How exactly do you specify the color #272727, i.e. what functions do you use to construct it?

-Brent

--
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.

Edsko de Vries

unread,
Jul 31, 2018, 2:06:04 PM7/31/18
to byo...@gmail.com, diagrams...@googlegroups.com
Hi Brent,

Thanks for replying. I was specifying this through a new command line flag, which I defined as follows:

newtype Background = Background (Maybe (Colour Double))

instance Parseable Background where
  parser = Opt.option (Opt.str >>= aux) $ mconcat [
        Opt.long "background"
      , Opt.help "Background color"
      ]
    where
      aux :: String -> Opt.ReadM Background
      aux "none" = return $ Background Nothing
      aux str    = Background . Just . fromAlphaColour <$> readHexColor str

and which I then use as follows

backgroundRect :: Background -> Diagram B
backgroundRect (Background background) =
    rect (20 * nodeDiameter) (14 * nodeDiameter)
      # lwO 0
      # maybe id fc background

I worked around the problem by adding a border around the rendered animation (so that the difference between the animation and rest of background on which I was showing it wasn't so obvious). 

Curious little problem! :)

-Edsko

Brent Yorgey

unread,
Aug 10, 2018, 4:20:43 PM8/10/18
to Edsko de Vries, diagrams...@googlegroups.com
I think ultimately this must have something to do with how the color is read and represented internally (hint: it's not just represented as 3 bytes), and perhaps some kind of color space conversion that is happening when you don't intend it.  I haven't been able to get to the bottom of it though...

-Brent
Reply all
Reply to author
Forward
0 new messages