diff --git a/bitmap/README b/bitmap/README new file mode 100644 index 0000000..d1d27cc --- /dev/null +++ b/bitmap/README @@ -0,0 +1,17 @@ +This is an OpenSCAD module that let's you easily (well kinda) create 3D text. I've emulated the Atari 8-Bit fonts A-Z, a-z, 0-9, and most punctuation. You can create them a letter at a time or pass an array of characters. (OpenSCAD doesn't have any real string manipulation) + +It also has a bitmap module that you can use to define your own fonts. It's pretty simple, you pass it an array of numbers, then tell it how many bits per row and it creates cubes (of configurable width and height) in a grid and combines them into a single shape. The number in the array sets the pixel height modifier. So if you set height to 5 and the array value is 2, then the height of that pixel will be 10mm. + +Be careful when defining your own bitmaps in that you can't have two bits only connected diagonally. Otherwise OpenSCAD will say it's not manifold. For instance you can't have: + +0 0 0 +0 1 0 +0 0 1 + +But you can have: + +0 0 0 +0 1 1 +0 0 1 + +For more info see: http://www.thingiverse.com/thing:2054 diff --git a/bitmap/alphabet_block.scad b/bitmap/alphabet_block.scad new file mode 100644 index 0000000..85d8084 --- /dev/null +++ b/bitmap/alphabet_block.scad @@ -0,0 +1,24 @@ +/* +Parametric Alphabet Block +Tony Buser +http://tonybuser.com +http://creativecommons.org/licenses/by/3.0/ +*/ + + + +// change to any letter +letter = "A"; + +union() { + difference() { + cube(size = 20); + translate(v = [2, 2, 17]) { + cube(size = [16, 16, 5]); + } + } + + translate(v = [10, 10, 15]) { + 8bit_char(letter, 2, 5); + } +} \ No newline at end of file diff --git a/bitmap/bitmap.scad b/bitmap/bitmap.scad new file mode 100644 index 0000000..38a0d0d --- /dev/null +++ b/bitmap/bitmap.scad @@ -0,0 +1,1067 @@ +/* +Bitmap and 8Bit Font Module +Tony Buser +http://tonybuser.com +http://creativecommons.org/licenses/by/3.0/ +*/ + +module bitmap(bitmap, block_size, height, row_size) { + width = block_size * row_size; + bitmap_size = row_size * row_size; + + function loc_x(loc) = floor(loc / row_size) * block_size; + function loc_y(loc) = loc % row_size * block_size; + function loc_z(loc) = (bitmap[loc]*height-height)/2; + + translate(v = [-width/2+block_size/2,-width/2+block_size/2,height/2]) { + for (loc = [0:bitmap_size - 1]) { + if (bitmap[loc] != 0) { + union() { + translate(v = [loc_x(loc), loc_y(loc), loc_z(loc)]) { + cube(size = [block_size, block_size, height * bitmap[loc]], center = true); + } + } + } + } + } +} + +module 8bit_char(char, block_size, height, include_base) { + if (char == "0") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,1,1,1,0, + 0,1,1,1,1,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "1") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,1,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,1,1,1,1,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "2") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,0,0,0,1,1,0,0, + 0,0,0,1,1,0,0,0, + 0,0,1,1,0,0,0,0, + 0,1,1,1,1,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "3") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,1,1,1,1,0, + 0,0,0,0,1,1,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,0,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "4") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,1,1,0,0, + 0,0,0,1,1,1,0,0, + 0,0,1,1,1,1,0,0, + 0,1,1,0,1,1,0,0, + 0,1,1,1,1,1,1,0, + 0,0,0,0,1,1,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "5") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,1,1,1,1,0, + 0,1,1,0,0,0,0,0, + 0,1,1,1,1,1,0,0, + 0,0,0,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "6") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "7") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,1,1,1,1,0, + 0,0,0,0,0,1,1,0, + 0,0,0,0,1,1,0,0, + 0,0,0,1,1,0,0,0, + 0,0,1,1,0,0,0,0, + 0,0,1,1,0,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "8") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "9") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,1,0, + 0,0,0,0,0,1,1,0, + 0,0,0,0,1,1,0,0, + 0,0,1,1,1,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "A") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,1,1,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "B") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,1,1,1,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "C") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "D") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,1,1,0,0,0, + 0,1,1,0,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,1,1,0,0, + 0,1,1,1,1,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "E") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,1,1,1,1,0, + 0,1,1,0,0,0,0,0, + 0,1,1,1,1,1,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,1,1,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "F") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,1,1,1,1,0, + 0,1,1,0,0,0,0,0, + 0,1,1,1,1,1,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "G") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,1,1,0, + 0,1,1,0,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,0,1,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "H") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,1,1,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "I") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,1,1,1,1,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,1,1,1,1,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "J") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,1,1,1,0, + 0,0,0,0,0,1,1,0, + 0,0,0,0,0,1,1,0, + 0,0,0,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "K") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,1,1,0,0, + 0,1,1,1,1,0,0,0, + 0,1,1,1,1,0,0,0, + 0,1,1,0,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "L") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,1,1,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "M") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,0,1,1, + 0,1,1,1,0,1,1,1, + 0,1,1,1,1,1,1,1, + 0,1,1,0,1,0,1,1, + 0,1,1,0,0,0,1,1, + 0,1,1,0,0,0,1,1, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "N") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,1,0,1,1,0, + 0,1,1,1,1,1,1,0, + 0,1,1,1,1,1,1,0, + 0,1,1,0,1,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "O") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "P") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,1,1,1,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "Q") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,1,1,1,0,0, + 0,0,1,1,0,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "R") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,1,1,1,0,0, + 0,1,1,0,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "S") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,1,1,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,0,0,0,0,1,1,0, + 0,0,0,0,0,1,1,0, + 0,0,1,1,1,1,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "T") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,1,1,1,1,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "U") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,1,1,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "V") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "W") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,0,1,1, + 0,1,1,0,0,0,1,1, + 0,1,1,0,1,0,1,1, + 0,1,1,1,1,1,1,1, + 0,1,1,1,0,1,1,1, + 0,1,1,0,0,0,1,1, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "X") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,0,0, + 0,0,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "Y") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "Z") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,1,1,1,1,0, + 0,0,0,0,1,1,0,0, + 0,0,0,1,1,0,0,0, + 0,0,1,1,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,1,1,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "a") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,0,0,0,0,1,1,0, + 0,0,1,1,1,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "b") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,1,1,1,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "c") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "d") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,1,1,0, + 0,0,0,0,0,1,1,0, + 0,0,1,1,1,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "e") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,1,1,1,1,0, + 0,1,1,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "f") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,1,1,1,0, + 0,0,0,1,1,0,0,0, + 0,0,1,1,1,1,1,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "g") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,1,0, + 0,0,0,0,0,1,1,0, + 0,1,1,1,1,1,0,0 + ], block_size, height, 8); + } else if (char == "h") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "i") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,1,1,1,1,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "j") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,1,1,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,1,1,0, + 0,0,0,0,0,1,1,0, + 0,0,0,0,0,1,1,0, + 0,0,0,0,0,1,1,0, + 0,0,1,1,1,1,0,0 + ], block_size, height, 8); + } else if (char == "k") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,0,1,1,0,0, + 0,1,1,1,1,0,0,0, + 0,1,1,0,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "l") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,1,1,1,1,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "m") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,1,1,1,1,1, + 0,1,1,1,1,1,1,1, + 0,1,1,0,1,0,1,1, + 0,1,1,0,0,0,1,1, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "n") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,1,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "o") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "p") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,1,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,1,1,1,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "q") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,1,0, + 0,0,0,0,0,1,1,0, + 0,0,0,0,0,1,1,0 + ], block_size, height, 8); + } else if (char == "r") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,1,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "s") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,1,1,0, + 0,1,1,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,0,0,0,0,1,1,0, + 0,1,1,1,1,1,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "t") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,1,1,0,0,0, + 0,1,1,1,1,1,1,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,0,1,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "u") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "v") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "w") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,0,1,1, + 0,1,1,0,1,0,1,1, + 0,1,1,1,1,1,1,1, + 0,0,1,1,1,1,1,0, + 0,0,1,1,0,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "x") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,0,0, + 0,0,0,1,1,0,0,0, + 0,0,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "y") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,1,0, + 0,0,0,0,1,1,0,0, + 0,1,1,1,1,0,0,0 + ], block_size, height, 8); + } else if (char == "z") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,1,1,1,1,1,1,0, + 0,0,0,0,1,1,0,0, + 0,0,0,1,1,0,0,0, + 0,0,1,1,0,0,0,0, + 0,1,1,1,1,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "+") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,1,1,1,1,1,1,0, + 0,1,1,1,1,1,1,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "-") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,1,1,1,1,1,1,0, + 0,1,1,1,1,1,1,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == ":") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == ".") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == ",") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,1,1,0,0,0,0 + ], block_size, height, 8); + } else if (char == "?") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,0,0,0,1,1,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "=") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,1,1,1,1,1,1,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,1,1,1,1,1,1,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "*") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,1,1,0, + 0,0,1,1,1,1,0,0, + 1,1,1,1,1,1,1,1, + 0,0,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "!") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "''") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "#") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,1,1,0, + 1,1,1,1,1,1,1,1, + 0,1,1,0,0,1,1,0, + 0,1,1,0,0,1,1,0, + 1,1,1,1,1,1,1,1, + 0,1,1,0,0,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "$") { + bitmap([ + 0,0,0,1,1,0,0,0, + 0,0,1,1,1,1,1,0, + 0,1,1,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,0,0,0,0,1,1,0, + 0,1,1,1,1,1,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "%") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,1,1,0,0, + 0,0,1,1,1,0,0,0, + 0,0,1,1,0,0,0,0, + 0,1,1,0,0,1,1,0, + 0,1,0,0,0,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "&") { + bitmap([ + 0,0,0,1,1,1,0,0, + 0,0,1,1,0,1,1,0, + 0,0,0,1,1,1,0,0, + 0,0,1,1,1,0,0,0, + 0,1,1,0,1,1,1,1, + 0,1,1,0,1,1,1,0, + 0,0,1,1,1,0,1,1, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "@") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,1,1,0,0,1,1,0, + 0,1,1,0,1,1,1,0, + 0,1,1,0,1,1,1,0, + 0,1,1,0,0,0,0,0, + 0,0,1,1,1,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "'") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "(") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,1,1,1,0,0, + 0,0,1,1,1,0,0,0, + 0,0,1,1,0,0,0,0, + 0,0,1,1,0,0,0,0, + 0,0,1,1,1,0,0,0, + 0,0,0,1,1,1,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == ")") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,0,0,0, + 0,0,0,1,1,1,0,0, + 0,0,0,0,1,1,0,0, + 0,0,0,0,1,1,0,0, + 0,0,0,1,1,1,0,0, + 0,0,1,1,1,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "<") { + bitmap([ + 0,0,0,0,0,1,1,0, + 0,0,0,0,1,1,0,0, + 0,0,0,1,1,0,0,0, + 0,0,1,1,0,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,0,1,1,0,0, + 0,0,0,0,0,1,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == ">") { + bitmap([ + 0,1,1,0,0,0,0,0, + 0,0,1,1,0,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,0,1,1,0,0, + 0,0,0,1,1,0,0,0, + 0,0,1,1,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "[") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,0,1,1,0,0,0,0, + 0,0,1,1,0,0,0,0, + 0,0,1,1,0,0,0,0, + 0,0,1,1,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "]") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,1,1,1,1,0,0, + 0,0,0,0,1,1,0,0, + 0,0,0,0,1,1,0,0, + 0,0,0,0,1,1,0,0, + 0,0,0,0,1,1,0,0, + 0,0,1,1,1,1,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "/") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,1,1,0, + 0,0,0,0,1,1,0,0, + 0,0,0,1,1,0,0,0, + 0,0,1,1,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,1,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "\") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,1,1,0,0,0,0,0, + 0,0,1,1,0,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,0,1,1,0,0, + 0,0,0,0,0,1,1,0, + 0,0,0,0,0,0,1,0, + 0,0,0,0,0,0,0,0 + ], block_size, height, 8); + } else if (char == "_") { + bitmap([ + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 1,1,1,1,1,1,1,1 + ], block_size, height, 8); + } else if (char == "|") { + bitmap([ + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0, + 0,0,0,1,1,0,0,0 + ], block_size, height, 8); + } else { + echo("Invalid Character: ", char); + } + +} + +module 8bit_str(chars, char_count, block_size, height) { + echo(str("Total Width: ", block_size * 8 * char_count, "mm")); + union() { + for (count = [0:char_count-1]) { + translate(v = [0, count * block_size * 8, 0]) { + 8bit_char(chars[count], block_size, height); + } + } + } +} + +/* + + +block_size = 5; +height = 10; + +union() { + translate(v = [0,0,5]) { + 8bit_char("A", block_size, height); + + //bitmap([ + // 1,1,1,1,1,1,1,1, + // 1,0,0,1,1,0,0,1, + // 1,0,1,1,1,1,0,1, + // 1,1,1,0,0,1,1,1, + // 1,1,1,0,0,1,1,1, + // 1,0,1,1,1,1,0,1, + // 1,0,0,1,1,0,0,1, + // 1,1,1,1,1,1,1,1 + //], block_size, height, 8); + + //bitmap([ + // 1,1,1,1, + // 1,0,0,1, + // 1,0,0,1, + // 1,1,1,1 + //], block_size, height, 4); + } + translate(v = [0,0,5/2]) { + color([0,0,1,1]) { + cube(size = [block_size * 8, block_size * 8, 5], center = true); + } + } +} + + + +chars = ["T","O","N","Y","","B","U","S","E","R"]; +char_count = 10; +block_size = 1; +height = 5; + +union() { + translate(v = [0,-block_size*8*char_count/2+block_size*8/2,5]) { + 8bit_str(chars, char_count, block_size, height); + } + translate(v = [0,0,5/2]) { + color([0,0,1,1]) { + cube(size = [block_size * 8, block_size * 8 * char_count, 5], center = true); + } + } +} +*/ diff --git a/bitmap/height_map.scad b/bitmap/height_map.scad new file mode 100644 index 0000000..6a5e4fa --- /dev/null +++ b/bitmap/height_map.scad @@ -0,0 +1,31 @@ +/* +Height Map Example +Tony Buser +http://tonybuser.com +http://creativecommons.org/licenses/by/3.0/ + +Can also dynamically run this by passing an array on the command line: + +/Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD -m make -D bitmap=[2,2,2,0,1,3,2,2,2] -D row_size=3 -s height_map.stl height_map.scad +*/ + + + +block_size = 5; +height = 5; + +row_size = 10; // 10x10 pixels +bitmap = [ + 1,1,0,0,1,1,0,0,1,1, + 1,1,1,1,1,1,1,1,1,1, + 0,1,2,2,1,1,2,2,1,0, + 0,1,2,1,1,1,1,2,1,0, + 1,1,1,1,3,3,1,1,1,1, + 1,1,1,1,3,3,1,1,1,1, + 0,1,2,1,1,1,1,2,1,0, + 0,1,2,2,1,1,2,2,1,0, + 1,1,1,1,1,1,1,1,1,1, + 1,1,0,0,1,1,0,0,1,1 +]; + +bitmap(bitmap, block_size, height, row_size); diff --git a/bitmap/name_tag.scad b/bitmap/name_tag.scad new file mode 100644 index 0000000..1c22d8a --- /dev/null +++ b/bitmap/name_tag.scad @@ -0,0 +1,29 @@ +/* +Parametric Name Tag +Tony Buser +http://tonybuser.com +http://creativecommons.org/licenses/by/3.0/ +*/ + + + +// change chars array and char_count +// OpenSCAD has no string or length methods :( +chars = ["M","a","k","e","r","B","o","t"]; +char_count = 8; + +// block size 1 will result in 8mm per letter +block_size = 1; +// height is the Z height of each letter +height = 3; + +union() { + translate(v = [0,-block_size*8*char_count/2+block_size*8/2,3]) { + 8bit_str(chars, char_count, block_size, height); + } + translate(v = [0,0,3/2]) { + color([0,0,1,1]) { + cube(size = [block_size * 8, block_size * 8 * char_count, 3], center = true); + } + } +}