Skip to content

braille.scad

Adrian Mariano edited this page Apr 21, 2024 · 9 revisions

LibFile: braille.scad

Create braille dots. Transcribe text to braille with contractions. Currently English Grade 2 braille (EBAE) is supported.

To use, add the following lines to the beginning of your file:

include <BOSL2/std.scad>
include <brailleSCAD/en-us-g2.scad>
include <brailleSCAD/braille.scad>

File Contents

  1. Section: Braille Overview and Printing

  2. Section: Braille Modules and Functions

    • braille() – Create braille dots for a text string with transcription to contracted braille. [Geom]
    • braille_unicode() – Convert unicode braille to a braille dots list [Dots]
    • braille_transcribe() – Transcribe English text into braille dots [Dots]

Section: Braille Overview and Printing

Braille is a writing system using raised dots that can be read with the fingers by people with impaired vision. Many different languages can be written using braille. A "braille cell" is the basic unit of the system. A braille cell consists of a 3 x 2 arrangement of dots. The dot positions are identified by numbers:

Figure 1: A single braille cell with its dots labeled by their numbers

Braille Overview and Printing Figure 1

One way to refer to a braille character is to list its dots numerically. In this library you can do that by giving a string like "245" or a number like 1246, which specifies which dots are present in the character. The number zero indicates an empty cell with no dots.

One might expect a simple mapping between text in a language like English and the braille characters. But the situation is much more complex. Braille takes up a lot of space so to make texts and books smaller, the convention of using braille "contractions" was developed. These contractions replace longer strings of letters like "ing" with their own symbol, 346 in the case of "ing". The use of contractions varies with language and may be complicated by rules about when exactly contractions can or cannot be used.

This library takes contraction rules from a standard braille library called liblouis and uses those rules to produce the contracted form ("grade 2") of US English braille, EBAE (English Braile American Edition). It may eventually be possible to add other languages or UEB (Unified English Braille).

Printing braille dots with a FDM printer is challenging. The dots are very small so in a horizontal layout, stringing tends to be a severe problem, and the dots develop undesirable sharp tips. Printing vertically appears to be much easier. In either case, it seems unlikely that ADA compliant output is possible with FDM printing.

Section: Braille Modules and Functions

Module: braille()

Synopsis: Create braille dots for a text string with transcription to contracted braille. [Geom]

Usage:

  • braille(text, [size=], [style=], [method=], [anchor=], [orient=], [spin=]) {ATTACHENTS};

Description:

Displays a row of braille characters. The interpretation of the text argument depends on the specified method. If the method is "dots" then text is a list of numbers or text string numbers that list the dots of each character. These numbers are the standard numerical representation for braille, where 1 represents the top left dot, 3 the bottom left dot, 4 the top right dot and 6 the bottom right dot. If method is "unicode" then the input must be a unicode text string where each character is either a space or a 6-dot braille unicode character from U+2800 to U+283F. Finally, method can be "un-en-g2", in which case text should be an English language text string, which will be transcribed into contracted English US grade 2 braille (EBAE). Note that the en-us-g2.scad transcription table must be included before braille.scad for the library to work.

At the moment, three styles of braille dot output are supported. The goal is to identify the best one(s) and remove the rest, so available styles may change. Current styles are "sphere", "cone", and "cyl". Reportedly when printing using FDM, "cone" is the best for vertical surfaces and sphere is the best for horizontal surfaces.

Anchoring is relative to the margins of the text block, not the actual edges of the dots. This means you can position texts together horizontally or vertically and the spacing should be correct.

Arguments:

By Position What it does
text input text to display, either English language text, unicode text, or a list of numerical dot values depending on method.
By Name What it does
size size of braille output, either "small" or "large". Default: "small"
method method for braille display, one of "en-us-g2", "unicode", or "dots". Default: "en-us-g2"
style style for braille dots. Default: "sphere".
anchor Translate so anchor point is at the origin (0,0,0). Default: CENTER
spin Rotate this many degrees around the Z axis after anchor. Default: 0
orient Vector to rotate top towards, after spin. Default: UP

Example 1:

