diff options
author | grian <54550982+grian32@users.noreply.github.com> | 2021-01-20 16:48:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-20 15:48:57 +0100 |
commit | 47263ef6fafdad22546396f9e2ce1ca020c7cd3d (patch) | |
tree | 0b80424f4c137612d0119b3a09a2ffa88b70672c | |
parent | 0a159bea15473254399e80c8e1536c0bb7f80fcf (diff) |
docs(std/fmt): Add examples of colors.ts usage (#9159)
-rw-r--r-- | std/fmt/README.md | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/std/fmt/README.md b/std/fmt/README.md index d71fdf4d0..8c44d78a7 100644 --- a/std/fmt/README.md +++ b/std/fmt/README.md @@ -7,6 +7,10 @@ If you are looking for the documentation proper, skip to: "printf: prints formatted output" +and + + "Colors" + below. ## Discussion @@ -190,6 +194,47 @@ Too few arguments: S("%d") %!(MISSING 'd')" +# Colors + +Adds functions used for displaying colored text. + +## Usage + +```typescript +import { + bgBlue, + bgRgb24, + bgRgb8, + bold, + italic, + red, + rgb24, + rgb8, +} from "https://deno.land/std@$STD_VERSION/fmt/colors.ts"; + +console.log(bgBlue(italic(red(bold("Hello, World!"))))); + +// also supports 8bit colors + +console.log(rgb8("Hello, World!", 42)); + +console.log(bgRgb8("Hello, World!", 42)); + +// and 24bit rgb + +console.log(rgb24("Hello, World!", { + r: 41, + g: 42, + b: 43, +})); + +console.log(bgRgb24("Hello, World!", { + r: 41, + g: 42, + b: 43, +})); +``` + [1]: https://pubs.opengroup.org/onlinepubs/009695399/functions/fprintf.html [2]: https://golang.org/pkg/fmt/ [3]: https://console.spec.whatwg.org/#object-formats |