Text-based canvas using braille characters.
Bytemap creates bitmaps using Unicode braille characters, where each character represents a 2x4 grid of pixels. This enables reasonably high-resolution text-based graphics in terminal output.
Text-based canvas using braille characters. Bytemap creates bitmaps using Unicode braille characters, where each character represents a 2x4 grid of pixels. This enables reasonably high-resolution text-based graphics in terminal output.
(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:
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
(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.
(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.
(canvas->string {:keys [width height pixels]})Converts a canvas to a string representation using braille characters.
Returns a multi-line string where each line represents one row of the canvas.
Converts a canvas to a string representation using braille characters. Returns a multi-line string where each line represents one row of the canvas.
(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.
(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.
(new-canvas width height)Creates a new canvas with the specified width and height in 'pixels'.
Each pixel is a braille character representing a 2x4 grid of subpixels. So, a 10x5 canvas has dimensions of 20x20 in subpixel coordinates.
Creates a new canvas with the specified width and height in 'pixels'. Each pixel is a braille character representing a 2x4 grid of subpixels. So, a 10x5 canvas has dimensions of 20x20 in subpixel coordinates.
(print-canvas! canvas)Prints a canvas to stdout using braille characters.
Outputs line-by-line to avoid buffer boundary issues with multibyte characters.
Prints a canvas to stdout using braille characters. Outputs line-by-line to avoid buffer boundary issues with multibyte characters.
(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.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |