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

Observable alpha value is not updated #2998

Closed
blegat opened this issue Jun 9, 2023 · 2 comments
Closed

Observable alpha value is not updated #2998

blegat opened this issue Jun 9, 2023 · 2 comments

Comments

@blegat
Copy link
Contributor

blegat commented Jun 9, 2023

Thanks for this amazing package!
In the following minimal reproducing example, I am creating a slider and using its value to set the opacity/alpha value of a square.
The square starts with the starting value of the slider, that works. But when moving the slider, it does not get updated.
Is that a bug or am I not using this correctly ?

using GLMakie

function main(start=0.5)
    fig = Figure(resolution=(1200, 800))

    slider = Slider(
        fig[1, 1],
        range = LinRange(0, 1, 20),
        startvalue = start,
    )

    s = LScene(fig[2, 1], width=1200, height=600)

    mesh!(s, Rect3f(Point3f(0, 0, 0), Point3f(1, 1, 1)), color = (:black, slider.value))

    return fig
end

display(main(start))
@SimonDanisch
Copy link
Member

You can't stack observables like this, the whole color attribute must be an observable, so try:

color = lift(a-> (:black, a), slider.value)

@jkrumbiegel
Copy link
Member

Or @lift((:black, $(slider.value)))

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