if i type:
triangle = Object( JPoly(ngon(vertices_square[1], 10, 3, -π / 2, vertices = true); action = :fill, color = "black")))
and use this object inside some functions, ill get this error:( using pos(triangle) )
ERROR: MethodError: no method matching get_position(::Vector{Point})
Closest candidates are:
get_position(::Javis.Layer) at C:\Users\lol.julia\packages\Javis\UaLm7\src\layers.jl:187
get_position(::Point) at C:\Users\lol.julia\packages\Javis\UaLm7\src\object_values.jl:17
get_position(::Transformation) at C:\Users\lol.julia\packages\Javis\UaLm7\src\object_values.jl:18
…
Stacktrace:
[1] get_position(obj::Object)
@ Javis C:\Users\lol.julia\packages\Javis\UaLm7\src\object_values.jl:32
Insted if i use:
JCircle(vertices_square[1], 3; action = :fill, color = "black")
all my program works fine.
how can i fix this?
the workaround i can suggest for now is to explicitly declare an object calling poly
in the object function instead of using the shorthand
triangle = Object ( frames , (args...) -> begin
sethue("black")
poly(ngon(vertices_...) , :fill)
O
end )
1 Like
thx for the reply
i have another type of error now:
ERROR: MethodError: no method matching (::var"#17#18")(::Video, ::Object, ::Int64; center=Point(-199.91949180758272, -199.00324605295305))
Closest candidates are:
(::var"#17#18")(::Any…) at c:\Users\lol\Desktop\julia_esercizi\testants\graph.jl:181 got unsupported keyword argument “center”
Stacktrace:
[1] draw_object(object::Object, video::Video, frame::Int64, origin_matrix::Matrix{Float64}, layer_frames::Nothing)
@ Javis C:\Users\lol.julia\packages\Javis\UaLm7\src\Javis.jl:666
its’ because i am using
obj.change_keywords[:center] = new_point
to change the positions of objects without using transition.
it seems that i must use another keyword for the dictionary change_keywords when i declare explicitly the object
can you post the code here ?
this is an example of using change_keywords
i use it in the same way, here too if you change the code and declare explicitly the obj you will have the same error
the shorthands construct an anonymous function for you , take a look at JCircle.jl
in the source ,
it returns an anonymous function which has the signature (args...; center , radius , color , linewidth ,action )
so in that example the obj.func has a kwarg center
.
If you want to declare explicitly and not use shorthands you have to ensure that the function passed inside Object
has a kwarg center
(it should be a kwarg , not a usual arg)
similarly in your example , the function used for drawing should have a kwarg called center
1 Like
Fantastic! i read carefully JCircle.jl and tried to do the same thing with my anonymous function.
the solution is this:
Object(1:nframes,(args...;center =Point(10,30) -> begin
obj_coordinate = center
radius = 5
....
return obj_coordinate
end ))
should i make your comment as the solution or mine? i m still learning on how to help the comunity
you can mark whichever , upto you ,
Also I’m not sure on the etiquette on having a follow up question in the comments or as a separate
post altogether .
Also maybe change the code to be in a code block , (looks nicer that way )
1 Like