Skip to content

Commit d5ac9a2

Browse files
committed
initial
0 parents  commit d5ac9a2

12 files changed

Lines changed: 902 additions & 0 deletions

File tree

.github/cutify.png

2.63 KB
Loading

.github/demo.png

86.1 KB
Loading

.github/workflows/ci.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
11+
env:
12+
RUSTFLAGS: -Dwarnings
13+
14+
jobs:
15+
build:
16+
name: Rust ${{matrix.rust}}
17+
runs-on: ${{matrix.os || 'ubuntu'}}-latest
18+
strategy:
19+
matrix:
20+
rust: [stable]
21+
timeout-minutes: 45
22+
steps:
23+
- uses: actions/checkout@v5
24+
- uses: dtolnay/rust-toolchain@master
25+
with:
26+
toolchain: ${{matrix.rust}}
27+
- run: cargo check
28+
29+
clippy:
30+
name: Clippy
31+
runs-on: ubuntu-latest
32+
if: github.event_name != 'pull_request'
33+
timeout-minutes: 45
34+
steps:
35+
- uses: actions/checkout@v5
36+
- uses: dtolnay/rust-toolchain@clippy
37+
- run: cargo clippy

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Rust
2+
/target/
3+
Cargo.lock
4+
5+
# IDE
6+
.vscode/
7+
.idea/
8+
*.swp
9+
*.swo
10+
*~
11+
12+
# OS
13+
.DS_Store
14+
Thumbs.db

