Skip to content
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

Modify error messages in constructors #256

Merged
merged 1 commit into from
May 29, 2021

Conversation

kimikage
Copy link
Collaborator

@kimikage kimikage commented May 27, 2021

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.

@kimikage kimikage added this to the 0.12 milestone May 27, 2021
@kimikage kimikage mentioned this pull request May 27, 2021
19 tasks
@codecov
Copy link

codecov bot commented May 27, 2021

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%) ⬇️
src/types.jl 91.95% <100.00%> (+0.57%) ⬆️

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 kimikage force-pushed the ctor_error_message branch from fa0dad7 to 1a7e568 Compare May 28, 2021 02:43
@kimikage kimikage force-pushed the ctor_error_message branch from 1a7e568 to 0d9ab7b Compare May 28, 2021 05:42
@kimikage kimikage merged commit 754a397 into JuliaGraphics:master May 29, 2021
@kimikage kimikage deleted the ctor_error_message branch May 29, 2021 17:24
@kimikage
Copy link
Collaborator Author

FYI, as for #187 (comment), 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.

johnnychen94 added a commit that referenced this pull request May 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RFC] Warn about the normalization first in error messages of RGB constructors
1 participant