JuliaGraphics / ColorTypes.jl

Basic color definitions and traits
Other
77 stars 35 forks source link

Modify error messages in constructors #256

Closed kimikage closed 3 years ago

kimikage commented 3 years ago

Closes #242

julia> RGB(255, 0, 0) # This PR
ERROR: ArgumentError: The components of RGB are normalized to the range 0-1,
  but (255, 0, 0) are integers in the range 0-255.
  Consider dividing your input values by 255, for example: RGB{N0f8}(255/255, 0/255, 0/255)
  The component type N0f8 is an 8-bit type representing 256 values from 0 to 1.
  You can also use `reinterpret(N0f8, x % UInt8)` to encode the input into N0f8.
  See the READMEs for FixedPointNumbers and ColorTypes for more information.
codecov[bot] commented 3 years ago

Codecov Report

Merging #256 (0d9ab7b) into master (e674ba9) will increase coverage by 0.01%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #256      +/-   ##
==========================================
+ Coverage   82.87%   82.89%   +0.01%     
==========================================
  Files           8        8              
  Lines         765      754      -11     
==========================================
- Hits          634      625       -9     
+ Misses        131      129       -2     
Impacted Files Coverage Δ
src/conversions.jl 86.66% <ø> (-0.15%) :arrow_down:
src/types.jl 91.95% <100.00%> (+0.57%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update e674ba9...0d9ab7b. Read the comment docs.

kimikage commented 3 years ago

FYI, as for https://github.com/JuliaGraphics/ColorTypes.jl/pull/187#discussion_r445370098, this PR and #255 alone are not a complete solution. (Currently, it is degraded.) Adding generic constructors for AbstractRGB etc in PR #197 will complete it.