thomasp85 / ggfx

Filters and Shaders for 'ggplot2'
https://ggfx.data-imaginist.com
Other
166 stars 4 forks source link

Unexpected behavior with_mask and with_shadow output #30

Open marcoaurelioguerrap opened 5 months ago

marcoaurelioguerrap commented 5 months ago

Hi, I found what I think is a bug when you combine with_mask and with_shadow. I think the shadow is being put on top of the used path.

# Suspected bug
ggplot(df) +
  geom_path(aes(x,y),
            color="#4bc4ff",linewidth=20,lineend="round" ) +
  with_shadow(
    geom_path(data=df[-3,],aes(x,y),
            color="blue",linewidth=20,lineend="round" ),
    stack=TRUE,x_offset = 0,y_offset = 0,sigma = 20,id="bar") +
  with_mask(
    geom_path(data=df,
              aes(x,y),
              linewidth=20,lineend='round'),
    mask=ch_alpha('bar')
  )

# Desired output
ggplot(df) +
  geom_path(aes(x,y),
            color="#4bc4ff",linewidth=20,lineend="round" ) +
  with_shadow(
    geom_path(data=df[-3,],aes(x,y),
              color="blue",linewidth=20,lineend="round" ),
    stack=FALSE,x_offset = 0,y_offset = 0,sigma = 20,id="bar") +
  with_mask(
    geom_path(data=df,
              aes(x,y),
              linewidth=20,lineend='round'),
    mask=ch_alpha('bar')
  ) +
  geom_path(data=df[-3,],aes(x,y),
            color="blue",linewidth=20,lineend="round" )

Expected output: image

Actual output: image