{"id":18076747,"url":"https://github.com/gooroo/qml-colors","last_synced_at":"2025-04-12T08:40:37.505Z","repository":{"id":147825523,"uuid":"479127715","full_name":"GooRoo/qml-colors","owner":"GooRoo","description":"This library should have never been created","archived":false,"fork":false,"pushed_at":"2023-03-09T21:19:48.000Z","size":714,"stargazers_count":37,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-26T03:41:46.789Z","etag":null,"topics":["color","css","javascript","less","qbs","qml","qt","sass","scss"],"latest_commit_sha":null,"homepage":"https://gooroo.github.io/qml-colors","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GooRoo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":["GooRoo"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2022-04-07T19:48:43.000Z","updated_at":"2025-03-23T20:49:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"d9a06678-d6df-4f0b-bf49-0a4d29a99567","html_url":"https://github.com/GooRoo/qml-colors","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/GooRoo%2Fqml-colors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GooRoo%2Fqml-colors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GooRoo%2Fqml-colors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GooRoo%2Fqml-colors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GooRoo","download_url":"https://codeload.github.com/GooRoo/qml-colors/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248542986,"owners_count":21121827,"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","css","javascript","less","qbs","qml","qt","sass","scss"],"created_at":"2024-10-31T11:11:02.248Z","updated_at":"2025-04-12T08:40:37.484Z","avatar_url":"https://github.com/GooRoo.png","language":"JavaScript","funding_links":["https://github.com/sponsors/GooRoo"],"categories":[],"sub_categories":[],"readme":"# qml-colors\n\n[![Made by Ukrainian](https://img.shields.io/static/v1?label=Made%20by\u0026message=Ukrainian\u0026labelColor=1f5fb2\u0026color=fad247\u0026style=flat-square)](https://github.com/GooRoo/ukrainian-shields)\n[![License](https://img.shields.io/github/license/GooRoo/qml-colors?style=flat-square)](LICENSE)\n\n## Struggling with colors?\n\nAre you sick and tired of poorness of Qt Quick's `color` datatype as much as I am? Ever wanted to have an easier way of doing simple color transformations in QML bindings like following?\n```qml hl_lines=\"5\"\nRectangle { id: r1; color: 'red' }\n\nRectangle {\n\t// oh god, I just wanted to add some transparency\n\tcolor: Qt.rgba(r1.color.r, r1.color.g, r1.color.b, 0.8)\n}\n```\nWhat if you could write it like this?\n```qml\nRectangle {\n\tcolor: rgba(r1.color, 0.8)\n}\n```\nOr even like this?\n```qml\nRectangle {\n\tcolor: $.fadeOut(r1.color, 20 .percent)\n}\n```\nInterested? **Then welcome aboard!** Let's see some examples.\n\n## With this library you can…\n\n### …construct color objects\n\nin many various ways\n\n```qml\nRectangle {\n\tcolor: rgba('indigo', 0.8)  // ⇒ #cc4b0082 (as ARGB)\n}\n```\n\n```qml\nRectangle {\n\tcolor: q`#036`  // ⇒ #003366\n}\n```\n\n```qml\nRectangle {\n\tcolor: q`r:${128} g:${0} b:${255}`  // ⇒ #8000ff\n}\n```\n\nAnd even imperatively out of `color`-properties\n\n```qml hl_lines=\"3\"\nItem {\n\tComponent.onCompleted: {\n\t\tconst c = q`yellow`       // It looks like a string, but it's an object!\n\n\t\t// this is expected\n\t\tconsole.log(q`yellow`)    // ⇒ #ffff00\n\n\t\t// but let's try this\n\t\tconsole.log(q`yellow`.r)  // ⇒ 1.0\n\t\tconsole.log(q`yellow`.g)  // ⇒ 1.0\n\t\tconsole.log(q`yellow`.b)  // ⇒ 0.0\n\t}\n}\n```\n\n### …use units\n\n```qml\nRectangle {\n\tcolor: $.adjustHue('#036', +45['°'])   // ⇒ #1a0066\n}\n```\n```qml\nRectangle {\n\tcolor: cc`#036`.lighten(60 .percent).color  // ⇒ #99ccff\n}\n```\n\n### …rely on a whole bunch of auxiliary color functions\n\n```qml\nRectangle {\n\tcolor: $.mix('#036', '#d2e1dd', 75['%'])  // ⇒ #355f84\n}\n```\n```qml\nRectangle {\n\tcolor: $.scale('#d2e1dd', {hsl: {l: -10['%'], s: +10['%']}})  // ⇒ #b3d4cb\n}\n```\n```qml\nRectangle {\n\tcolor: $.desaturate('#f2ece4', 20 .percent)  // ⇒ #eeebe8\n}\n```\n\n### …chain as many transformations as you need\n\n```qml\nRectangle {\n\tcolor:\n\t\tcc`#0000ff`\n\t\t\t.adjustHue(-105 .deg)\n\t\t\t.desaturate(20 .percent)\n\t\t\t.mix('red', 85 .percent)\n\t\t\t.adjust({alpha: -30 .percent})\n\t\t\t.color                          // ⇒ #b33cc341\n}\n```\n\n### …work with `color`s imperatively\n\n```qml hl_lines=\"3 6-7\"\nRectangle {\n\tcolor: {\n\t\tlet newColor = cc`darkorange`\n\t\tconsole.log(newColor)  // ⇒ #ffa500\n\t\tconsole.log(newColor.hue, newColor.saturation)  // ⇒ 0.108 1.0\n\t\tnewColor.hue = 20 .deg\n\t\tnewColor.saturation = 65 .percent\n\t\tconsole.log(newColor)  // ⇒ #d2642d\n\t\treturn newColor.color\n\t}\n}\n```\n\n### …and maybe something else\n\nbut I don't even remember.\n\n## Wanna use it?\n\nConvinced? [Get started][get-started] now!\n\nNot yet? Anyway, read the [documentation][get-started] and you'll change your mind.\n\n[get-started]: https://gooroo.github.io/qml-colors/getting-started/why/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgooroo%2Fqml-colors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgooroo%2Fqml-colors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgooroo%2Fqml-colors/lists"}