Skip to content

Commit

Permalink
Update docs with ColorSchemes example
Browse files Browse the repository at this point in the history
  • Loading branch information
adrhill committed Jun 13, 2021
1 parent 93c8222 commit b342bf9
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions docs/literate/color.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using DitherPunk
using Images
using ColorSchemes
using TestImages

# # Color dithering
Expand All @@ -15,11 +14,7 @@ orange = RGB{Float32}(1, 0.5, 0)
red = RGB{Float32}(1, 0, 0)
blue = RGB{Float32}(0, 0, 1)

rubiks_colors = ColorScheme([white, yellow, green, orange, red, blue])

# Any of the predefined color schemes from
# [ColorSchemes.jl](https://juliagraphics.github.io/ColorSchemes.jl/stable/basics/#Pre-defined-schemes)
# can also be used!
rubiks_colors = [white, yellow, green, orange, red, blue]

# ## Dithering the image
# Now we only have to pick an image
Expand All @@ -33,3 +28,15 @@ d = dither(img, FloydSteinberg(), rubiks_colors)
d = dither(img, ClosestColor(), rubiks_colors)

# For an overview of all error diffusion algorithms, check out the gallery.

# ## Using ColorSchemes.jl
# Predefined color schemes from
# [ColorSchemes.jl](https://juliagraphics.github.io/ColorSchemes.jl/stable/basics/#Pre-defined-schemes)
# can also be used by accessing the color scheme's `colors`.
# Let's use the colors of the Brazilian flag 🇧🇷:
using ColorSchemes
cs = ColorSchemes.flag_br
colors = cs.colors

img = testimage("fabio_color_256")
d = dither(img, Atkinson(), colors)

0 comments on commit b342bf9

Please sign in to comment.