{"id":39565160,"url":"https://github.com/rmhubbert/tuifade","last_synced_at":"2026-01-31T07:04:07.489Z","repository":{"id":333185223,"uuid":"1127090298","full_name":"rmhubbert/tuifade","owner":"rmhubbert","description":"TUI luminance management for your Go cli tools. Fade background and foreground colours in ANSI coloured strings  ","archived":false,"fork":false,"pushed_at":"2026-01-18T00:34:40.000Z","size":44,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-18T15:51:36.855Z","etag":null,"topics":["ansi","colours","go","golang","golang-package","tui"],"latest_commit_sha":null,"homepage":"","language":"Go","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/rmhubbert.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-01-03T06:38:13.000Z","updated_at":"2026-01-18T00:34:44.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/rmhubbert/tuifade","commit_stats":null,"previous_names":["rmhubbert/tuifade"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/rmhubbert/tuifade","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmhubbert%2Ftuifade","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmhubbert%2Ftuifade/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmhubbert%2Ftuifade/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmhubbert%2Ftuifade/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rmhubbert","download_url":"https://codeload.github.com/rmhubbert/tuifade/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmhubbert%2Ftuifade/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28932605,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-31T04:05:25.756Z","status":"ssl_error","status_checked_at":"2026-01-31T04:02:35.005Z","response_time":128,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["ansi","colours","go","golang","golang-package","tui"],"created_at":"2026-01-18T07:13:05.924Z","updated_at":"2026-01-31T07:04:07.482Z","avatar_url":"https://github.com/rmhubbert.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tuifade\n\nTUI luminance management - A Go package for fading the background and foreground colours of ANSI strings.\n\n## Overview\n\n`tuifade` provides functions to apply luminance-based fading effects to ANSI-coloured text strings. It's particularly useful for creating subtle visual effects in terminal user interfaces, such as fading text to blend with terminal backgrounds or creating smooth colour transitions.\n\n## Features\n\n- **ANSI String Processing**: Preserves existing ANSI codes while applying colour transformations\n- **True Color Support**: Requires truecolour-capable terminals (24-bit colour)\n- **Linear Color Interpolation**: Uses proper linear RGB colour space for accurate fading\n- **Terminal Integration**: Automatically detects terminal background/foreground colours\n- **Flexible Fading Control**: Adjustable interpolation parameter for fine-grained control\n\n## Installation\n\n```bash\ngo get github.com/rmhubbert/tuifade\n```\n\n## Requirements\n\n- Go 1.25.5 or later\n- A terminal that supports truecolour (24-bit colour)\n- Compatible terminal environments (most modern terminals support truecolour)\n\n## Usage\n\n### Basic Usage\n\nThe main function is `Fade()`, which applies luminance fading to ANSI strings:\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"github.com/rmhubbert/tuifade\"\n)\n\nfunc main() {\n    // ANSI string with red text\n    colouredText := \"\\x1b[31mHello, World!\\x1b[0m\"\n    \n    // Apply 50% fade\n    faded, err := tuifade.Fade(colouredText, 0.5)\n    if err != nil {\n        fmt.Printf(\"Error: %v\\n\", err)\n        return\n    }\n    \n    fmt.Println(faded)\n}\n```\n\n### Interpolation Values\n\nThe `interpolation` parameter controls the degree of fading:\n\n- `1.0`: No fade (original colours preserved)\n- `0.5`: 50% fade (colours blended halfway with terminal background)\n- `0.0`: Full fade (colours become terminal background/foreground)\n\n### Advanced Usage with Custom Color Interpolation\n\nFor more control, you can use the `Interpolate()` function directly:\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"github.com/rmhubbert/tuifade\"\n)\n\nfunc main() {\n    // Interpolate between two colours\n    result, err := tuifade.Interpolate(\"#ff0000\", \"#0000ff\", 0.5)\n    if err != nil {\n        fmt.Printf(\"Error: %v\\n\", err)\n        return\n    }\n    \n    fmt.Printf(\"Interpolated colour: %s\\n\", result) // #800080 (purple)\n}\n```\n\n### Working with Complex ANSI Strings\n\nThe package handles complex ANSI sequences including:\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"github.com/rmhubbert/tuifade\"\n)\n\nfunc main() {\n    // Complex ANSI with multiple colours and styles\n    complexText := \"\\x1b[1;31;44mBold red on blue\\x1b[32mGreen text\\x1b[0m\"\n    \n    // Apply fading\n    faded, err := tuifade.Fade(complexText, 0.3)\n    if err != nil {\n        fmt.Printf(\"Error: %v\\n\", err)\n        return\n    }\n    \n    fmt.Println(faded)\n}\n```\n\n## API Reference\n\n### `func Fade(content string, interpolation float64) (string, error)`\n\nFades the background and foreground colours of an ANSI string using the terminal's default colours.\n\n**Parameters:**\n- `content`: ANSI string to process\n- `interpolation`: Fade amount (0.0 = full fade, 1.0 = no fade)\n\n**Returns:**\n- `string`: Faded ANSI string\n- `error`: Error if terminal doesn't support truecolour\n\n### `func Interpolate(hexBackground, hexForeground string, interpolation float64) (string, error)`\n\nInterpolates between two hex colours.\n\n**Parameters:**\n- `hexBackground`: Background colour in hex format (#RRGGBB)\n- `hexForeground`: Foreground colour in hex format (#RRGGBB)\n- `interpolation`: Interpolation amount (0.0 = background, 1.0 = foreground)\n\n**Returns:**\n- `string`: Interpolated colour in hex format\n- `error`: Error if colour formats are invalid\n\n## Error Handling\n\nThe package returns errors in these situations:\n\n1. **Non-truecolour terminals**: `Fade()` returns an error if the terminal doesn't support truecolour\n2. **Invalid colour formats**: `Interpolate()` returns errors for malformed hex colour strings\n3. **Interpolation clamping**: Values outside [0, 1] range are automatically clamped\n\n```go\nfaded, err := tuifade.Fade(colouredText, 0.5)\nif err != nil {\n    // Handle error - most commonly \"fade only supports truecolour terminals\"\n    fmt.Printf(\"Terminal limitation: %v\\n\", err)\n    // Fallback: use original text\n    faded = colouredText\n}\n```\n\n## Colour Space\n\nThe package uses linear RGB colour space for interpolation, which provides more accurate colour transitions than sRGB. This ensures that luminance changes appear natural and consistent across different colour combinations.\n\n## Testing\n\nRun the test suite:\n\n```bash\ngo test\n```\n\nRun benchmarks:\n\n```bash\ngo test -bench=.\n```\n\n## Dependencies\n\n- `github.com/leaanthony/go-ansi-parser` - ANSI string parsing\n- `github.com/lucasb-eyer/go-colourful` - Color space conversions\n- `github.com/muesli/termenv` - Terminal environment detection\n\n## Examples\n\n### Creating a Progress Effect\n\n```go\nfunc showProgress() {\n    text := \"\\x1b[32mProcessing...\\x1b[0m\"\n    \n    for i := 10; i \u003e= 0; i-- {\n        fadeAmount := float64(i) / 10.0\n        faded, _ := tuifade.Fade(text, fadeAmount)\n        fmt.Printf(\"\\r%s\", faded)\n        time.Sleep(200 * time.Millisecond)\n    }\n    fmt.Println()\n}\n```\n\n### Subtle UI Elements\n\n```go\nfunc createSubtleHint() {\n    hint := \"\\x1b[36mPress 'q' to quit\\x1b[0m\"\n    subtle, _ := tuifade.Fade(hint, 0.7) // 30% faded\n    fmt.Println(subtle)\n}\n```\n\n## License\n\ntuifade is licensed under the MIT License. See the LICENSE file for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frmhubbert%2Ftuifade","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frmhubbert%2Ftuifade","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frmhubbert%2Ftuifade/lists"}