Slider in Julia with Luxor


#1

Hi!

I am trying to implement elementary graphics stuffs in Julia, like displaying a circle whose size would change based on the value set by the user on a slider.
My code:

using Luxor, Interact;
@png begin
    s = slider(0:.1:1,label="Slider X:")
    #display(s)
    #display(observe(s));
    #text("Hello world")
    circle(0, 0, observe(s), action=:nothing)
    #display(s)
    #circle(Point(0, 0), 200, :stroke)
end

Can you guys suggest a better way to try this? My permutations keep giving errors.


#2

Yes, it used to work well a long time ago. In fact it used to run into “IOPub data rate exceeded” messages it was that “working” :).

It sometimes works now:

But it has got gradually more broken over time.

There are some open issues (https://github.com/JuliaGizmos/Interact.jl/issues/196), (https://github.com/JuliaGraphics/Luxor.jl/issues/27 which has a Help Wanted label).

And then there was InteractNext (https://github.com/JuliaGizmos/InteractNext.jl), which also didn’t work.

It may be a problem I can fix. I don’t know…

Also, I would make sure the graphic syntax is correct, before trying to manipulate it:

julia-1.0> circle(0, 0, 5, action=:nothing)
ERROR: function circle does not accept keyword arguments

You want:

julia-1.0> circle(O, 5, :stroke)

or similar.


#3

Hi cormullion! Thanks for the help.

I tried this:

@manipulate for x in 5:50
    d = Drawing(300,300,:svg)
    origin()
    sethue(Colors.RGB(0.9, 0.4,0.6))
    #circle(0, x, :stroke)
    box(0,x,x,:fill)
    finish()
    d
end

I am getting this error:

MethodError: no method matching box(::Int64, ::Int64, ::Int64, ::Symbol)
Closest candidates are:
box(!Matched::Point, ::Any, ::Any, ::Symbol; vertices) at /home/subhankar/.julia/packages/Luxor/laUAE/src/shapes.jl:60
box(!Matched::Point, ::Any, ::Any, ::Any) at /home/subhankar/.julia/packages/Luxor/laUAE/src/shapes.jl:84
box(!Matched::Point, ::Any, ::Any, ::Any, !Matched::Symbol) at /home/subhankar/.julia/packages/Luxor/laUAE/src/shapes.jl:84

Stacktrace:
[1] (::getfield(Main, Symbol("##11#13")))(::Int64) at ./In[4]:6
[2] top-level scope at /home/subhankar/.julia/packages/InteractBase/Q4IkI/src/manipulate.jl:21
[3] top-level scope at In[4]:1


#4

the error suggests that you should use a Point. The manual describes all the available forms for box() here. The tutorial might be worth looking at too… :slight_smile:


#5

you could try using Luxor in a Gtk canvas
I have an old demo of a dynamic running clock here
https://github.com/nodrygo/GtkLuxorNaiveDemo