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

[RFC] Redesign color constructors #197

Merged
merged 1 commit into from
Jun 27, 2021

Conversation

kimikage
Copy link
Collaborator

@kimikage kimikage commented Jun 23, 2020

This eliminates the macro-based constructor generation. This helps add user-defined types (cf. #179).
This also allows grays to be used in the constructor argument in more cases (cf. #177 (comment)).

Fixes #156

@kimikage kimikage marked this pull request as draft June 23, 2020 13:30
@codecov
Copy link

codecov bot commented Jun 23, 2020

Codecov Report

Merging #197 (2a86a25) into master (9e2550f) will increase coverage by 0.94%.
The diff coverage is 94.17%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #197      +/-   ##
==========================================
+ Coverage   82.81%   83.76%   +0.94%     
==========================================
  Files           8        8              
  Lines         745      733      -12     
==========================================
- Hits          617      614       -3     
+ Misses        128      119       -9     
Impacted Files Coverage Δ
src/types.jl 96.70% <93.87%> (+4.39%) ⬆️
src/conversions.jl 85.54% <100.00%> (-0.18%) ⬇️
src/traits.jl 98.90% <100.00%> (+0.01%) ⬆️

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 9e2550f...2a86a25. Read the comment docs.

@timholy
Copy link
Member

timholy commented Jun 23, 2020

Took a glance (didn't review since it's marked Draft), this looks quite promising!

@kimikage kimikage mentioned this pull request Feb 25, 2021
@kimikage kimikage force-pushed the redesign_ctor branch 4 times, most recently from 5ec3662 to 6533522 Compare March 6, 2021 07:00
@kimikage
Copy link
Collaborator Author

kimikage commented Mar 6, 2021

I made the ambiguity resolution simpler than when this PR was originally submitted. Now it works without explicitly writing constructors. This means that there is no ambiguity with the default constructors.

@kimikage kimikage force-pushed the redesign_ctor branch 5 times, most recently from 08d6143 to e4977cf Compare March 10, 2021 09:28
@johnnychen94
Copy link
Member

Simplifying the macro looks promising to me. Just a simple loading time test on this that might worth noting. (No objection on this PR)

julia> versioninfo()
Julia Version 1.6.0-rc1
Commit a58bdd9010 (2021-02-06 15:49 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin18.7.0)
  CPU: Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, skylake)

julia> @time using ColorTypes
  # master:  0.266565 seconds (506.97 k allocations: 37.554 MiB, 5.03% gc time, 18.80% compilation time)
  # PR 0.308603 seconds (646.04 k allocations: 50.311 MiB, 4.10% gc time, 13.67% compilation time)

@kimikage
Copy link
Collaborator Author

I'm not going to make any performance related tweaks in this PR unless there is a very large regression.
This PR is not an end goal, but a means to solve a problem. Subsequent changes may improve the performance, or conversely, may significantly degrade it.:smile:

@kimikage kimikage added this to the 0.12 milestone Apr 8, 2021
@kimikage kimikage mentioned this pull request May 6, 2021
19 tasks
@kimikage kimikage marked this pull request as ready for review May 30, 2021 14:05
@kimikage kimikage changed the title [RFC/WIP] Redesign color constructors [RFC] Redesign color constructors May 30, 2021
@kimikage kimikage marked this pull request as draft May 30, 2021 14:18
@kimikage kimikage marked this pull request as ready for review June 18, 2021 15:24
This eliminates the macro-based constructor generation.
Instead, this uses the abstract types to provide the constructor interfaces.
This also allows grays to be used in the constructor argument in more cases.
@kimikage
Copy link
Collaborator Author

This is a drastic change and I have not been able to fully understand the impact of it.
Although I have changed the commit of this PR many times, the essential points have not changed from the original commit. And I have been experimenting with this change for the past year, and have not encountered any fatal problems.

Well, I've been struggling with the precompilation problems in Colors.jl for over a year now. I don't exactly know the impact of this change, but at least I know this won't have a fatal negative impact.

So, I plan to merge this in around this weekend.

cc: @johnnychen94

@johnnychen94
Copy link
Member

I believe we'll live well with it.

@kimikage
Copy link
Collaborator Author

I'll merge this, but it won't be released for a while yet.
The promotion rules for constructor arguments will be changed before the release of v0.12.

@kimikage kimikage merged commit 87364c4 into JuliaGraphics:master Jun 27, 2021
@kimikage kimikage deleted the redesign_ctor branch June 27, 2021 01:20
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Constructing transparent colors with FixedPoint arguments
3 participants