Add example files for text() usage.

The test case images are currently not including the text as the example
test run does not include experimental features. This will need to be
updated once the text() feature is not experimental anymore.
master
Torsten Paul 2014-07-07 23:23:46 +02:00
parent 0a5acbde25
commit e8fac2ef97
10 changed files with 209 additions and 0 deletions

View File

@ -0,0 +1,46 @@
// Example for text() usage
// (c) 2014 Torsten Paul
// CC-BY-SA 4.0
$vpr = [0, 0, 0];
$vpt = [-250, 0, -80];
$vpd = 500;
r = 60;
hole = 30;
module t(t, s = 18, style = "") {
rotate([90, 0, 0])
linear_extrude(height = 1)
text(t, size = s, font = str("Liberation Serif", style), $fn = 16);
}
module cut() {
cylinder(r = hole, h = 2.5 * r, center = true, $fn = 60);
}
module logo() {
difference() {
sphere(r = r, $fn = 120);
cut();
rotate([0, 90, 0]) cut();
#rotate([90, 0, 0]) cut();
}
}
module green() {
color([81/255, 142/255, 4/255]) children();
}
module black() {
color([0, 0, 0]) children();
}
translate([110, 0, 80]) {
translate([0, 0, 30]) rotate([25, 25, -40]) logo();
translate([100, 0, 40]) green() t("Open", 42, ":style=Bold");
translate([242, 0, 40]) black() t("SCAD", 42, ":style=Bold");
translate([100, 0, -10]) black() t("The Programmers");
translate([160, 0, -40]) black() t("Solid 3D CAD Modeller");
}

View File

@ -0,0 +1,38 @@
// Example for text() usage
// (c) 2014 Torsten Paul
// CC-BY-SA 4.0
font = "Liberation Sans";
cube_size = 60;
letter_size = 50;
letter_height = 5;
o = cube_size / 2 - letter_height / 2;
module letter(l) {
// Use linear_extrude() to make the letters 3D objects as they
// are only 2D shapes when only using text()
linear_extrude(height = letter_height) {
text(l, size = letter_size, font = font, halign = "center", valign = "center", $fn = 16);
}
}
difference() {
union() {
color("gray") cube(cube_size, center = true);
translate([0, -o, 0]) rotate([90, 0, 0]) letter("C");
translate([o, 0, 0]) rotate([90, 0, 90]) letter("U");
translate([0, o, 0]) rotate([90, 0, 180]) letter("B");
translate([-o, 0, 0]) rotate([90, 0, -90]) letter("E");
}
// Put some symbols on top and bottom using symbols from the
// Unicode symbols table.
// (see https://en.wikipedia.org/wiki/Miscellaneous_Symbols)
//
// Note that depending on the font used, not all the symbols
// are actually available.
translate([0, 0, o]) letter("\u263A");
translate([0, 0, -o - letter_height]) letter("\u263C");
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

@ -0,0 +1,78 @@
group() {
multmatrix([[1, 0, 0, 110], [0, 1, 0, 0], [0, 0, 1, 80], [0, 0, 0, 1]]) {
multmatrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 30], [0, 0, 0, 1]]) {
multmatrix([[0.69427204401, 0.71938369937, 0.02175826214, 0], [-0.58256341607, 0.57946619475, -0.56994630922, 0], [-0.42261826174, 0.38302222155, 0.82139380484, 0], [0, 0, 0, 1]]) {
group() {
difference() {
sphere($fn = 120, $fa = 12, $fs = 2, r = 60);
group() {
cylinder($fn = 60, $fa = 12, $fs = 2, h = 150, r1 = 30, r2 = 30, center = true);
}
multmatrix([[0, 0, 1, 0], [0, 1, 0, 0], [-1, 0, 0, 0], [0, 0, 0, 1]]) {
group() {
cylinder($fn = 60, $fa = 12, $fs = 2, h = 150, r1 = 30, r2 = 30, center = true);
}
}
# multmatrix([[1, 0, 0, 0], [0, 0, -1, 0], [0, 1, 0, 0], [0, 0, 0, 1]]) {
group() {
cylinder($fn = 60, $fa = 12, $fs = 2, h = 150, r1 = 30, r2 = 30, center = true);
}
}
}
}
}
}
multmatrix([[1, 0, 0, 100], [0, 1, 0, 0], [0, 0, 1, 40], [0, 0, 0, 1]]) {
group() {
color([0.317647, 0.556863, 0.0156863, 1]) {
group() {
group() {
multmatrix([[1, 0, 0, 0], [0, 0, -1, 0], [0, 1, 0, 0], [0, 0, 0, 1]]) {
linear_extrude(height = 1, center = false, convexity = 1, scale = [1, 1], $fn = 0, $fa = 12, $fs = 2);
}
}
}
}
}
}
multmatrix([[1, 0, 0, 242], [0, 1, 0, 0], [0, 0, 1, 40], [0, 0, 0, 1]]) {
group() {
color([0, 0, 0, 1]) {
group() {
group() {
multmatrix([[1, 0, 0, 0], [0, 0, -1, 0], [0, 1, 0, 0], [0, 0, 0, 1]]) {
linear_extrude(height = 1, center = false, convexity = 1, scale = [1, 1], $fn = 0, $fa = 12, $fs = 2);
}
}
}
}
}
}
multmatrix([[1, 0, 0, 100], [0, 1, 0, 0], [0, 0, 1, -10], [0, 0, 0, 1]]) {
group() {
color([0, 0, 0, 1]) {
group() {
group() {
multmatrix([[1, 0, 0, 0], [0, 0, -1, 0], [0, 1, 0, 0], [0, 0, 0, 1]]) {
linear_extrude(height = 1, center = false, convexity = 1, scale = [1, 1], $fn = 0, $fa = 12, $fs = 2);
}
}
}
}
}
}
multmatrix([[1, 0, 0, 160], [0, 1, 0, 0], [0, 0, 1, -40], [0, 0, 0, 1]]) {
group() {
color([0, 0, 0, 1]) {
group() {
group() {
multmatrix([[1, 0, 0, 0], [0, 0, -1, 0], [0, 1, 0, 0], [0, 0, 0, 1]]) {
linear_extrude(height = 1, center = false, convexity = 1, scale = [1, 1], $fn = 0, $fa = 12, $fs = 2);
}
}
}
}
}
}
}
}

