Liking cljdoc? Tell your friends :D

bytemap.core

Text-based canvas using braille or block octant characters.

Bytemap creates bitmaps using Unicode characters that divide a character cell into a 2x4 grid of pixels: braille patterns by default, or the Unicode 16 block octants. This enables reasonably high-resolution text-based graphics in terminal output.

Text-based canvas using braille or block octant characters.

Bytemap creates bitmaps using Unicode characters that divide a character cell
into a 2x4 grid of pixels: braille patterns by default, or the Unicode 16
block octants. This enables reasonably high-resolution text-based graphics in
terminal output.
raw docstring

bit-of-subpixelclj/s

(bit-of-subpixel [x y])

Maps a subpixel coordinate [x y] to its corresponding bit position (0-7).

The mapping follows the braille standard layout:

  • x is 0-1 (left or right column)
  • y is 0-3 (top to bottom)

The bit layout is: [0,0]=0 [1,0]=3 [0,1]=1 [1,1]=4 [0,2]=2 [1,2]=5 [0,3]=6 [1,3]=7

Maps a subpixel coordinate [x y] to its corresponding bit position (0-7).

The mapping follows the braille standard layout:
- x is 0-1 (left or right column)
- y is 0-3 (top to bottom)

The bit layout is:
  [0,0]=0  [1,0]=3
  [0,1]=1  [1,1]=4
  [0,2]=2  [1,2]=5
  [0,3]=6  [1,3]=7
sourceraw docstring

blockclj/s

(block byte-val)

Converts a byte (0-255) to a Unicode block octant character.

Each bit in the byte corresponds to one of the 8 cells of the 2x4 grid, using the same layout as braille.

Converts a byte (0-255) to a Unicode block octant character.

Each bit in the byte corresponds to one of the 8 cells of the 2x4 grid, using
the same layout as `braille`.
sourceraw docstring

boundsclj/s

(bounds {:keys [width height]})

Returns the canvas dimensions in subpixels [width height], where each pixel is 2x4 subpixels.

Returns the canvas dimensions in subpixels [width height], where each pixel is 2x4 subpixels.
sourceraw docstring

brailleclj/s

(braille byte-val)

Converts a byte (0-255) to a braille Unicode character.

Each bit in the byte corresponds to one of the 8 dots in a braille character. The byte is added to the braille Unicode offset (0x2800) to get the final character.

Converts a byte (0-255) to a braille Unicode character.

Each bit in the byte corresponds to one of the 8 dots in a braille character.
The byte is added to the braille Unicode offset (0x2800) to get the final character.
sourceraw docstring

canvas->stringclj/s

(canvas->string {:keys [width height pixels style] :or {style :braille}})

Converts a canvas to a string representation, using the canvas style.

Returns a multi-line string where each line represents one row of the canvas.

Converts a canvas to a string representation, using the canvas style.

Returns a multi-line string where each line represents one row of the canvas.
sourceraw docstring

draw-lineclj/s

(draw-line canvas start end)

Draws a line from start point to end point using Bresenham’s algorithm.

Returns a new canvas with the line drawn. Both start and end are subpixel coordinates.

Draws a line from start point to end point using Bresenham’s algorithm.

Returns a new canvas with the line drawn. Both start and end are subpixel
coordinates.
sourceraw docstring

draw-pointclj/s

(draw-point canvas point)
(draw-point canvas [x y] value)

Draws a point at subpixel coordinates [x y] on the canvas.

Returns a new canvas with the point drawn. Coordinates are rounded to nearest integer. Points outside canvas bounds are silently ignored.

The optional value parameter determines whether to set (true) or clear (false) the point. Defaults to true.

Draws a point at subpixel coordinates [x y] on the canvas.

Returns a new canvas with the point drawn. Coordinates are rounded to
nearest integer. Points outside canvas bounds are silently ignored.

The optional value parameter determines whether to set (true) or clear (false)
the point. Defaults to true.
sourceraw docstring

new-canvasclj/s

(new-canvas width height & {:keys [style] :or {style :braille}})

Creates a new canvas with the specified width and height in 'pixels'.

Each pixel is a character representing a 2x4 grid of subpixels. So, a 10x5 canvas has dimensions of 20x20 in subpixel coordinates.

Options:

  • :style - :braille (default) or :blocks, the characters the canvas renders with. :blocks needs a font with Unicode 16 block octants.
Creates a new canvas with the specified width and height in 'pixels'.

Each pixel is a character representing a 2x4 grid of subpixels. So, a 10x5
canvas has dimensions of 20x20 in subpixel coordinates.

Options:
- :style - :braille (default) or :blocks, the characters the canvas renders
           with. :blocks needs a font with Unicode 16 block octants.
sourceraw docstring

(print-canvas! canvas)

Prints a canvas to stdout using the canvas style.

Outputs line-by-line to avoid buffer boundary issues with multibyte characters.

Prints a canvas to stdout using the canvas style.

Outputs line-by-line to avoid buffer boundary issues with multibyte characters.
sourceraw docstring

set-subpixelclj/s

(set-subpixel num subpixel value)

Sets or clears a specific subpixel in a byte value.

Returns a new byte with the specified subpixel bit set or cleared.

Sets or clears a specific subpixel in a byte value.

Returns a new byte with the specified subpixel bit set or cleared.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close