pybricks/parameters/pb_type_color: add distance method #217
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Exposing the new HCL-bicone color cost function (#104) makes it possible for users to create their own smarter color detection algorithms, for example by adding a hysteresis. This PR adds it as a
color.distance(other_color)
method to aColor
instance. On movehub, this adds 84 bytes. The function nameget_distance_to
would have added 100 bytes.Example use:
Not sure if this would add less firmware size if it were just a module-level function, but to me it makes a bit more sense as a
Color
method.