-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e3efb21
commit 3e1d8c5
Showing
2 changed files
with
18 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,21 @@ | ||
# expand vector to have length N while keeping the same discrete color gradient | ||
function smooth_color_vector(colorscheme::ColorScheme, N::Integer) | ||
return colorscheme[LinRange(0, 1, N)] | ||
end | ||
|
||
# expand vector to have length N while keeping the same discrete color scheme | ||
function expand_colors(colors::Vector, N::Integer) | ||
L = length(colors) | ||
color_matrix = reshape(repeat(colors, inner=ceil(Int, N/L))[1:N], :, 1) | ||
return color_matrix | ||
end | ||
repeats = ceil(Int, N / L) | ||
total_elements = repeats * L | ||
extra_elements = total_elements - N | ||
|
||
# Distribute the extra elements evenly across the vector | ||
result = Vector{eltype(colors)}() | ||
for i in 1:L | ||
# Calculate the number of repeats for this element | ||
current_repeats = repeats - (i <= extra_elements ? 1 : 0) | ||
append!(result, fill(colors[i], current_repeats)) | ||
end | ||
|
||
function chain_color_vector(chain::Chain, colorscheme::ColorScheme) | ||
#return repeat([colorant"red", colorant"blue"], length(chain) ÷ 2 + 1)[1:length(chain)] | ||
return colorscheme[LinRange(0, 1, length(chain))] | ||
return reshape(result[1:N], :, 1) | ||
end |