Cargo.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[package]
2+
name = "cutify"
3+
version = "0.1.0"
4+
edition = "2024"
5+
description = "A library for colorizing console output with cute gradients"
6+
license = "MIT"
7+
repository = "https://github.com/mxve/cutify"
8+
keywords = ["color", "gradient", "terminal", "console", "ansi"]
9+
10+
[dependencies]
11+
crossterm = "0.29"
12+
rand = "0.9"

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 mxve
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# cutify
2+
3+
[![Crates.io Version](https://img.shields.io/crates/v/cutify?style=for-the-badge&logo=rust)](https://crates.io/crates/cutify) ![CI](https://img.shields.io/github/actions/workflow/status/mxve/cutify/ci.yml?style=for-the-badge&logo=github) [![Docs.rs](https://img.shields.io/docsrs/cutify?style=for-the-badge&logo=docs.rs)](https://docs.rs/cutify/latest/cutify/)
4+
5+
A Rust library for colorizing console output with cute gradients.
6+
7+
![cutify](.github/cutify.png)
8+
9+
## Features
10+
11+
- Extension trait API (`"text".gradient()`)
12+
- Builder API (`Cutifier::new()`)
13+
- Stateful API for persistent gradients
14+
- Built-in color palettes
15+
- Hue range filtering
16+
- Gradient directions
17+
- Configurable parameters
18+
- Custom writer support
19+
20+
> [!NOTE]
21+
> Windows Compatibility
22+
> - These features require Windows 10+ or a modern terminal
23+
> - Stateful API: `cute!()`, `cuteprintln!()`, `cuteprint!()` macros
24+
> - Extension trait API: `Display` formatting of `CutifiedString`
25+
26+
## Usage
27+
28+
### Extension Trait API
29+
30+
```rust
31+
use cutify::Cutify;
32+
33+
println!("{}", "Hello World".gradient());
34+
println!("{}", "Pastel colors".pastel());
35+
println!("{}", "Ocean vibes".ocean());
36+
println!("{}", "Only purples".purples());
37+
```
38+
39+
### Builder API
40+
41+
Fine-grained control with method chaining:
42+
43+
```rust
44+
use cutify::{Cutifier, ColorPalette, GradientDirection};
45+
46+
Cutifier::new("Custom gradient")
47+
.palette(ColorPalette::Sunset)
48+
.direction(GradientDirection::Diagonal)
49+
.hue_shift(15.0)
50+
.print();
51+
52+
// Write to custom buffer
53+
let mut buffer = Vec::new();
54+
Cutifier::new("To buffer")
55+
.palette(ColorPalette::Fire)
56+
.write_to(&mut buffer)?;
57+
```
58+
59+
### Stateful API
60+
61+
Continue gradients across multiple prints:
62+
63+
```rust
64+
use cutify::{cuteprintln, cute};
65+
66+
cuteprintln!("This continues");
67+
cuteprintln!("the same gradient");
68+
let colored = cute!("across calls");
69+
```
70+
71+
## Options
72+
73+
- `palette(ColorPalette)` - Apply predefined color scheme
74+
- `hue_range(HueRange)` - Limit colors to specific hue range
75+
- `direction(GradientDirection)` - Set gradient direction
76+
- `saturation(f32)` - Adjust color saturation (0.0-1.0)
77+
- `lightness(f32)` - Adjust color lightness (0.0-1.0)
78+
- `hue_shift(f32)` - How much the hue changes per step (degrees, default: 12.0)
79+
- `step(f32)` - How often the color changes (characters per step, default: 1.0)
80+
- `step(3.0)` means every 3rd character gets a new color
81+
- Combine with `hue_shift` for control: `step(2.0).hue_shift(30.0)` = big color jumps every 2 chars
82+
- `scale(f32)` - Alternative to hue_shift: characters for full gradient cycle (e.g., 10.0=completes in 10 chars, 0=disabled)
83+
- `base_hue(f32)` - Set starting hue (0-360)
84+
- `random_hue()` - Randomize base hue
85+
- `reverse()` - Reverse gradient direction
86+
87+
## Examples
88+
89+
Run examples:
90+
```bash
91+
cargo run --example demo
92+
```
93+
94+
![demo](.github/demo.png)
95+
96+
## License
97+
98+
MIT

examples/demo.rs

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
use cutify::*;
2+
3+
fn code(s: &str) -> String {
4+
format!("\x1b[90m{}\x1b[0m", s)
5+
}
6+
7+
fn main() {
8+
println!("1. Extension Trait API");
9+
println!(" {}", code("\"Hello, World!\".gradient()"));
10+
println!(" {}", "Hello, World!".gradient());
11+
println!();
12+
13+
println!("2. Builder API");
14+
println!(
15+
" {}",
16+
code("Cutifier::new(\"Method chaining\").saturation(0.8).print()")
17+
);
18+
Cutifier::new("Method chaining").saturation(0.8).print();
19+
20+
println!("3. Color Palette");
21+
println!(" {}", code("\"Ocean waves\".ocean()"));
22+
println!(" {}", "Ocean waves".ocean());
23+
println!();
24+
25+
println!("4. Hue Range Constraints");
26+
println!(" {}", code("\"Warm colors only\".warm()"));
27+
println!(" {}", "Warm colors only".warm());
28+
println!();
29+
println!(
30+
" {}",
31+
code(
32+
"Cutifier::new(\"Custom 200-280°\").hue_range(HueRange::Custom(200.0, 280.0)).print()"
33+
)
34+
);
35+
Cutifier::new("Custom 200-280°")
36+
.hue_range(HueRange::Custom(200.0, 280.0))
37+
.print();
38+
39+
println!("5. Multi-line with Direction");
40+
let poem = "Roses are red,\nViolets are blue,\nGradients are cool,\nAnd so are you!";
41+
println!(
42+
" {}",
43+
code(
44+
"Cutifier::new(poem).palette(ColorPalette::Sunset).direction(GradientDirection::Vertical).print()"
45+
)
46+
);
47+
Cutifier::new(poem)
48+
.palette(ColorPalette::Sunset)
49+
.direction(GradientDirection::Vertical)
50+
.print();
51+
52+
println!("6. ASCII Art");
53+
let ascii = r#"
54+
██████╗██╗ ██╗████████╗██╗███████╗██╗ ██╗
55+
██╔════╝██║ ██║╚══██╔══╝██║██╔════╝╚██╗ ██╔╝
56+
██║ ██║ ██║ ██║ ██║█████╗ ╚████╔╝
57+
██║ ██║ ██║ ██║ ██║██╔══╝ ╚██╔╝
58+
╚██████╗╚██████╔╝ ██║ ██║██║ ██║
59+
╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝
60+
"#;
61+
println!(
62+
" {}",
63+
code(
64+
"Cutifier::new(ascii).palette(ColorPalette::Neon).direction(GradientDirection::Diagonal).scale(40.0).print()"
65+
)
66+
);
67+
Cutifier::new(ascii)
68+
.palette(ColorPalette::Neon)
69+
.direction(GradientDirection::Diagonal)
70+
.scale(40.0)
71+
.print();
72+
73+
println!(
74+
" {}",
75+
code(
76+
"Cutifier::new(ascii).palette(ColorPalette::Fire).direction(GradientDirection::Vertical).scale(6.0).print()"
77+
)
78+
);
79+
Cutifier::new(ascii)
80+
.palette(ColorPalette::Fire)
81+
.direction(GradientDirection::Vertical)
82+
.scale(6.0)
83+
.print();
84+
85+
println!("7. Scale and Step");
86+
println!(
87+
" {}",
88+
code(
89+
"Cutifier::new(\"Quick gradient!\").palette(ColorPalette::Rainbow).scale(7.0).print()"
90+
)
91+
);
92+
Cutifier::new("Quick gradient!")
93+
.palette(ColorPalette::Rainbow)
94+
.scale(7.0)
95+
.print();
96+
97+
println!(
98+
" {}",
99+
code(
100+
"Cutifier::new(\"Use a new color every 3rd character by setting the step size to 3!\").palette(ColorPalette::Neon).step(3.0).print()"
101+
)
102+
);
103+
Cutifier::new("Use a new color every 3rd character by setting the step size to 3!")
104+
.palette(ColorPalette::Neon)
105+
.step(3.0)
106+
.print();
107+
108+
println!("8. Custom Writer");
109+
println!(
110+
" {}",
111+
code("let mut buffer = Vec::new(); Cutifier::new(\"To buffer\").write_to(&mut buffer)")
112+
);
113+
let mut buffer = Vec::new();
114+
Cutifier::new("Written to buffer!")
115+
.palette(ColorPalette::Fire)
116+
.write_to(&mut buffer)
117+
.unwrap();
118+
print!(" {}", String::from_utf8_lossy(&buffer));
119+
}

0 commit comments

Comments
 (0)