ragg
ragg copied to clipboard
Differences in rendering results for the alpha parameter
Hi! @thomasp85
Hmm... that's interesting. Can I get you to open a different issue about that? It should (in theory) be the same...
Originally posted by @thomasp85 in #205
I've placed the results of both renderings below. I hope the differences aren't due to my code...
library(ggplot2)
colors <- grid::linearGradient(
c("white", "#f6915e"),
stops = seq(0, 1, length.out = 2),
x1 = unit(0, "npc"),
y1 = unit(0, "npc"),
x2 = unit(0, "npc"),
y2 = unit(1, "npc"),
)
ragg::agg_png("/Users/sy/Desktop/test1.png",
width = 4, height = 4, units = "in",
res = 600,bitsize = 16)
ggplot(mtcars, aes(mpg, wt)) +
geom_rect(
aes(xmin = I(0.2), xmax = I(0.5), ymin = I(0), ymax = I(1)),
fill = fill_alpha(colors, alpha = 0.2)
)
dev.off()
Result:
png("/Users/sy/Desktop/test2.png",
width = 4, height = 4, units = "in",
res = 600)
ggplot(mtcars, aes(mpg, wt)) +
geom_rect(
aes(xmin = I(0.2), xmax = I(0.5), ymin = I(0), ymax = I(1)),
fill = fill_alpha(colors, alpha = 0.2)
)
dev.off()
Result:
ragg::agg_png("/Users/sy/Desktop/test3.png",
width = 4, height = 4, units = "in",
res = 600, bitsize = 16)
ggplot(mtcars, aes(mpg, wt)) +
geom_rect(
aes(xmin = I(0.2), xmax = I(0.5), ymin = I(0), ymax = I(1)),
fill = fill_alpha(colors, alpha = 0.05) # lower alpha value
)
dev.off()
I cannot see anywhere that AGG should handle transparency any different when working with 16bit colours. Maybe alpha blending is just more precise due to lack of rounding errors when done at higher precision, but I can't convince myself that a value of 0.2 should be that opaque in reality.
I'll leave this open in case an epiphany comes around