From bd5aac6f96ac7ecf3613fd81999bd82605925562 Mon Sep 17 00:00:00 2001 From: Andrew Plumb Date: Sat, 18 Feb 2012 12:10:06 -0500 Subject: MCAD/fonts with search() example. Adding example023.scad demonstrating use of search() with MCAD/fonts.scad diff --git a/examples/example023.scad b/examples/example023.scad new file mode 100644 index 0000000..3f59264 --- /dev/null +++ b/examples/example023.scad @@ -0,0 +1,30 @@ +// MCAD/fonts.scad with search() function example. + +use + +thisFont=8bit_polyfont(); +thisText="OpenSCAD Rocks!"; +// Find one letter matches from 2nd column (index 1) +theseIndicies=search(thisText,thisFont[2],1,1); +// Letter spacing, x direction. +x_shift=thisFont[0][0]; +y_shift=thisFont[0][1]; +echo(theseIndicies); +// Simple polygon usage. +for(i=[0:len(theseIndicies)-1]) translate([i*x_shift-len(theseIndicies)*x_shift/2,0]) { + polygon(points=thisFont[2][theseIndicies[i]][6][0],paths=thisFont[2][theseIndicies[i]][6][1]); +} + +theseIndicies2=search("ABC",thisFont[2],1,1); +// outline_2d() example +for(i=[0:len(theseIndicies2)-1]) translate([i*x_shift-len(theseIndicies2)*x_shift,-y_shift]) { + outline_2d(outline=true,points=thisFont[2][theseIndicies2[i]][6][0],paths=thisFont[2][theseIndicies2[i]][6][1],width=0.25); +} + +theseIndicies3=search("123",thisFont[2],1,1); +// bold_2d() outline_2d(false) example +for(i=[0:len(theseIndicies3)-1]) translate([i*x_shift,-2*y_shift]) { + bold_2d(bold=true,width=0.25,resolution=8) + outline_2d(false,thisFont[2][theseIndicies3[i]][6][0],thisFont[2][theseIndicies3[i]][6][1]); +} + -- cgit v0.10.1 From de1deb113fa098d2a758b933436cde81a1a09beb Mon Sep 17 00:00:00 2001 From: Andrew Plumb Date: Sat, 18 Feb 2012 21:22:31 -0500 Subject: Added better example023 with test output. diff --git a/examples/example023.scad b/examples/example023.scad index 3f59264..1332899 100644 --- a/examples/example023.scad +++ b/examples/example023.scad @@ -1,30 +1,20 @@ -// MCAD/fonts.scad with search() function example. +// Example combining MCAD/fonts.scad with search() function. use thisFont=8bit_polyfont(); -thisText="OpenSCAD Rocks!"; -// Find one letter matches from 2nd column (index 1) -theseIndicies=search(thisText,thisFont[2],1,1); -// Letter spacing, x direction. x_shift=thisFont[0][0]; y_shift=thisFont[0][1]; -echo(theseIndicies); -// Simple polygon usage. -for(i=[0:len(theseIndicies)-1]) translate([i*x_shift-len(theseIndicies)*x_shift/2,0]) { - polygon(points=thisFont[2][theseIndicies[i]][6][0],paths=thisFont[2][theseIndicies[i]][6][1]); -} -theseIndicies2=search("ABC",thisFont[2],1,1); -// outline_2d() example -for(i=[0:len(theseIndicies2)-1]) translate([i*x_shift-len(theseIndicies2)*x_shift,-y_shift]) { - outline_2d(outline=true,points=thisFont[2][theseIndicies2[i]][6][0],paths=thisFont[2][theseIndicies2[i]][6][1],width=0.25); -} +hours=["one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve"]; -theseIndicies3=search("123",thisFont[2],1,1); -// bold_2d() outline_2d(false) example -for(i=[0:len(theseIndicies3)-1]) translate([i*x_shift,-2*y_shift]) { - bold_2d(bold=true,width=0.25,resolution=8) - outline_2d(false,thisFont[2][theseIndicies3[i]][6][0],thisFont[2][theseIndicies3[i]][6][1]); +module clock_hour_words(word_offset=20.0,word_height=2.0) { + for(i=[0:(len(hours)-1)]) assign( hourHandAngle=(i+1)*360/len(hours), theseIndicies=search(hours[i],thisFont[2],1,1) ) { + rotate(90-hourHandAngle) translate([word_offset,0]) + for( j=[0:(len(theseIndicies)-1)] ) translate([j*x_shift,-y_shift/2]) { + linear_extrude(height=word_height) polygon(points=thisFont[2][theseIndicies[j]][6][0],paths=thisFont[2][theseIndicies[j]][6][1]); + } + } } +clock_hour_words(word_offset=16.0,word_height=5.0); diff --git a/tests/regression/cgalpngtest/example023-expected.png b/tests/regression/cgalpngtest/example023-expected.png new file mode 100644 index 0000000..c528b90 Binary files /dev/null and b/tests/regression/cgalpngtest/example023-expected.png differ diff --git a/tests/regression/opencsgtest/example023-expected.png b/tests/regression/opencsgtest/example023-expected.png new file mode 100644 index 0000000..a097d99 Binary files /dev/null and b/tests/regression/opencsgtest/example023-expected.png differ diff --git a/tests/regression/throwntogethertest/example023-expected.png b/tests/regression/throwntogethertest/example023-expected.png new file mode 100644 index 0000000..a097d99 Binary files /dev/null and b/tests/regression/throwntogethertest/example023-expected.png differ -- cgit v0.10.1 From d3528779bb370b2314af3b198e8aa4456eba0189 Mon Sep 17 00:00:00 2001 From: Andrew Plumb Date: Sat, 18 Feb 2012 23:20:28 -0500 Subject: Added dumptest_example023 to disable_tests() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 881a750..12b8543 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -669,7 +669,8 @@ disable_tests(dumptest_transform-tests dumptest_example017 dumptest_example020 dumptest_example021 - dumptest_example022) + dumptest_example022 + dumptest_example023) # FIXME: This test illustrates a weakness in child() combined with modifiers. # Reenable it when this is improved -- cgit v0.10.1