Repository navigation
Conversation
|
@tmcw, thanks for your PR! By analyzing this pull request, we identified @jfirebaugh and @yhahn to be potential reviewers. |
|
I think eventually we'll need a set of color-space-specific classes -- |
78ea832 to
e0f00fe
Compare
|
@jfirebaugh want to take a look at the code and the approach? This now passes unit tests locally, but there are at least three ways I could implement the to&from RGB/LCH conversion, and I chose the one I could get to work, not necessarily the most idiomatic. |
jfirebaugh
left a comment
There was a problem hiding this comment.
Types look good, just a few small nits.
PropertyEvaluator<Color>::operator() duplicates a lot of PropertyEvaluator<T>::operator() but I imagine that's something you're still working on.
|
|
||
| using EnumType = uint32_t; | ||
|
|
||
| enum class ColorSpace : EnumType { |
There was a problem hiding this comment.
Delete EnumType; let the compiler choose.
| explicit Function(Stops stops_, float base_) | ||
| : base(base_), stops(std::move(stops_)) {} | ||
|
|
||
| explicit Function(Stops stops_, float base_, ColorSpace colorSpace_) |
There was a problem hiding this comment.
Combine with the previous constructor using a default parameter (ColorSpace colorSpace_ = ColorSpace::RGB).
| float b = 0.0f; | ||
| float a = 0.0f; | ||
|
|
||
| ColorLAB to_lab(); |
| float a = 0.0f; | ||
|
|
||
| ColorLAB to_lab(); | ||
| ColorHCL to_hcl(); |
| static constexpr Color black() { return { 0.0f, 0.0f, 0.0f, 1.0f }; }; | ||
| static constexpr Color white() { return { 1.0f, 1.0f, 1.0f, 1.0f }; }; | ||
|
|
||
| static Color from_lab(const ColorLAB); |
There was a problem hiding this comment.
fromLAB/fromHCL
Parameter type should be const ColorLAB&
This is just a start so I can get an idea from the C++ illuminati about whether it's the right direction. Approach here is * Since colors are arrays in JS and objects in C++, instead of a rgbToLab() method, there's a to_lab() method on the color object
* Default parameter for colorSpace in Function * to_lab -> toLab, to_hcl -> toHCL, from_lab -> fromLAB, from_hcl -> fromHCL * Pass colors by reference, not value * Don't explicitly choose a type for the ColorSpace enum
f405e5e to
7e264d1
Compare
|
Looks like the changes requested in #6442 (review) have been implemented. @tmcw, would you mind rebasing this PR and resolving the conflicts? |
|
This requires some non-trival rework now that data-driven properties have landed. |
This is just a start so I can get an idea from the C++ illuminati
about whether it's the right direction. Approach here is
rgbToLab() method, there's a to_lab() method on the color object
Connected to mapbox/mapbox-gl-js#3245 - the GL JS side