braille() Example 1
include <BOSL2/std.scad>
include <brailleSCAD/en-us-g2.scad>
include <brailleSCAD/braille.scad>
braille("⠿⠺⠱ ⠞⠉⠀⠇",method="unicode", $fn=32);

Example 2:

braille() Example 2
include <BOSL2/std.scad>
include <brailleSCAD/en-us-g2.scad>
include <brailleSCAD/braille.scad>
braille([123456,1234,123456,15,123456],style="cone",method="dots",$fn=22);

Example 3:

braille() Example 3
include <BOSL2/std.scad>
include <brailleSCAD/en-us-g2.scad>
include <brailleSCAD/braille.scad>
braille(["245","145","","12", 134,346,"1","16"],style="cyl", method="dots", $fn=22);

Example 4:

braille() Example 4
include <BOSL2/std.scad>
include <brailleSCAD/en-us-g2.scad>
include <brailleSCAD/braille.scad>
braille("This is a test.", $fn=22);



Example 5:

braille() Example 5
include <BOSL2/std.scad>
include <brailleSCAD/en-us-g2.scad>
include <brailleSCAD/braille.scad>
braille("The value 44 is smaller than 132.", $fn=22);

Example 6:

braille() Example 6
include <BOSL2/std.scad>
include <brailleSCAD/en-us-g2.scad>
include <brailleSCAD/braille.scad>
braille("Look look LOOK LOOk", $fn=22);

Example 7:

braille() Example 7
include <BOSL2/std.scad>
include <brailleSCAD/en-us-g2.scad>
include <brailleSCAD/braille.scad>
braille("Hello World! Information.",$fn=22);

Example 8: Chaining together rows of braille with left-alignment, where each braile() object is a child of the one before. Each row is in a different style.

braille() Example 8
include <BOSL2/std.scad>
include <brailleSCAD/en-us-g2.scad>
include <brailleSCAD/braille.scad>
$fn=22;
cuboid([40, 38, 5]){
  fwd(3)right(4)
  position(TOP+BACK+LEFT)braille("One",anchor=BOTTOM+BACK+LEFT)
    position(FWD+LEFT)braille("Two", style="cone", anchor=BACK+LEFT)
    position(FWD+LEFT)braille("Three", style="cyl", anchor=BACK+LEFT);
}

Example 9: Attaching rows of braille to a face of a cube and then chaining rows with center alignment, where each braille() object is a child of the one before. This orientation of braille prints better on FDM printers.

braille() Example 9
include <BOSL2/std.scad>
include <brailleSCAD/en-us-g2.scad>
include <brailleSCAD/braille.scad>
cuboid([70, 14, 34]){
  up(15)
    attach(FRONT)
      braille("Top line",anchor=BOTTOM+BACK)
      position(FWD)braille("Middle line",anchor=BACK)
      position(FWD)braille("Last!",anchor=BACK);
}

Function: braille_unicode()

Synopsis: Convert unicode braille to a braille dots list [Dots]

Usage:

  • braille_dots = braille_unicode(str);

Description:

Converts a string of braille unicode (which may include ASCII space characters) into a list of braille dot numbers. This output is suitable for display with braille() using the "dots" method.

Example 1:

include <BOSL2/std.scad>
include <brailleSCAD/en-us-g2.scad>
include <brailleSCAD/braille.scad>
dots = braille_unicode("⠿⠺⠱ ⠞⠉⠀⠇");  // Produces [123456, 2456, 156, 0, 2345, 14, 0, 123]




Function: braille_transcribe()

Synopsis: Transcribe English text into braille dots [Dots]

Usage:

  • braille_dots = braille_transcribe(text);

Description:

Transcribes a single line of English text into contracted English US grade 2 braille (EBAE: Englishi Braile: American Edition). The output is a list of numbers specifying braille dots in the usual notation, where the digits 1-6 correspond to the dots in each braille character. Any unicode braille characters encountered in the in put are also translated to dots.

Example 1:

include <BOSL2/std.scad>
include <brailleSCAD/en-us-g2.scad>
include <brailleSCAD/braille.scad>
echo(braille_transcribe("This is a test."));  // Returns  [6, 1456, 0, 24, 234, 0, 1, 0, 2345, 15, 34, 256]