Skip to content

byt3-dev/PixelColor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pixelcolor

A Dart package to print colored text in terminals using CSS color names, hex codes, and RGB values.

Features

  • Supports CSS color names (red, blue, gold, etc.)
  • Hex colors (#RGB, #RRGGBB, #RRRGGGBBB)
  • RGB values (rgb(255,0,0) or rgb(255 0 0))
  • Truecolor ANSI escapes (works on modern terminals)
  • Graceful fallback on unsupported terminals
  • CLI tool included

Installation

dart pub add pixelcolor

Library Usage

import 'package pixelcolor.dart';

void main() {
  printColor('Hello in red!', 'red');
  printColor('Hex orange', '#FF8C00');
  printColor('RGB cyan', 'rgb(0 255 255)');
}

CLI Usage

dart run pixelcolor "Your text" color

Examples:
  dart run pixelcolor "Success!" green
  dart run pixelcolor "Warning" "#FFA500"
  dart run pixelcolor "Custom" "rgb(100 200 50)"

API

  • printColor(String text, String colorStr): Prints colored text (with error for invalid colors).
  • List<int>? parseColor(String colorStr): Parses to [r,g,b] or null.
  • String getAnsiColor(List<int> rgb): Returns ANSI escape string or empty.
  • int calculate(): Legacy demo function.

Supported Colors

CSS names like: red, blue, green, yellow, orange, pink, purple, etc. (20+ included, expandable).

Hex: #f00, #ff0000, etc.

RGB: rgb(255,0,0), rgb(255 0 0)

Tests & Dev

dart test
dart analyze

Compatibility

  • Works on Windows Terminal, iTerm2, most Linux/macOS terminals.
  • Fallback to plain text if no ANSI support detected.

See lib pixelcolor.dart for full implementation.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages