Skip to content
This repository has been archived by the owner on Jul 13, 2021. It is now read-only.

WIP: allow to use arguments in default theme #40

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/interfaces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ const Theme = Attributes

Theme(x::AbstractPlot) = x.attributes

default_theme(scene, T) = Attributes()
default_theme(scene, T; kwargs...) = Attributes()

function default_theme(scene)
function default_theme(scene; kwargs...)
light = Vec3f0[Vec3f0(1.0,1.0,1.0), Vec3f0(0.1,0.1,0.1), Vec3f0(0.9,0.9,0.9), Vec3f0(20,20,20)]
Theme(
color = theme(scene, :color),
Expand Down Expand Up @@ -326,7 +326,7 @@ function (PlotType::Type{<: AbstractPlot{Typ}})(scene::SceneLike, attributes::At
# PlotType
FinalType = Combined{Typ, ArgTyp}

plot_attributes, scene_attributes = merged_get!(()-> default_theme(scene, FinalType), plotsym(FinalType), scene, attributes)
plot_attributes, scene_attributes = merged_get!(()-> default_theme(scene, FinalType; args = to_value(args_converted)), plotsym(FinalType), scene, attributes)
trans = get(plot_attributes, :transformation, automatic)
transformation = if to_value(trans) == automatic
Transformation(scene)
Expand Down
2 changes: 1 addition & 1 deletion src/recipes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ macro recipe(theme_func, Tsym::Symbol, args::Symbol...)
Base.show(io::IO, ::Type{<: $PlotType}) = print(io, $(string(Tsym)), "{...}")
$(default_plot_signatures(funcname, funcname!, PlotType))
Base.@__doc__($funcname)
AbstractPlotting.default_theme(scene, ::Type{<: $PlotType}) = $(esc(theme_func))(scene)
AbstractPlotting.default_theme(scene, ::Type{<: $PlotType}; kwargs...) = $(esc(theme_func))(scene)
export $PlotType, $funcname, $funcname!
end
if !isempty(args)
Expand Down