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:
parent
0a159bea15
commit
47263ef6fa
1 changed files with 45 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue