-
-
Notifications
You must be signed in to change notification settings - Fork 295
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
Feature request: Patterned bar plots in CairoMakie #1385
Comments
I'd like to try implementing this, any pointer to a similar PR? |
not sure if relevant, but here's the PR that added this to Plots.jl JuliaPlots/Plots.jl#3107 |
don't think so, this is CairoMakie, for the record, I'd like to know at which point I need to add stuff: julia> using CairoMakie
julia> p = Pattern('/');
julia> save("/tmp/f.png", barplot([1],[2], color=p))
ERROR: CanonicalIndexError: getindex not defined for Makie.LinePattern
Stacktrace:
[1] error_if_canonical_getindex(::IndexCartesian, ::Makie.LinePattern, ::Int64, ::Int64)
@ Base ./abstractarray.jl:1255
[2] getindex
@ ./abstractarray.jl:1235 [inlined]
[3] _getindex
@ ./abstractarray.jl:1281 [inlined]
[4] getindex
@ ./abstractarray.jl:1236 [inlined]
[5] attr_broadcast_getindex(x::Makie.LinePattern, i::Int64)
@ Makie ~/Documents/github/Makie.jl/src/utilities/utilities.jl:164
[6] macro expansion
@ ~/Documents/github/Makie.jl/src/utilities/utilities.jl:199 [inlined]
[7] broadcast_foreach(::CairoMakie.var"#64#65"{CairoMakie.CairoScreen{Cairo.CairoSurfaceBase{UInt32}}}, ::Vector{GeometryBasics.HyperRectangle{2, Float32}}, ::Makie.LinePattern, ::Symbol, ::Int64)
@ Makie ~/Documents/github/Makie.jl/src/utilities/utilities.jl:185
[8] draw_poly(scene::Scene, screen::CairoMakie.CairoScreen{Cairo.CairoSurfaceBase{UInt32}}, poly::Combined{Makie.poly, Tuple{Vector{GeometryBasics.HyperRectangle{2, Float32}}}}, rects::Vector{GeometryBasics.HyperRectangle{2, Float32}})
@ CairoMakie ~/Documents/github/Makie.jl/CairoMakie/src/overrides.jl:84
[9] draw_plot(scene::Scene, screen::CairoMakie.CairoScreen{Cairo.CairoSurfaceBase{UInt32}}, poly::Combined{Makie.poly, Tuple{Vector{GeometryBasics.HyperRectangle{2, Float32}}}})
@ CairoMakie ~/Documents/github/Makie.jl/CairoMakie/src/overrides.jl:13
[10] draw_plot(scene::Scene, screen::CairoMakie.CairoScreen{Cairo.CairoSurfaceBase{UInt32}}, primitive::Combined{Makie.barplot, Tuple{Vector{Point{2, Float32}}}})
@ CairoMakie ~/Documents/github/Makie.jl/CairoMakie/src/infrastructure.jl:255
[11] cairo_draw(screen::CairoMakie.CairoScreen{Cairo.CairoSurfaceBase{UInt32}}, scene::Scene)
@ CairoMakie ~/Documents/github/Makie.jl/CairoMakie/src/infrastructure.jl:192
[12] backend_show(x::CairoMakie.CairoBackend, io::IOContext{IOStream}, #unused#::MIME{Symbol("image/png")}, scene::Scene)
@ CairoMakie ~/Documents/github/Makie.jl/CairoMakie/src/infrastructure.jl:396 |
This should end up in https://github.com/JuliaPlots/Makie.jl/blob/174ef914759b64fdc271a4be26d692b97a5dfa09/CairoMakie/src/primitives.jl#L624 with a LinePattern in |
right now it doesn't call this function at all, I guess one of the function on the current stack trace needs to be replaced by a specialization? |
too hard right now because first we probably want to solve: |
Ah right, poly has it's own backend code. I don't know Cairo well enough to know how these patterns should be implemented, but I don't think you need to worry about that branch. I assume you either need to make a new branch that transforms the pattern into an image and uses it as a repeated texture like opengl, or that Cairo has some version of hatching/patterns natively that you could use |
that branch takes a If this branch were to work correctly, I can use it to draw the inside of the bar plot? or I guess this is not the correct way to go about it. I also didn't find anything in Cairo.jl, but maybe something like https://stackoverflow.com/questions/28755265/cairo-fill-a-polygon-with-a-hatch-pattern |
We could also draw patterns onto a CairoRecordingSurface using Cairo intrinsics (set_line_width, move_to, line_to) and then set those surfaces as the pattern, and simply clip everything which is not within the area by using e.g. If you can get the patterns onto a recording surface I would be more than happy to help with the second part. |
What's the difference between imagesurface and recordingsurface? |
@asinghvi17 I can't find any use of here we're clipping with |
Following up on the discussion from slack, it would be great if similar functionality to this example in GLMakie from 100daysOfMakie could be brought to CairoMakie as well
The text was updated successfully, but these errors were encountered: