1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-23 07:44:48 -05:00

docs(std/fmt): Add examples of colors.ts usage (#9159)

This commit is contained in:
grian 2021-01-20 16:48:57 +02:00 committed by GitHub
parent 0a159bea15
commit 47263ef6fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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