aboutsummaryrefslogtreecommitdiff
path: root/LS47.scad
blob: c97d45ba18648bd94d75a88f64d61fc6d572a2e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115

// No license, but send me a hello if you use this for some good purpose.
// -- Mirek Kratochvil <exa.exa@gmail.com>

//TODO: round corners?

font = "Consolas"; //URW Bookman L looks nicely here as well
font2 = "Droid Sans Mono";

alphabet = "en";

//inch-sized tiles look imperial.
tilesize=25.4;
//you might like them a bit larger if you want to use this outdoors

//distance between tiles
off=tilesize*1.1;
//height 1/8"
tileheight=tilesize/8;
fontheight=tileheight*0.5;
corner=tileheight*2;

//accomodate for Ё
if (alphabet=="ru") { 
        fontheight=fontheight*0.9;
}

module arrow(n) {
    if (n>=1) for(i=[0:n-1]) translate([i-(n-1)/2,0,0]) polygon([[0.45,0],[0,0.7],[-0.45,0]]);
}

//this produces one tile
module tilec(letter, x, y, c) {
  xx = ((x+3)%7)-3;
  yy = ((y+3)%7)-3;
  dx = sign(xx);
  dy = sign(yy);
  translate([x*off,(6-y)*off,0]) {
    difference() {
      color(c) union() {
        cube([tilesize,tilesize-corner,tileheight]);
        translate([corner, tilesize-corner,0])
          cube([tilesize-2*corner, corner, tileheight]);
        translate([corner, tilesize-corner, 0])
          cylinder(tileheight, corner, corner);
        translate([tilesize-corner, tilesize-corner, 0])
          cylinder(tileheight, corner, corner);
      };
      color("white") {
        translate([tilesize*(0.5-dx*0.13),tilesize*(0.275-dy*0.13),tileheight*.51])
        linear_extrude (height=tileheight/2)
          text(letter, font=font, size=tilesize*.45,
               halign="center", valign="baseline");
      }
      color("white")
      translate([tilesize*(0.5+dx*0.3), tilesize*0.5, tileheight*.76])
        scale(4*[dx,1,1])
          rotate([0,0,-90])
          linear_extrude(height=tileheight/4)
            arrow(abs(xx));
      color("white")
      translate([tilesize*0.5, tilesize*(0.5+dy*0.3), tileheight*.76])
        scale(4*[1,dy,1])
        linear_extrude(height=tileheight/4)
          arrow(abs(yy));
    }
  }
}

//tiles
module tile(letter,x,y) {
   tilec(letter,x,y,"darkgray");
}

module tiles(letters) {
    for(i=[0,1,2,3,4,5,6]) for (j=[0,1,2,3,4,5,6]) {
        tile(letters[i+7*j], i, j);
    }
}

if (alphabet=="en") {
    // latin variant of tiles
    tiles(
        ["□", "A", "B", "C", "D", "E", "F",
        "G", "H", "I", "J", "K", "L", "M",
        "N", "O", "P", "Q", "R", "S", "T",
        "U", "V", "W", "X", "Y", "Z", ".",
        "/", ":", "?", "!", "'", "(", ")",
        "0", "1", "2", "3", "4", "5", "6",
        "7", "8", "9", ",", "-", "+", "*"]
    );
} else if (alphabet=="ru") {
    // variant of tiles thanks to Stas Bushuev
    // (see https://github.com/Xitsa/ls47 for other versions)
    tiles(
        ["□", "А", "Б", "В", "Г", "Д", "Е",
        "Ё", "Ж", "З", "И", "Й", "К", "Л",
        "М", "Н", "О", "П", "Р", "С", "Т",
        "У", "Ф", "Х", "Ц", "Ч", "Ш", "Щ",
        "Ъ", "Ы", "Ь", "Э", "Ю", "Я", ".",
        "0", "1", "2", "3", "4", "5", "6",
        "7", "8", "9", "/", ",", "?", "!"]
    );
}

//the token
translate([-off/2,off/2,0]) {
    color("red") difference() {
      cylinder(h=tileheight, d=tilesize);
      translate([0,0,-.1])
        cylinder(h=tileheight*1.2, d=tilesize-2*tileheight);
    }
}