Skip to content

Commit

Permalink
feat: A bunch of colors
Browse files Browse the repository at this point in the history
  • Loading branch information
musoke committed May 20, 2024
1 parent 3b97abf commit 5518003
Show file tree
Hide file tree
Showing 12 changed files with 423 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
/Manifest.toml
/docs/Manifest.toml
/docs/build/

/docs/src/examples/*.md
6 changes: 6 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,11 @@ uuid = "61d02e3d-8de9-45ce-a87b-73174b99cb55"
authors = ["Nathan Musoke <nathan.musoke@gmail.com> and contributors"]
version = "1.0.0-DEV"

[deps]
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"

[compat]
Colors = "0.12.11"
PrecompileTools = "1.2.1"
julia = "1.10"
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# PrideColorSchemes

[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://musoke.github.io/PrideColorSchemes.jl/stable/)
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://musoke.github.io/PrideColorSchemes.jl/dev/)
[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://musoke.github.io/PrideColorSchemes.jl/stable/)
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://musoke.github.io/PrideColorSchemes.jl/dev/)
[![Build Status](https://github.com/musoke/PrideColorSchemes.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/musoke/PrideColorSchemes.jl/actions/workflows/CI.yml?query=branch%3Amain)
[![Build Status](https://app.travis-ci.com/musoke/PrideColorSchemes.jl.svg?branch=main)](https://app.travis-ci.com/musoke/PrideColorSchemes.jl)
[![Coverage](https://codecov.io/gh/musoke/PrideColorSchemes.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/musoke/PrideColorSchemes.jl)

## Citing
Expand Down
6 changes: 6 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
[deps]
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
DocumenterInterLinks = "d12716ef-a0f6-4df4-a9f1-a5a34e75c656"
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
PrideColorSchemes = "61d02e3d-8de9-45ce-a87b-73174b99cb55"

[compat]
Literate = "2.18"
21 changes: 20 additions & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
using PrideColorSchemes
using Documenter
using Literate

# Use Literate.jl to convert ../examples/*.jl to markdown files included in
# docs/src/examples
LITERATE_INPUT = joinpath(@__DIR__, "src", "examples")
LITERATE_OUTPUT = joinpath(@__DIR__, "src", "examples")

for (root, _, files) walkdir(LITERATE_INPUT), file files
# ignore non julia files
splitext(file)[2] == ".jl" || continue
# full path to a literate script
ipath = joinpath(root, file)
# generated output path
opath = splitdir(replace(ipath, LITERATE_INPUT=>LITERATE_OUTPUT))[1]
# generate the markdown file calling Literate
Literate.markdown(ipath, opath)
end

DocMeta.setdocmeta!(
PrideColorSchemes,
Expand All @@ -17,7 +34,9 @@ makedocs(;
edit_link = "main",
assets = String[],
),
pages = ["Home" => "index.md"],
pages = ["Home" => "index.md",
"Examples" => Any["Makie.jl" => "examples/makie.md"],
],
)

deploydocs(; repo = "github.com/musoke/PrideColorSchemes.jl", devbranch = "main")
31 changes: 31 additions & 0 deletions docs/src/examples/makie.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# # Use with Makie.jl

using CairoMakie
using PrideColorSchemes

# The palettes defined in [`PROUD_PALETTES`](@ref) can be used to set colors in
#
# [Makie](https://github.com/MakieOrg/Makie.jl) plots.
#
# For example,

x = 0:1e-2:2π
lines(x, cos, color = PROUD_PALETTES[:rainbow][1])
lines!(x, sin, color = PROUD_PALETTES[:rainbow][2])

current_figure()

# They can also be used to set the palette for a whole plot.
# This can be simpler than setting colors one plot at a time.

p = PROUD_PALETTES[:rainbow]

fig = Figure()
ax = Axis(fig[1, 1], palette = (patchcolor = p,))

for (i, _) in enumerate(p)
y = @. sin(x) + i - 1
band!(ax, x, y, y .+ 1,)
end

fig
3 changes: 3 additions & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ CurrentModule = PrideColorSchemes

Documentation for [PrideColorSchemes](https://github.com/musoke/PrideColorSchemes.jl).


# API

```@index
```

Expand Down
83 changes: 82 additions & 1 deletion src/PrideColorSchemes.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,86 @@
"""
Colour palettes
For flags composed of horizontal stripes, the colors in each array are ordered from bottom to top.
This results in color bars with an intuitive order.
"""
module PrideColorSchemes

# Write your package code here.
import Colors
using Colors: @colorant_str

export PROUD_PALETTES

const bi = [colorant"#0038A8", colorant"#9B4F96", colorant"#D60270"]

const pan = [colorant"#21B1FF", colorant"#FFD800", colorant"#FF218C"]

pride6 = [
colorant"#750787",
colorant"#004DFF",
colorant"#008026",
colorant"#FFED00",
colorant"#FF8C00",
colorant"#E40303",
]

pride8 = [
colorant"violet",
colorant"indigo",
colorant"turquoise",
colorant"green",
colorant"yellow",
colorant"orange",
colorant"red",
colorant"pink",
]

pride7 = pride8[begin:end-1]

trans = [
colorant"#5BCEFA",
colorant"#F5A9B8",
colorant"#FFFFFF",
colorant"#F5A9B8",
colorant"#5BCEFA",
]

"""
const PROUD_PALETTES::Dict{Symbol,Vector{Colors.RGB}}
`Dict` of RGB vectors.
# Examples
```jldoctest
julia> using PrideColorSchemes
julia> PROUD_PALETTES[:pride]
6-element Array{RGB,1} with eltype ColorTypes.RGB:
RGB{N0f8}(0.459,0.027,0.529)
RGB{N0f8}(0.0,0.302,1.0)
RGB{N0f8}(0.0,0.502,0.149)
RGB{N0f8}(1.0,0.929,0.0)
RGB{N0f8}(1.0,0.549,0.0)
RGB{N0f8}(0.894,0.012,0.012)
```
"""
const PROUD_PALETTES = Dict{Symbol,Vector{Colors.RGB}}(
:bi => bi,
:nonbinary =>
[colorant"#2C2C2C", colorant"#9C59D1", colorant"#FFFFFF", colorant"#FFF430"],
:pan => pan,
:pride => pride6,
:pride6 => pride6,
:pride7 => pride7,
:pride8 => pride8,
:pride_progress =>
[pride6..., trans[begin:begin+3]..., colorant"brown", colorant"black"],
:trans => trans,
:rainbow => pride6,
)

include("precompile.jl")

end
7 changes: 7 additions & 0 deletions src/precompile.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import PrecompileTools

PrecompileTools.@compile_workload begin
for c in PROUD_PALETTES[:bi]
display(c)
end
end
Loading

0 comments on commit 5518003

Please sign in to comment.