-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
48 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Snapper 📷 | ||
|
||
> Snapper allows you to generate images of ANSI formatted text. | ||
> 🚧 Project is WIP, expect breaking changes | ||
# Usage | ||
|
||
#### Set up puppeteer | ||
> In the background the module uses [deno Puppeteer](https://deno.land/x/puppeteer@9.0.2), which is a wrapper around [Puppeteer](https://github.com/puppeteer/puppeteer). | ||
Follow the [current setup steps](https://github.com/lucacasonato/deno-puppeteer#installation), the basic setups should be something like: | ||
|
||
```bash | ||
PUPPETEER_PRODUCT=chrome deno run -A --unstable https://deno.land/x/puppeteer@9.0.2/install.ts | ||
|
||
#windows | ||
$env:PUPPETEER_PRODUCT='chrome'; deno run -A --unstable https://deno.land/x/puppeteer@9.0.2/install.ts | ||
``` | ||
|
||
## Module | ||
|
||
```ts | ||
import { snap } from "https://deno.land/x/snapper/mod.ts"; | ||
|
||
await snap([ | ||
{content: `\x1b[42m \x1b[1m\x1b[37mSnapper\x1b[39m\x1b[22m 📷 \x1b[49m`, imageSavePath: 'snapper.png', viewport: {width: 145, height: 35}}, | ||
]); | ||
``` | ||
|
||
> To run it, you will need `--allow-env`, `--allow-net`, `--allow-write`, `--allow-read`, `--unstable`. | ||
The result should be a png file placed into `cwd+imageSavePath`: | ||
![result](./docs/snapper.png) | ||
|
||
When creating multiple images, provide your inputs to `snap` in bulk, otherwise, calling the function one-by-one will take a lot of time to finish. | ||
|
||
To get whole image for the output, simply leave out the `viewport` property from the parameters. | ||
|
||
> `height` cuts the image, while a small `width` will result in the content wrapping | ||
# TODO | ||
|
||
- [ ] Try polyfill DOM+canvas, use xterm without puppeteer | ||
- [ ] Improve server, so it can be hosted as a standalone site |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters