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.
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 (Manipulate sliders hidden underneath output · Issue #196 · JuliaGizmos/Interact.jl · GitHub ), (Using Interact.jl and Luxor.jl inside IJulia (Jupyter) notebook · Issue #27 · JuliaGraphics/Luxor.jl · GitHub which has a Help Wanted label).
And then there was InteractNext (GitHub - 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.
cormullion:
, :stroke
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
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…
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_