# bitmap-to-braille

> Bitmap to unicode braille converter

Latest version **1.0.0** (published 2018-04-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install bitmap-to-braille
pnpm add bitmap-to-braille
yarn add bitmap-to-braille
bun add bitmap-to-braille
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2018-04-11 |
| First published | 2018-04-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 124.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | András Parditka |
| Maintainers | andraaspar |

## Links

- npm: https://www.npmjs.com/package/bitmap-to-braille
- Repository: https://github.com/andraaspar/bitmap-to-braille
- Homepage: https://github.com/andraaspar/bitmap-to-braille#readme
- Issues: https://github.com/andraaspar/bitmap-to-braille/issues
- npm.io page: https://npm.io/package/bitmap-to-braille

## Recent versions

- 1.0.0 (latest) — 2018-04-11

## README

# bitmap-to-braille

> Bitmap to unicode braille converter

## Install

```
npm i bitmap-to-braille
```
or
```
yarn add bitmap-to-braille
```

## Examples

### Generate from code

```JS
const { bitmapToBraille, CHAR_WIDTH, CHAR_HEIGHT } = require('bitmap-to-braille')

const bitmap = `
  oooo
 o    o
o o  o o
o      o
o o  o o
o  oo  o
 o    o
  oooo
`.replace(/^\n|\n$/g, '').split(`\n`)

console.log(
	bitmapToBraille({
		widthPixels: CHAR_WIDTH * 4,
		heightPixels: CHAR_HEIGHT * 2,
		pixelIsLit: (x, y) => bitmap[y][x] === 'o',
	})
)
/* Output:
⡔⠍⠩⢢
⠣⣑⣊⠜
*/
```

### Generate from image

```JS
const { bitmapToBraille, CHAR_WIDTH, CHAR_HEIGHT } = require('bitmap-to-braille')
const Jimp = require('jimp')

Jimp.read('smiley.png')
	.then(img => {
		const width = CHAR_WIDTH * 24
		const ratio = width / img.bitmap.width
		const height = Math.round(img.bitmap.height * ratio / CHAR_HEIGHT) * CHAR_HEIGHT
		return img.resize(width, height).grayscale()
	})
	.then(img => {
		const { width, height, data } = img.bitmap
		console.log(
			bitmapToBraille({
				widthPixels: width,
				heightPixels: height,
				pixelIsLit: (x, y) => data.readUInt8(y * width * 4 + x * 4) <= 127,
			})
		)
	})
	.catch(console.error)
/* Output:
⠀⠀⠀⠀⠀⠀⣀⣤⡴⠶⠚⠛⠛⠓⠶⢦⣤⣀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⢀⣴⠞⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠳⣦⡀⠀⠀⠀
⠀⠀⣰⠟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠻⣆⠀⠀
⠀⣼⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣧⠀
⢰⡏⠀⠀⠀⠀⢰⣿⠀⠀⠀⠀⣾⡇⠀⠀⠀⠀⠀⠀⠀⠀⢹⡆
⣾⠀⠀⠀⠀⠀⠸⠟⠀⠀⠀⠀⠻⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⣷
⢿⠀⠀⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡄⠀⠀⠀⠀⡿
⠸⣇⠀⠙⢆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡰⠟⠀⠀⠀⣸⠇
⠀⢻⡄⠀⠀⠑⢄⡀⠀⠀⠀⠀⠀⠀⠀⡠⠞⠁⠀⠀⠀⢠⡟⠀
⠀⠀⠹⣦⡀⠀⠀⠉⠓⠲⠤⠤⠖⠒⠉⠀⠀⠀⠀⢀⣴⠏⠀⠀
⠀⠀⠀⠈⠻⢦⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⡴⠟⠁⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠉⠛⠳⠶⢤⣤⣤⡤⠶⠞⠛⠉⠀⠀⠀⠀⠀⠀
*/
```

## License

MIT

---
_Source: https://npm.io/package/bitmap-to-braille · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
