Skip to content

Commit

Permalink
move poly to MakieCore (#2334)
Browse files Browse the repository at this point in the history
* move poly to MakieCore

* improve poly docs
  • Loading branch information
jw3126 authored Oct 21, 2022
1 parent 9e888f0 commit 853d17e
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 48 deletions.
64 changes: 64 additions & 0 deletions MakieCore/src/basic_plots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -532,3 +532,67 @@ Plots one or multiple texts passed via the `text` keyword.
inspectable = theme(scene, :inspectable)
)
end

"""
poly(vertices, indices; kwargs...)
poly(points; kwargs...)
poly(shape; kwargs...)
poly(mesh; kwargs...)
Plots a polygon based on the arguments given.
When vertices and indices are given, it functions similarly to `mesh`.
When points are given, it draws one polygon that connects all the points in order.
When a shape is given (essentially anything decomposable by `GeometryBasics`), it will plot `decompose(shape)`.
poly(coordinates, connectivity; kwargs...)
Plots polygons, which are defined by
`coordinates` (the coordinates of the vertices) and
`connectivity` (the edges between the vertices).
## Attributes
### Specific to `Poly`
- `lowclip::Union{Nothing, Symbol, <:Colorant} = nothing` sets a color for any value below the colorrange.
- `highclip::Union{Nothing, Symbol, <:Colorant} = nothing` sets a color for any value above the colorrange.
- `strokecolor::Union{Symbol, <:Colorant} = :black` sets the color of the outline around a marker.
- `strokewidth::Real = 0` sets the width of the outline around a marker.
- `linestyle::Union{Nothing, Symbol, Vector} = nothing` sets the pattern of the line (e.g. `:solid`, `:dot`, `:dashdot`)
### Generic
- `visible::Bool = true` sets whether the plot will be rendered or not.
- `overdraw::Bool = false` sets whether the plot will draw over other plots. This specifically means ignoring depth checks in GL backends.
- `transparency::Bool = false` adjusts how the plot deals with transparency. In GLMakie `transparency = true` results in using Order Independent Transparency.
- `fxaa::Bool = true` adjusts whether the plot is rendered with fxaa (anti-aliasing).
- `inspectable::Bool = true` sets whether this plot should be seen by `DataInspector`.
- `color` is set by the plot.
- `colormap::Union{Symbol, Vector{<:Colorant}} = [:black, :white` sets the colormap that is sampled for numeric `color`s.
- `colorrange::Tuple{<:Real, <:Real}` sets the values representing the start and end points of `colormap`.
- `nan_color::Union{Symbol, <:Colorant} = RGBAf(0,0,0,0)` sets a replacement color for `color = NaN`.
- `space::Symbol = :data` sets the transformation space for the position of the image. See `Makie.spaces()` for possible inputs.
- `cycle::Vector{Symbol} = [:color => :patchcolor]` sets which attributes to cycle when creating multiple plots.
- `shading = false` enables lighting.
"""
@recipe(Poly) do scene
Attributes(;
color = theme(scene, :patchcolor),
visible = theme(scene, :visible),
strokecolor = theme(scene, :patchstrokecolor),
colormap = theme(scene, :colormap),
colorrange = automatic,
lowclip = automatic,
highclip = automatic,
nan_color = :transparent,
strokewidth = theme(scene, :patchstrokewidth),
shading = false,
fxaa = true,
linestyle = nothing,
overdraw = false,
transparency = false,
cycle = [:color => :patchcolor],
inspectable = theme(scene, :inspectable),
space = :data
)
end
12 changes: 6 additions & 6 deletions src/Makie.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ import Base: getindex, setindex!, push!, append!, parent, get, get!, delete!, ha
using Observables: listeners, to_value, notify

using MakieCore: SceneLike, MakieScreen, ScenePlot, AbstractScene, AbstractPlot, Transformable, Attributes, Combined, Theme, Plot
using MakieCore: Heatmap, Image, Lines, LineSegments, Mesh, MeshScatter, Scatter, Surface, Text, Volume
using MakieCore: Heatmap, Image, Lines, LineSegments, Mesh, MeshScatter, Poly, Scatter, Surface, Text, Volume
using MakieCore: ConversionTrait, NoConversion, PointBased, SurfaceLike, ContinuousSurface, DiscreteSurface, VolumeLike
using MakieCore: Key, @key_str, Automatic, automatic, @recipe
using MakieCore: Pixel, px, Unit, Billboard
using MakieCore: not_implemented_for
import MakieCore: plot, plot!, theme, plotfunc, plottype, merge_attributes!, calculated_attributes!,
get_attribute, plotsym, plotkey, attributes, used_attributes
import MakieCore: heatmap, image, lines, linesegments, mesh, meshscatter, scatter, surface, text, volume
import MakieCore: heatmap!, image!, lines!, linesegments!, mesh!, meshscatter!, scatter!, surface!, text!, volume!
import MakieCore: heatmap, image, lines, linesegments, mesh, meshscatter, poly, scatter, surface, text, volume
import MakieCore: heatmap!, image!, lines!, linesegments!, mesh!, meshscatter!, poly!, scatter!, surface!, text!, volume!
import MakieCore: convert_arguments, convert_attribute, default_theme, conversion_trait

export @L_str
Expand Down Expand Up @@ -329,9 +329,9 @@ include("basic_recipes/text.jl")
include("basic_recipes/raincloud.jl")
include("deprecated.jl")

export Heatmap, Image, Lines, LineSegments, Mesh, MeshScatter, Scatter, Surface, Text, Volume
export heatmap, image, lines, linesegments, mesh, meshscatter, scatter, surface, text, volume
export heatmap!, image!, lines!, linesegments!, mesh!, meshscatter!, scatter!, surface!, text!, volume!
export Heatmap, Image, Lines, LineSegments, Mesh, MeshScatter, Poly, Scatter, Surface, Text, Volume
export heatmap, image, lines, linesegments, mesh, meshscatter, poly, scatter, surface, text, volume
export heatmap!, image!, lines!, linesegments!, mesh!, meshscatter!, poly!, scatter!, surface!, text!, volume!

export PointLight, EnvironmentLight, AmbientLight, SSAO

Expand Down
42 changes: 0 additions & 42 deletions src/basic_recipes/poly.jl
Original file line number Diff line number Diff line change
@@ -1,45 +1,3 @@
"""
poly(vertices, indices; kwargs...)
poly(points; kwargs...)
poly(shape; kwargs...)
poly(mesh; kwargs...)
Plots a polygon based on the arguments given.
When vertices and indices are given, it functions similarly to `mesh`.
When points are given, it draws one polygon that connects all the points in order.
When a shape is given (essentially anything decomposable by `GeometryBasics`), it will plot `decompose(shape)`.
poly(coordinates, connectivity; kwargs...)
Plots polygons, which are defined by
`coordinates` (the coordinates of the vertices) and
`connectivity` (the edges between the vertices).
## Attributes
$(ATTRIBUTES)
"""
@recipe(Poly) do scene
Attributes(;
color = theme(scene, :patchcolor),
visible = theme(scene, :visible),
strokecolor = theme(scene, :patchstrokecolor),
colormap = theme(scene, :colormap),
colorrange = automatic,
lowclip = automatic,
highclip = automatic,
nan_color = :transparent,
strokewidth = theme(scene, :patchstrokewidth),
shading = false,
fxaa = true,
linestyle = nothing,
overdraw = false,
transparency = false,
cycle = [:color => :patchcolor],
inspectable = theme(scene, :inspectable),
space = :data
)
end

const PolyElements = Union{Polygon, MultiPolygon, Circle, Rect, AbstractMesh, VecTypes, AbstractVector{<:VecTypes}}

convert_arguments(::Type{<: Poly}, v::AbstractVector{<: PolyElements}) = (v,)
Expand Down

0 comments on commit 853d17e

Please sign in to comment.