Skip to content

Commit

Permalink
Merge pull request #76 from JuliaGraphics/cormullion/cat
Browse files Browse the repository at this point in the history
add concat method
  • Loading branch information
cormullion authored Aug 10, 2021
2 parents f5e1664 + 44fcf98 commit d2601f2
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
17 changes: 16 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
# Changelog

## forthcoming [v3.13] - 2021 July 8
## [v3.14] - 2021 August 10

### Added

- `*` concatenates two colorschemes

## Changed

- dependency on StaticArrays
- norwegian flag colors

### Removed

### Deprecated

## [v3.13] - 2021 July 8

### Added

Expand Down
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ColorSchemes"
uuid = "35d6a980-a343-548e-a6ea-1d62b119f2f4"
authors = ["cormullion <[email protected]>"]
version = "3.13"
authors = ["cormullion", "rafaqz", "gustaphe", "lwabeke", "NHDaly"]
version = "3.14"

[deps]
ColorTypes = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"
Expand Down
9 changes: 8 additions & 1 deletion src/ColorSchemes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ See also `getinverse()`.
"""
module ColorSchemes

import Base.get, Base.reverse
import Base.get, Base.reverse, Base.*

using Colors, ColorTypes, FixedPointNumbers

Expand Down Expand Up @@ -320,4 +320,11 @@ Make a new ColorScheme with the same colors as `cscheme` but in reverse order.
Base.reverse(cscheme::ColorScheme) =
ColorScheme(reverse(cscheme.colors), cscheme.category, cscheme.notes)

"""
cscheme1 * cscheme2
Create new colorscheme by concatenating two colorschemes.
"""
*(cscheme1::ColorScheme, cscheme2::ColorScheme) = ColorScheme(vcat(cscheme1.colors, cscheme2.colors))

end
5 changes: 5 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,9 @@ end
@test isapprox(y3[1], y2[1])
@test isapprox(y3[2], y2[2])
@test isapprox(y3[end], y2[end])

# tests concatenation
l1 = length(monalisa)
l2 = length(monalisa * monalisa)
@test l2 == 2l1
end

0 comments on commit d2601f2

Please sign in to comment.