Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fillopacity: new issues #318

Closed
Mattriks opened this issue Oct 14, 2018 · 4 comments
Closed

Fillopacity: new issues #318

Mattriks opened this issue Oct 14, 2018 · 4 comments

Comments

@Mattriks
Copy link
Member

Mattriks commented Oct 14, 2018

@tlnagy, @bjarthur
Here is a MWE of the subsequent #314 issue in Compose (this example reproduces the code in Gadfly's Guide.background). Note the comments:

set_default_graphic_size(14cm,4cm)
panela = compose(context(order=1), rectangle(), fill(nothing), fillopacity(0.0) )
draw(SVG(), panela) # works in IJulia
draw(SVG("panela.svg"), panela) # opening file in browser shows error

The reason that error occurs is that fill(nothing) is RGBA(0,0,0,0), and hence in svg "fill-opacity=0" gets printed twice: once from fill(nothing) and once from fillopacity(0.0).
Perhaps a warning should be thrown in Compose - suggesting to the user that they can't use any xxxA fill color e.g. RGBA(0,0,0,0)and fillopacity() together for svg i.e. you can't specify the fill opacity twice for svg.
In Gadfly, there are two options to solve the issue:
i) make theme.panel_fill a e.g. RGBA color (it is), and deprecate theme.panel_opacity
ii) make theme.panel_fill a e.g. RGB color, and use theme.panel_opacity to control opacity

Note that option i) is actually what is done in Gadfly's render(plot::Plot) function, which has a fill(nothing) statement, and no fillopacity() statement, because fill(nothing) is RGBA(0,0,0,0).
Thoughts?

@bjarthur
Copy link
Member

i think #316 was on the right track, and all that needs to be added to it is to change the definition of svg_fmt_color to handle alpha values.

the SVG spec permits one to use either RGB or RGBA for fill colors.

@Mattriks
Copy link
Member Author

Mattriks commented Oct 14, 2018

I think updating svg_fmt_color to handle the rgba spec is good. I also found an example which shows that in svg fill="rgba()" and fill-opacity can be used together (which seems to have a multiplicative effect? i.e. 0.5*0.5 in the example).

@Mattriks
Copy link
Member Author

Mattriks commented Oct 15, 2018

I've been testing some new code using the svg rgba spec, and the question arises: What do you want the default behaviour for svg to be in this example?:

set_default_graphic_size(4cm,4cm)
img = compose(context(), 
        (context(), circle(0.5,0.5,0.3), fill(HSVA(45,1,1,0.5)), fillopacity(0.3) )
)
draw(SVG(), img)

There are two choices:
i) The alpha values get multiplied i.e 0.5*0.3 which is the default in svg
ii) Override the SVG behaviour by letting Compose change the color to HSVA(45,1,1,1) if fillopacity(x) is supplied. Then the final fill-opacity will be x.

Option ii) will take a bit more work then option i).

@tlnagy
Copy link
Member

tlnagy commented Oct 15, 2018

I think option i is reasonable, especially since this is the default behavior of SVG.

If the user provides a RGBA color with A ⊄ {0, 1} and fillopacity then I think it's reasonable to assume multiplicative behavior. I think we should make sure to add a note about this behavior in fillopacity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants