Skip to content

Commit

Permalink
Added :print option to color
Browse files Browse the repository at this point in the history
  • Loading branch information
eprovst committed Sep 20, 2023
1 parent 1884a49 commit 4fa8289
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
2 changes: 2 additions & 0 deletions DomainColoringToy/src/DomainColoringToy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ to ``\\frac{2\\pi}{3}``, cyan to ``\\pi``, blue to
- **`color`** toggles coloring of the phase angle. Can also be set to
either the name of, or a `ColorScheme`, or a function `θ -> Color`.
If set to `:print` a desaturated version of the default is used.
- **`all`** is a shortcut for `abs = true`, `grid = true`, and
`color = true`.
Expand Down Expand Up @@ -386,6 +387,7 @@ If none of the below options are set, the plot defaults to `rect = true`.
- **`color`** toggles coloring of the phase angle. Can also be set to
either the name of, or a `ColorScheme`, or a function `θ -> Color`.
If set to `:print` a desaturated version of the default is used.
- **`box`** if set to `(a, b, s)` shades the area where the output is
within the box `a` and `b` in the color `s`. Can also be a list of
Expand Down
4 changes: 2 additions & 2 deletions docs/src/usage/custom.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ A shader function (a map from complex numbers to colors) is applied to
the input function `f` applied to some grid.

The specification of this grid, the `pixels` option, the axis limiting
and the interface with Makie are identical throughout DomainColoring and
stem from the internal macro `@shadedplot`.
and the interface with Plots and Makie are identical throughout
DomainColoring and stem from the internal macro `@shadedplot`.

An example makes this clear. Let's say we want a plot where integer grid
lines of the real part and the imaginary part in different colors. A
Expand Down
13 changes: 12 additions & 1 deletion docs/src/usage/general.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,13 +274,24 @@ can add a discretization effect:
```@example
using CairoMakie, DomainColoring # hide
discrangle(θ) = DomainColoring.labsweep(π/10 * floor(10/π * θ))
domaincolor(tan, color=discrangle)
domaincolor(tan, π/2, color=discrangle)
resize!(current_figure(), 620, 600) #hide
save("dsccolor.png", current_figure()) # hide
nothing # hide
```
![](dsccolor.png)

There is also a `:print` option that uses a desaturated version of the
default color scheme, which is more suitable for consumer grade printers.
```@example
using CairoMakie, DomainColoring # hide
domaincolor(tan, π/2, color=:print)
resize!(current_figure(), 620, 600) #hide
save("dscprint.png", current_figure()) # hide
nothing # hide
```
![](dscprint.png)

Finally, if no coloring of the phase is wanted, we can set
`color = false`.

Expand Down
2 changes: 2 additions & 0 deletions src/plots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ to ``\\frac{2\\pi}{3}``, cyan to ``\\pi``, blue to
- **`color`** toggles coloring of the phase angle. Can also be set to
either the name of, or a `ColorScheme`, or a function `θ -> Color`.
If set to `:print` a desaturated version of the default is used.
- **`all`** is a shortcut for `abs = true`, `grid = true`, and
`color = true`.
Expand Down Expand Up @@ -265,6 +266,7 @@ If none of the below options are set, the plot defaults to `rect = true`.
- **`color`** toggles coloring of the phase angle. Can also be set to
either the name of, or a `ColorScheme`, or a function `θ -> Color`.
If set to `:print` a desaturated version of the default is used.
- **`box`** if set to `(a, b, s)` shades the area where the output is
within the box `a` and `b` in the color `s`. Can also be a list of
Expand Down
5 changes: 4 additions & 1 deletion src/shaders.jl
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,10 @@ _color_angle(w, arg::Function) = arg(mod(angle(w), 2π))
_color_angle(w, arg::ColorScheme) = get(arg, mod(angle(w) / 2π, 1))

function _color_angle(w, arg::Symbol)
if arg == :CBC1 || arg == :pd
if arg == :print
c = labsweep(angle(w))
Lab(c.l + 5, .7c.a, .7c.b)
elseif arg == :CBC1 || arg == :pd
get(ColorSchemes.cyclic_protanopic_deuteranopic_bwyk_16_96_c31_n256,
mod(-angle(w) / 2π + .5, 1))
elseif arg == :CBTC1 || arg == :t
Expand Down

0 comments on commit 4fa8289

Please sign in to comment.