Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ Note that `norm` has been designed to satisfy **equivalence** of grayscale and R
Effectively, there's a division-by-3 in the `norm(::RGB)` case compared to the Euclidean interpretation of
the RGB vector space.
Equivalence is an important principle for the Colors ecosystem, and violations should be reported as likely bugs.
One violation is `abs2`; see the section below for more detail.
However, the equivalence cannot be straightforwardly extended to transparent colors (e.g., `GrayA` or `ARGB`).
For this reason, some APIs, such as `abs2`, do not support transparent colors.

## Usage

Expand All @@ -53,8 +54,8 @@ using ColorTypes, ColorVectorSpace
```

For the most part, that's it; just by loading `ColorVectorSpace`, most basic mathematical
operations will "just work" on `AbstractRGB`, `AbstractGray`
(`Color{T,1}`), `TransparentRGB`, and `TransparentGray` objects.
operations will "just work" on `AbstractRGB`, `AbstractGray`,
`TransparentRGB`, and `TransparentGray` objects.
(See definitions for the latter inside of `ColorTypes`).

However, there are some additional operations that you may need to distinguish carefully.
Expand Down
12 changes: 6 additions & 6 deletions src/ColorVectorSpace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ function __init__()
if exc.f === dot && length(argtypes) == 2
if any(C -> C <: Union{TransparentGray, TransparentRGB}, argtypes)
print(io, "\n`dot` (or `⋅`) for transparent colors is not supported ")
print(io, "because the normalization is designed for opaque grays and RGBs.")
print(io, "because its normalization is designed for opaque grays and RGBs.")
print(io, "\nYou can use `reducec(+, 0, mapc(float, a) ⊙ mapc(float, b))` ")
print(io, "to get the dot product without normalization.")
end
Expand All @@ -479,11 +479,11 @@ function __init__()
end
elseif exc.f === abs2 && length(argtypes) == 1
C = argtypes[1]
if C <: MathTypes
print(io, "\nIt is ambiguous whether `abs2(::$C)` should return a real number ")
print(io, "or a color object.")
print(io, "\nYou can use `_abs2(c) = mapreducec(v->float(v)^2, +, 0, c)` ")
print(io, "to get the value compatible with ColorVectorSpace v0.8 or earlier.")
if C <: Union{TransparentGray, TransparentRGB}
print(io, "\n`abs2` for transparent colors is not supported ")
print(io, "because its normalization is designed for opaque grays and RGBs.")
print(io, "\nYou can use `mapreducec(v->float(v)^2, +, 0, c)` ")
print(io, "to get the unnormalized sum of squared channel values.")
end
end
end
Expand Down
Loading