An open API service indexing awesome lists of open source software.

https://github.com/scriptsmith/tart

Text art renderer for the terminal. View on the web at https://tart.sh
https://github.com/scriptsmith/tart

ascii-art text-art

Last synced: 4 months ago
JSON representation

Text art renderer for the terminal. View on the web at https://tart.sh

Awesome Lists containing this project

README

          

# tart

Text art renderer for the terminal.

![art demo](./assets/banner.png)

> [!TIP]
> See your art rendered on the web at [tart.sh](https://tart.sh)

## Installation

Follow the instructions at [rustup.rs](https://rustup.rs/) to install Rust.

Then, you can install `tart` using Cargo:

```bash
cargo install --git https://github.com/ScriptSmith/tart.git
```

## Usage

Create a TOML file with the following structure:

```bash
cat < art.toml
design = '''
abc
def
ghi
'''

styles = '''
rgb
RGB
YPO
'''

[style_map]

[style_map.r]
foreground = "Red"
[style_map.g]
foreground = "Green"
[style_map.b]
foreground = "Blue"

[style_map.R]
foreground = "Red"
styles = ["Bold"]
[style_map.G]
foreground = "Green"
styles = ["Bold"]
[style_map.B]
foreground = "Blue"
styles = ["Bold"]

[style_map.Y]
foreground.RGB = [255, 255, 0]
styles = ["Italic"]
[style_map.P]
foreground.RGB = [255, 0, 255]
styles = ["Italic"]
[style_map.O]
foreground.RGB = [255, 165, 0]
styles = ["Italic"]
EOF
```

Then run the following command to render the text art:

```bash
tart render art.toml
```

The output should look like this:

![rendered text art](./assets/art.png)

See the help message for more information:

```
$ tart --help
Usage: tart

Commands:
render Render the input file
validate Validate the input file
schema Print the JSON schema for the input file
help Print this message or the help of the given subcommand(s)

Options:
-h, --help Print help
-V, --version Print version
```

```
$ tart render --help
Render the input file

Usage: tart render [OPTIONS]

Arguments:
Path to the input file

Options:
-t, --type Input file type [possible values: toml, json]
-h, --help Print help

```

## Input file schema

The input file schema is as follows:

```json
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Input",
"type": "object",
"required": [
"design",
"style_map",
"styles"
],
"properties": {
"design": {
"type": "string"
},
"style_map": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/InputStyles"
}
},
"styles": {
"type": "string"
}
},
"definitions": {
"InputColor": {
"oneOf": [
{
"type": "string",
"enum": [
"Black",
"Red",
"Green",
"Yellow",
"Blue",
"Purple",
"Cyan",
"White"
]
},
{
"type": "object",
"required": [
"Fixed"
],
"properties": {
"Fixed": {
"type": "integer",
"format": "uint8",
"minimum": 0.0
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"RGB"
],
"properties": {
"RGB": {
"type": "array",
"items": [
{
"type": "integer",
"format": "uint8",
"minimum": 0.0
},
{
"type": "integer",
"format": "uint8",
"minimum": 0.0
},
{
"type": "integer",
"format": "uint8",
"minimum": 0.0
}
],
"maxItems": 3,
"minItems": 3
}
},
"additionalProperties": false
}
]
},
"InputStyle": {
"type": "string",
"enum": [
"Bold",
"Dimmed",
"Italic",
"Underlined",
"Blink",
"Reverse",
"Hidden",
"Strikethrough"
]
},
"InputStyles": {
"type": "object",
"properties": {
"background": {
"anyOf": [
{
"$ref": "#/definitions/InputColor"
},
{
"type": "null"
}
]
},
"foreground": {
"anyOf": [
{
"$ref": "#/definitions/InputColor"
},
{
"type": "null"
}
]
},
"styles": {
"type": [
"array",
"null"
],
"items": {
"$ref": "#/definitions/InputStyle"
}
}
}
}
}
}
```