{"id":27767947,"url":"https://github.com/bernaferrari/hsluv-dart","last_synced_at":"2025-04-29T19:56:17.687Z","repository":{"id":56832563,"uuid":"224734226","full_name":"bernaferrari/hsluv-dart","owner":"bernaferrari","description":"Dart port of HSLuv, a human-friendly alternative to HSL based on human experiments.","archived":false,"fork":false,"pushed_at":"2023-03-03T16:16:42.000Z","size":33253,"stargazers_count":51,"open_issues_count":2,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-29T19:56:11.628Z","etag":null,"topics":["color-picker","flutter","hsl","hsluv","hsv","rgb"],"latest_commit_sha":null,"homepage":"","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bernaferrari.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-11-28T21:41:53.000Z","updated_at":"2024-01-31T12:03:39.000Z","dependencies_parsed_at":"2024-12-31T10:02:57.313Z","dependency_job_id":"db179788-e7de-4488-8066-d450b6fb4d5e","html_url":"https://github.com/bernaferrari/hsluv-dart","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bernaferrari%2Fhsluv-dart","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bernaferrari%2Fhsluv-dart/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bernaferrari%2Fhsluv-dart/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bernaferrari%2Fhsluv-dart/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bernaferrari","download_url":"https://codeload.github.com/bernaferrari/hsluv-dart/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251574671,"owners_count":21611387,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["color-picker","flutter","hsl","hsluv","hsv","rgb"],"created_at":"2025-04-29T19:56:16.946Z","updated_at":"2025-04-29T19:56:17.677Z","avatar_url":"https://github.com/bernaferrari.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Logo of HSLuv for Dart \u0026 Flutter](assets/logo.png)\n\n# HSLuv for Dart \u0026 Flutter\n\nDart port of [HSLuv](https://www.hsluv.org) (revision 4) with a [Flutter sample](example). This was a direct conversion of the [reference implementation](https://github.com/hsluv/hsluv/tree/main/haxe).\nThe sample is available as a web app.\n\n\u003ca href=\"https://bernaferrari.github.io/hsluv-dart/\"\u003e\u003cimg src=\"https://github.com/bernaferrari/hsluv-dart/raw/main/assets/try_here.png\" height=\"50\"/\u003e\u003c/a\u003e\n\n[\u003cp align=\"center\"\u003e\u003cimg src=\"https://github.com/bernaferrari/hsluv-dart/raw/main/assets/sample_app.jpg?raw=true\" width=\"400\"/\u003e\u003c/p\u003e](example)\n\n\u003e HSLuv is a human-friendly alternative to HSL.\n\nIt is like HSL, but color only gets perceptually lighter or darker when the Lightness attribute changes.\nIn HSL, if you go from a green hue to a red one, there will be big differences in the perceived lightness. In HSLuv, almost none.\n\nIf you want to see for yourself, check the [sample app](example) and open the Color Compare screen. Contrast \"only\" changes when Lightness changes.\nWhen Hue or Saturation attributes change, there might be minimal changes in contrast (in the 0.01 range), but nothing perceivable and certainly better than HSV/HSL.\n\nThis is specially useful when [building acessible color systems](https://stripe.com/blog/accessible-color-systems).\nFor more information, check: [Designing Color Spaces](https://programmingdesignsystems.com/color/perceptually-uniform-color-spaces/index.html) / [Wikipedia article](https://en.wikipedia.org/wiki/HSLuv)\n\n## Usage\n\nIn the `pubspec.yaml` of your flutter project, add the following dependency:\n\n[![pub package](https://img.shields.io/pub/v/hsluv.svg)](https://pub.dev/packages/hsluv)\n\n```yaml\ndependencies:\n  hsluv: ^VERSION\n```\n\nIn your project you can use it in two different ways, either low level (directly accessing values as a `list\u003cdouble\u003e`) or high level (similar to [HSLColor](https://api.flutter.dev/flutter/painting/HSLColor-class.html)).\n`HSLuvColor` is easier to use, but has less flexibility than a raw list.\n\n```dart\nimport 'package:hsluv/hsluv.dart';\n\nvoid main() {\n\n  // Low level usage.\n  final List\u003cdouble\u003e hsluvLow = Hsluv.rgbToHsluv([0.2,0.5,0.7]);\n  print(Hsluv.hsluvToHex(hsluvLow));\n\n  // High level usage.\n  final hsluvFromColor = HSLuvColor.fromColor(Colors(0xffef3e4a));\n  print(hsluvFromColor.toString());\n\n  final hsluvFromHSL = HSLuvColor.fromHSL(300, 70, 60);\n  print(hsluvFromHSL.toString());\n}\n```\n\n[\u003cp align=\"center\"\u003e\u003cimg src=\"https://github.com/bernaferrari/hsluv-dart/raw/main/assets/hsv_vs_hsluv.gif?raw=true\" width=\"300\"/\u003e\u003c/p\u003e](example)\n\n[Sample app](example) showing HSV (top) vs HSLuv (bottom). See how the perceived lightness changes as the hue slider moves.\n\n### Color values ranges\n\n- RGB values are ranging in [0...1]\n- HSLuv and HPLuv values have different ranging for their components\n  - H : [0...360]\n  - S and L : [0...100]\n- LUV has different ranging for their components\n  - L\\* : [0...100]\n  - u* and v* : [-100...100]\n- LCh has different ranging for their components\n  - L\\* : [0...100]\n  - C* : [0...?] Upper bound varies depending on L* and H\\*\n  - H\\* : [0...360]\n- XYZ values are ranging in [0...1]\n\n**Important**: Flutter's HSLColor has lightness and saturation ranging from 0 to 1.0. HSLuv uses 0 to 100.\nThere is a class, called HSInterColor in the [sample](example) that tries to mitigate this.\n\n### API functions\n\n#### Note\n\nThe passing/returning values, when not `String` are `List\u003cdouble\u003e` containing each component of the given color space/system in the name's order :\n\n- RGB : [red, blue, green]\n- XYZ : [X, Y, Z]\n- LCH : [L, C, H]\n- LUV : [L, u, v]\n- HSLuv/HPLuv : [H, S, L]\n\n#### Function listing\n\n- `xyzToRgb(List\u003cdouble\u003e tuple)`\n- `rgbToXyz(List\u003cdouble\u003e tuple)`\n- `xyzToLuv(List\u003cdouble\u003e tuple)`\n- `luvToXyz(List\u003cdouble\u003e tuple)`\n- `luvToLch(List\u003cdouble\u003e tuple)`\n- `lchToLuv(List\u003cdouble\u003e tuple)`\n- `hsluvToLch(List\u003cdouble\u003e tuple)`\n- `lchToHsluv(List\u003cdouble\u003e tuple)`\n- `hpluvToLch(List\u003cdouble\u003e tuple)`\n- `lchToHpluv(List\u003cdouble\u003e tuple)`\n- `lchToRgb(List\u003cdouble\u003e tuple)`\n- `rgbToLch(List\u003cdouble\u003e tuple)`\n- `hsluvToRgb(List\u003cdouble\u003e tuple)`\n- `rgbToHsluv(List\u003cdouble\u003e tuple)`\n- `hpluvToRgb(List\u003cdouble\u003e tuple)`\n- `rgbToHpluv(List\u003cdouble\u003e tuple)`\n- `hsluvToHex(List\u003cdouble\u003e tuple)`\n- `hpluvToHex(List\u003cdouble\u003e tuple)`\n- `hexToHsluv(String s)`\n- `hexToHpluv(String s)`\n- `rgbToHex(List\u003cdouble\u003e tuple)`\n- `hexToRgb(String hex)`\n\n### Reporting Issues\n\nIssues and Pull Requests are welcome.\nYou can report [here](https://github.com/bernaferrari/hsluv-dart/issues).\n\n### License\n\n```text\nCopyright 2020 Bernardo Ferrari\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbernaferrari%2Fhsluv-dart","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbernaferrari%2Fhsluv-dart","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbernaferrari%2Fhsluv-dart/lists"}