-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC] Distinguishing between AbstractGray{T}
and Color{T, 1}
#230
Comments
This is an experimental type (it does not conform to any specific standard). struct Cyanotype{T <: Real} <: Color{T,1}
value::T
end
function Base.convert(::Type{Cout}, c::C) where {Cout <: AbstractRGB, T, C <: Cyanotype{T}}
r = max(1 - 1.5 * c.value, 0)
g = 0.98 - 0.7 * c.value
b = 0.88 - 0.5 * c.value^2
Cout(T(r), T(g), T(b))
end It would be a step forward if ColorTypes.jl and its downstream packages did not misidentify this as a "gray" type. And that's technically easy to do. |
The following are obviously not equal, as they belong to different color spaces. Cyanotype{Float32}(0.5) == Gray{Float32}(0.5) # -> false We treat gray as a real number. 0.5 == Gray{Float32}(0.5) # -> true However, it is debatable whether the following are equal. The following equality relation itself is reasonable, but by accepting it, the transitivity is no longer satisfied. Cyanotype{Float32}(0.5) == 0.5 # -> false? If we don't allow comparisons with real numbers, then defining real(Cyanotype{Float32}(0.5)) # -> 0.5f0? More problematic is the
IMO, only |
Currently,
AbstractGray{T}
is the alias forColor{T, 1}
, but this is a bit weird. (cf. #145 (comment))Here is an extreme example.
Colored tones such as sepia and cyanotype can be prevented from strange reinterpretations by not implementing
gray()
. However, when you implementgray()
for a "gray" scale, strange things happen.That is, color types which have difference between
comp1
andgray
are inherently incompatible withAbstractGray
.IMO,
AbstractGray
should be anabstract type
as well asAbsractRGB
.The text was updated successfully, but these errors were encountered: