-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This eliminates the macro-based constructor generation. Instead, this uses the abstract types to provide the constructor interfaces. This also allows grays to be used in the constructor argument in more cases.
- Loading branch information
Showing
10 changed files
with
310 additions
and
270 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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
module DummyTypes | ||
|
||
using ColorTypes | ||
|
||
export C2, C2A, C4, AC4 | ||
export AnaglyphColor, CMYK, ACMYK | ||
|
||
struct C2{T <: Real} <: Color{T,2} | ||
c1::T | ||
c2::T | ||
end | ||
|
||
struct C2A{T} <: ColorAlpha{C2{T},T,3} # T should be <: Real | ||
c1::T | ||
c2::T | ||
alpha::T | ||
end | ||
ColorTypes.coloralpha(::Type{<:C2}) = C2A | ||
|
||
struct C4{T <: Real} <: Color{T,4} | ||
c1::T | ||
c2::T | ||
c3::T | ||
c4::T | ||
end | ||
ColorTypes.eltype_default(::Type{<:C4}) = Int16 | ||
|
||
struct AC4{T <: Real} <: AlphaColor{C4{T},T,5} | ||
alpha::T | ||
c1::T | ||
c2::T | ||
c3::T | ||
c4::T | ||
AC4{T}(c1::T, c2::T, c3::T, c4::T, alpha::T=oneunit(T)) where {T} = new{T}(alpha, c1, c2, c3, c4) | ||
end | ||
ColorTypes.alphacolor(::Type{<:C4}) = AC4 | ||
ColorTypes.eltype_default(::Type{<:AC4}) = Int16 | ||
|
||
# dummy type for testing 2-component color | ||
struct AnaglyphColor{T} <: Color{T,2} # not `TransparentGray` | ||
left::T | ||
right::T | ||
end | ||
|
||
# dummy type for testing 4-component color | ||
struct CMYK{T <: Fractional} <: Color{T,4} # not `Transparent3` | ||
c::T | ||
m::T | ||
y::T | ||
k::T | ||
CMYK{T}(c::T, m::T, y::T, k::T) where {T} = new{T}(c, m, y, k) | ||
end | ||
|
||
# dummy type for testing 5-component color | ||
struct ACMYK{T <: Fractional} <: AlphaColor{CMYK{T},T,5} | ||
alpha::T | ||
c::T | ||
m::T | ||
y::T | ||
k::T | ||
ACMYK{T}(c::T, m::T, y::T, k::T, alpha::T=oneunit(T)) where {T} = new{T}(alpha, c, m, y, k) | ||
end | ||
|
||
end # module |
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
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