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

Size of arguments calling poly #1514

Closed
edljk opened this issue Dec 14, 2021 · 6 comments · Fixed by #1564
Closed

Size of arguments calling poly #1514

edljk opened this issue Dec 14, 2021 · 6 comments · Fixed by #1564

Comments

@edljk
Copy link
Contributor

edljk commented Dec 14, 2021

I am a little bit confused with the size of attribute using a vector of polygons:

using GLMakie
P = [Polygon([Point2(rand(), rand()) for _ = 1:3]) for k = 1:2]
poly!(P, color = [:red, :green], strokecolor = :blue, strokewidth = 1)

works fine. Surprisingly, choosing one different color by triangle

poly!(P, color = [:red, :green], strokecolor = [:blue, :red], strokewidth = 1)

produces an error. Is it the expected behavior?
Thanks!

@SimonDanisch
Copy link
Member

Hm, guess strokecolor isn't handled correctly by the multi poly recipe...

@SimonDanisch
Copy link
Member

I think at this line one would need to check for number of poly elements and then adapt the color accordingly:
https://github.com/JuliaPlots/Makie.jl/blob/master/src/basic_recipes/poly.jl#L130

@edljk
Copy link
Contributor Author

edljk commented Jan 9, 2022

Not sure it is a related issue.
Since update 0.16.1, the following instructions produce a strange error

using Makie, GLMakie

y, z, sizes = rand(10), rand(10), 30 * rand(10)
f = Figure()
Axis(f[1, 1])
scatter!(y, z,  markersize = sizes, marker = :circle)

ERROR: UndefVarError: x not defined
Stacktrace:
  [1] (::GLMakie.GLVisualize.var"#51#52"{Vec{2, Float32}})(xs::Vec{2, Float32})
    @ GLMakie.GLVisualize $HOME/.julia/packages/GLMakie/oDJ8D/src/GLVisualize/visualize/particles.jl:292
  [2] iterate
    @ ./generator.jl:47 [inlined]
  [3] _collect(c::Vector{Vec{2, Float32}}, itr::Base.Generator{Vector{Vec{2, Float32}}, GLMakie.GLVisualize.var"#51#52"{Vec{2, Float32}}}, #unused#::Base.EltypeUnknown, isz::Base.HasShape{1})
    @ Base ./array.jl:744
  [4] collect_similar
...

Sorry not to be able to investigate further, thanks.

@edljk
Copy link
Contributor Author

edljk commented Jan 9, 2022

It seems that this line

particles.jl

should be replaced by

map(x -> f * x, xs)

@edljk
Copy link
Contributor Author

edljk commented Jan 9, 2022

Btw, the original problem does not seem to be resolved in Makie 0.16.1

using GeometryBasics, GLMakie
f = Figure(); Axis(f[1, 1])
P = [Polygon([Point2(rand(), rand()) for _ = 1:3]) for k = 1:2]
poly!(P, color = [:red, :green], strokecolor = [:blue, :red], strokewidth = 1)

ERROR: Buffer vertex does not have the same length as the other buffers.
	color has length 2
	vertex has length 9
	valid_vertex has length 9
...

@ffreyer
Copy link
Collaborator

ffreyer commented Jan 9, 2022

It seems that this line

particles.jl

should be replaced by

map(x -> f * x, xs)

Oh good catch! Do you want to make a pr for this?

@edljk edljk mentioned this issue Jan 9, 2022
7 tasks
SimonDanisch added a commit that referenced this issue Jan 9, 2022
SimonDanisch added a commit that referenced this issue Jan 9, 2022
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

Successfully merging a pull request may close this issue.

3 participants