JuliaGraphics / ColorVectorSpace.jl

Treat colors as if they are n-vectors for the purposes of arithmetic
Other
36 stars 20 forks source link

[RFC] Return type of scaling for non-parametric colors #169

Open kimikage opened 3 years ago

kimikage commented 3 years ago

This is related to issue #56, #148, and https://github.com/JuliaGraphics/ColorTypes.jl/issues/235.

I think the following return types are reasonable and leave little room for debate.

julia> RGB24(1) * 1.0
RGB{Float64}(1.0,1.0,1.0)

julia> RGB24(1) / 1.0
RGB{Float64}(1.0,1.0,1.0)

julia> RGB24(1) / 1
RGB{Float32}(1.0f0,1.0f0,1.0f0)

The following is a bit controversial, but consistent with the decision in FixedPointNumbers (cf. https://github.com/JuliaMath/FixedPointNumbers.jl/pull/207).

julia> RGB24(1) * 1
RGB{Float32}(1.0f0,1.0f0,1.0f0)

However, I think the following should return RGB24 objects.

julia> RGB24(1) * 1N0f8
RGB{N0f8}(1.0,1.0,1.0)

julia> RGB24(1) / 1N0f8
RGB{N0f8}(1.0,1.0,1.0)

julia> RGB24(1) * true
RGB{N0f8}(1.0,1.0,1.0)

I'm going to fix the obviously problematic cases regarding Bool in PR #153 and release it in v0.9.5. For other cases, I am planning to change them in v0.10 with new one.

kimikage commented 3 years ago

See also: https://github.com/JuliaGraphics/ColorVectorSpace.jl/issues/148#issuecomment-837707515