View File

@ -0,0 +1,47 @@
group() {
difference() {
union() {
color([0.501961, 0.501961, 0.501961, 1]) {
cube(size = [60, 60, 60], center = true);
}
multmatrix([[1, 0, 0, 0], [0, 1, 0, -27.5], [0, 0, 1, 0], [0, 0, 0, 1]]) {
multmatrix([[1, 0, 0, 0], [0, 0, -1, 0], [0, 1, 0, 0], [0, 0, 0, 1]]) {
group() {
linear_extrude(height = 5, center = false, convexity = 1, scale = [1, 1], $fn = 0, $fa = 12, $fs = 2);
}
}
}
multmatrix([[1, 0, 0, 27.5], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
multmatrix([[0, 0, 1, 0], [1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 0, 1]]) {
group() {
linear_extrude(height = 5, center = false, convexity = 1, scale = [1, 1], $fn = 0, $fa = 12, $fs = 2);
}
}
}
multmatrix([[1, 0, 0, 0], [0, 1, 0, 27.5], [0, 0, 1, 0], [0, 0, 0, 1]]) {
multmatrix([[-1, 0, 0, 0], [0, 0, 1, 0], [0, 1, 0, 0], [0, 0, 0, 1]]) {
group() {
linear_extrude(height = 5, center = false, convexity = 1, scale = [1, 1], $fn = 0, $fa = 12, $fs = 2);
}
}
}
multmatrix([[1, 0, 0, -27.5], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
multmatrix([[0, 0, -1, 0], [-1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 0, 1]]) {
group() {
linear_extrude(height = 5, center = false, convexity = 1, scale = [1, 1], $fn = 0, $fa = 12, $fs = 2);
}
}
}
}
multmatrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 27.5], [0, 0, 0, 1]]) {
group() {
linear_extrude(height = 5, center = false, convexity = 1, scale = [1, 1], $fn = 0, $fa = 12, $fs = 2);
}
}
multmatrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, -32.5], [0, 0, 0, 1]]) {
group() {
linear_extrude(height = 5, center = false, convexity = 1, scale = [1, 1], $fn = 0, $fa = 12, $fs = 2);
}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB