{"id":16965009,"url":"https://github.com/propensive/iridescence","last_synced_at":"2025-03-22T14:31:00.916Z","repository":{"id":49393899,"uuid":"357684916","full_name":"propensive/iridescence","owner":"propensive","description":"Sophisticated representation of color in Scala","archived":false,"fork":false,"pushed_at":"2025-01-26T12:14:40.000Z","size":2267,"stargazers_count":5,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-18T11:52:01.684Z","etag":null,"topics":["cielab","color","color-models","hsl","hsv","lab-color","rgb","scala","srgb"],"latest_commit_sha":null,"homepage":"https://soundness.dev/iridescence/","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/propensive.png","metadata":{"files":{"readme":".github/readme.md","changelog":null,"contributing":".github/contributing.md","funding":null,"license":null,"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":"2021-04-13T20:49:25.000Z","updated_at":"2025-01-26T12:14:43.000Z","dependencies_parsed_at":"2023-11-16T09:26:01.098Z","dependency_job_id":"3401c7d0-df0b-4746-9b26-a7dcf7ee1d4b","html_url":"https://github.com/propensive/iridescence","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/propensive%2Firidescence","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/propensive%2Firidescence/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/propensive%2Firidescence/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/propensive%2Firidescence/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/propensive","download_url":"https://codeload.github.com/propensive/iridescence/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244971777,"owners_count":20540854,"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":["cielab","color","color-models","hsl","hsv","lab-color","rgb","scala","srgb"],"created_at":"2024-10-13T23:44:49.536Z","updated_at":"2025-03-22T14:31:00.906Z","avatar_url":"https://github.com/propensive.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"[\u003cimg alt=\"GitHub Workflow\" src=\"https://img.shields.io/github/actions/workflow/status/propensive/iridescence/main.yml?style=for-the-badge\" height=\"24\"\u003e](https://github.com/propensive/iridescence/actions)\n[\u003cimg src=\"https://img.shields.io/discord/633198088311537684?color=8899f7\u0026label=DISCORD\u0026style=for-the-badge\" height=\"24\"\u003e](https://discord.com/invite/MBUrkTgMnA)\n\u003cimg src=\"/doc/images/github.png\" valign=\"middle\"\u003e\n\n# Iridescence\n\n__Sophisticated representation of color__\n\n__Iridescence__ implements several algorithms for working with colors represented in different forms.\n\n## Features\n\n- represents colors using a variety of different color models\n- work with colors in RGB, HSV, CMY, CMYK, HSL, CIELAB and XYZ\n- convert between any colors\n- utilize color profiles (where necessary)\n- provides a standard palette of named colors\n- print colors as CSS, Hex or ANSI\n- brighten, lighten, darken and blend colors\n- calculate perceptual deltas between colors\n\n\n## Availability\n\n\n\n\n\n\n\n## Getting Started\n\n_Iridescence_ provides seven different ways of representing colors:\n- `Srgb`: [sRGB](https://en.wikipedia.org/wiki/SRGB), \n- `Xyz`: [CIE 1931 XYZ](https://en.wikipedia.org/wiki/CIE_1931_color_space)\n- `Cielab`: [L*a*b*](https://en.wikipedia.org/wiki/CIELAB_color_space) or CIELAB\n- `Cmy`: [CMY](https://en.wikipedia.org/wiki/CMY_color_model)\n- `Cmyk`: [CMYK](https://en.wikipedia.org/wiki/CMYK_color_model)\n- `Hsl`: [HSL](https://en.wikipedia.org/wiki/HSL_and_HSV)\n- `Hsv`: [HSV](https://en.wikipedia.org/wiki/HSL_and_HSV)\n\nEach color model uses either three or four continuous coordinates, all represented in Iridescence as `Double`s\nin the unit interval (0 ≤ *c* ≤ 1), to describe an apparently full spectrum of colors perceived by the human\neye.\n\nGiven the complex nature of sight and color, different models make different tradeoffs in their representations\nof different colors. While sRGB is the most direct representation of the colored light emitted by a computer\nmonitor, and indeed the most common representation for computers, CMY and CMYK are more common in printing.\n\nMeanwhile, the HSL and HSV representations representations use the natural qualititative properties of hue,\nsaturation, lightness and brightness, and the XYZ and CIELAB color spaces are derived empirically. CIELAB\nattempts to maintain the property that the Euclidean distance between two colors is proportional to the\nperceptual difference between those colors, as determined by experimentation.\n\nThe particular color model should be chosen according to the requirements of the particular task.\n\n### A Quick Example\n\n```scala\nimport iridescence.*\n\ngiven profile = profiles.Ultralume50\n\nval pink: Cielab = colors.Ivory.cielab.mix(colors.DarkMagenta.cielab)\nval palePink: Srgb = pink.srgb.hsv.tint(0.5).srgb\nprintln(s\"${color.ansiFg24}Hello World!\")\n```\n\n### Types\n\nIridescence provides case classes to immutably represent each of the seven color models, above. Colors in one\nrepresentation can be directly converted into many of the other representations, and the remaining conversions\ncan be performed indirectly.\n\nIn general, every color representation provides the `Color#srgb` method to convert it to an `Srgb` value.\nConversely, the `Srgb` type provides the methods `cmy`, `cmyk`, `cielab`, `xyz`, `hsv` and `hsl` to convert to\nthese alternative representations.\n\nWhile it would be possible to provide an n×n set of methods for converting between any pair of representations,\nconversions which rely on an unspecified intermediate representation (for example converting between HSL and\nCMYK) are generally _not_ provided unless the intermediate representation is a necessary step in the\ncalculation. This is to make it clear when conversions are happening.\n\nFor example, the methods `Hsl#srgb` and `Srgb#xyz` both exist, but `Hsl#xyz` is not implemented. However,\n`Srgb#cielab` _is_ provided, even though the conversion is made via an intermediate XYZ value.\n\nHere are some examples:\n```scala\nval DeepPink: Srgb = Srgb(1, 0.078, 0.576)\nval Gold: Hsv = Srgb(1, 0.843, 0).hsv\nval Gold2: Cmyk = Gold.srgb.cmyk\n```\n\n### Palette\n\nThe `colors` object provides a standard palette of about 140 named colors defined in sRGB space.\n\n### Color profiles\n\nCertain color representations rely on additional information that characterizes the conditions under which the\ncolors are encoded, and this information is necessary for conversions between certain color spaces.\n\nFor example, to convert from `Srgb` to `Cielab` requires a profile. Profiles are provided through the `Profile`\ntype, and several are provided in the `profiles` object. These should be specified, implicitly or explicitly\nwith each conversion, like so:\n\n```scala\nval color = DeepPink.cielab(using profiles.MidMorningDaylight)\n```\nor,\n```scala\ngiven Profile = profiles.CoolFluorescent\nval color = LawnGreen.xyz\n```\n\nFor generality, conversions to `Srgb` _always_ require a profile to be given (even for conversions where it is\nnot used). This restriction may be lifted later. A good default profile to use is the `Daylight` profile.\n```scala\ngiven Profile = profiles.Daylight\n```\n\n### Color methods\n\nAdditional methods are provided on certain color types for producing new colors from old. In general, these\nmethods are particular to the color model being used.\n\nFor example, the methods `saturate`, `desaturate`, `pure` and `rotate` (for changing the hue) are provided on\n`Hsl` and `Hsv` types, while `Hsv` additionally provides `shade`, `tint` and `tone` methods. These latter\nmethods take `black` and/or `white` parameters to specify the amount of shading, tinting or toning to be\napplied.\n\n`Cielab` provides a `delta` method for comparing two colors (returning a `Double` in the unit interval), and the\n`mix` method for combining two colors. `Cielab#mix` takes another `Cielab` color as its first parameter, and\na mix ratio (again, in the unit interval) as an optional second parameter. If left unspecified, it defaults to\nthe midpoint between the two colors.\n\nUse of these methods might typically involve converting a color to the model which defines them, then applying\nthem as necessary, before converting back. For example,\n```scala\ncolors.IndianRed.hsv.tone(0.2, 0.4).srgb\n```\n\n### Serialization\n\nDifferent formats, languages and protocols will represent colors as strings in a number of different ways.\nIridescence provides serialization methods to the following formats:\n- 24-bit ANSI foreground and background escape codes,\n- RGB CSS, in the form `rgb(100, 78, 12)`,\n- HSL CSS, in the form `hsl(310, 12%, 84%)`,\n- 12-bit and 24-bit hexadecimal, e.g. `#afc` or `#ffed00`\n\nThese are available on the `Srgb` type, with the exception of `Hsl#css`.\n\n### Limitations\n\nThere is no support for transparency.\n\n\n\n\n\n## Status\n\nIridescence is classified as __maturescent__. For reference, Soundness projects are\ncategorized into one of the following five stability levels:\n\n- _embryonic_: for experimental or demonstrative purposes only, without any guarantees of longevity\n- _fledgling_: of proven utility, seeking contributions, but liable to significant redesigns\n- _maturescent_: major design decisions broady settled, seeking probatory adoption and refinement\n- _dependable_: production-ready, subject to controlled ongoing maintenance and enhancement; tagged as version `1.0.0` or later\n- _adamantine_: proven, reliable and production-ready, with no further breaking changes ever anticipated\n\nProjects at any stability level, even _embryonic_ projects, can still be used,\nas long as caution is taken to avoid a mismatch between the project's stability\nlevel and the required stability and maintainability of your own project.\n\nIridescence is designed to be _small_. Its entire source code currently consists\nof 498 lines of code.\n\n## Building\n\nIridescence will ultimately be built by Fury, when it is published. In the\nmeantime, two possibilities are offered, however they are acknowledged to be\nfragile, inadequately tested, and unsuitable for anything more than\nexperimentation. They are provided only for the necessity of providing _some_\nanswer to the question, \"how can I try Iridescence?\".\n\n1. *Copy the sources into your own project*\n   \n   Read the `fury` file in the repository root to understand Iridescence's build\n   structure, dependencies and source location; the file format should be short\n   and quite intuitive. Copy the sources into a source directory in your own\n   project, then repeat (recursively) for each of the dependencies.\n\n   The sources are compiled against the latest nightly release of Scala 3.\n   There should be no problem to compile the project together with all of its\n   dependencies in a single compilation.\n\n2. *Build with [Wrath](https://github.com/propensive/wrath/)*\n\n   Wrath is a bootstrapping script for building Iridescence and other projects in\n   the absence of a fully-featured build tool. It is designed to read the `fury`\n   file in the project directory, and produce a collection of JAR files which can\n   be added to a classpath, by compiling the project and all of its dependencies,\n   including the Scala compiler itself.\n   \n   Download the latest version of\n   [`wrath`](https://github.com/propensive/wrath/releases/latest), make it\n   executable, and add it to your path, for example by copying it to\n   `/usr/local/bin/`.\n\n   Clone this repository inside an empty directory, so that the build can\n   safely make clones of repositories it depends on as _peers_ of `iridescence`.\n   Run `wrath -F` in the repository root. This will download and compile the\n   latest version of Scala, as well as all of Iridescence's dependencies.\n\n   If the build was successful, the compiled JAR files can be found in the\n   `.wrath/dist` directory.\n\n## Contributing\n\nContributors to Iridescence are welcome and encouraged. New contributors may like\nto look for issues marked\n[beginner](https://github.com/propensive/iridescence/labels/beginner).\n\nWe suggest that all contributors read the [Contributing\nGuide](/contributing.md) to make the process of contributing to Iridescence\neasier.\n\nPlease __do not__ contact project maintainers privately with questions unless\nthere is a good reason to keep them private. While it can be tempting to\nrepsond to such questions, private answers cannot be shared with a wider\naudience, and it can result in duplication of effort.\n\n## Author\n\nIridescence was designed and developed by Jon Pretty, and commercial support and\ntraining on all aspects of Scala 3 is available from [Propensive\nO\u0026Uuml;](https://propensive.com/).\n\n\n\n## Name\n\nThe word _iridescent_, defined as \"having a play of changeable colors\", also describes the functionality of Iridescence.\n\nIn general, Soundness project names are always chosen with some rationale,\nhowever it is usually frivolous. Each name is chosen for more for its\n_uniqueness_ and _intrigue_ than its concision or catchiness, and there is no\nbias towards names with positive or \"nice\" meanings—since many of the libraries\nperform some quite unpleasant tasks.\n\nNames should be English words, though many are obscure or archaic, and it\nshould be noted how willingly English adopts foreign words. Names are generally\nof Greek or Latin origin, and have often arrived in English via a romance\nlanguage.\n\n## Logo\n\nThe logo illustrates a color wheel.\n\n## License\n\nIridescence is copyright \u0026copy; 2025 Jon Pretty \u0026 Propensive O\u0026Uuml;, and\nis made available under the [Apache 2.0 License](/license.md).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpropensive%2Firidescence","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpropensive%2Firidescence","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpropensive%2Firidescence/lists"}