Skip to content

Commit

Permalink
#235 define colors from define languages invocation
Browse files Browse the repository at this point in the history
  • Loading branch information
atluft committed Oct 16, 2020
2 parents bee2bf7 + 792850e commit 074e238
Show file tree
Hide file tree
Showing 32 changed files with 1,812 additions and 1,826 deletions.
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ updates:
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
8 changes: 6 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: CI
on: [push]
on:
push:
branches: [ '*' ]
pull_request:
branches: [ master ]

jobs:
build:
Expand Down Expand Up @@ -34,7 +38,7 @@ jobs:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
Expand Down
18 changes: 11 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Adding support for a new Language requires adding a new entry in the `define_lan

**Example**:

```{ CSharp, "csharp.ascii", "C#", { Colors { basic_colors: vec![Color::Blue, Color::Magenta], true_colors: Some(vec![Color::TrueColor{ r:0, g:0, b:255 }, Color::TrueColor{ r:255, g:0, b:255 }]) } }, "c#" },```
` { CSharp, "csharp.ascii", "C#", define_colors!( [Color::Blue, Color::Magenta] ), "c#" }, `

The first item `CSharp` corresponds to the name of the language as defined in tokei. The second item `csharp.ascii` is the name of the file containing the ascii logo, this file has to be placed in the _./resources_ folder (more info below). The third item `C#` is the display name. Then we have the colors used to customize the look of the ascii logo when displayed to the screen. The last item `c#` is required only if the Enum name `CSharp` doesn't match the display name `C#`.

Expand Down Expand Up @@ -89,13 +89,17 @@ Remarks:
- Your ascii logo's dimensions must fall below `25*45` (height\*width). The CI will fail otherwise.
- You can use `{N}` to color the ascii which will utilize the vec! of colors defined in `define_language!`
- Make sure to trim any unnecessary trailing whitespaces
- Make sure if you use true_colors that the number of true_colors matches the number of basic_colors
- See example here [Ascii Art From Image File Using Python Image Library](https://github.com/o2sh/onefetch/wiki/ASCII-Art-From-Image-Using-Python-Image-Library)

- These are all equal color schemes, notice that a shortcut to duplicate the basic colors is to leave out true_colors entirely:
```{ CSharp, "csharp.ascii", "C#", { Colors { basic_colors: vec![Color::Blue, Color::Magenta], true_colors: Some(vec![Color::TrueColor{ r:0, g:0, b:255 }, Color::TrueColor{ r:255, g:0, b:255 }]) } }, "c#" },```
```{ CSharp, "csharp.ascii", "C#", { Colors { basic_colors: vec![Color::Blue, Color::Magenta], true_colors: None } }, "c#" },```
```{ CSharp, "csharp.ascii", "C#", { vec![Color::Blue, Color::Magenta] }, "c#" },```
- You must always provide an array of basic colors
- Optionally, you may provide true colors in a second array of colors separated from the first array by a colon
- One last approach allows you to define colors using the Colors structure itself
- Make sure if you use true colors that the number of true colors matches the number of basic colors
- For example, the following are equivalent:
```
{ CSharp, "csharp.ascii", "C#", define_colors!( [Color::Blue, Color::Magenta] ), "c#" },
{ CSharp, "csharp.ascii", "C#", define_colors!( [Color::Blue, Color::Magenta] : [Color::TrueColor{ r:0, g:255, b:255 }, Color::TrueColor{ r:255, g:0, b:255 } ] ), "c#" },
{ CSharp, "csharp.ascii", "C#", define_colors!( Colors { basic_colors: vec![Color::Blue, Color::Magenta] , true_colors: Some(vec![Color::TrueColor{ r:0, g:255, b:255 }, Color::TrueColor{ r:255, g:0, b:255 } ] ) } ), "c#" },
```

### Project-specific notes

Expand Down
Loading

0 comments on commit 074e238

Please sign in to comment.