Skip to content

Commit

Permalink
Added better example023 with test output.
Browse files Browse the repository at this point in the history
  • Loading branch information
clothbot committed Feb 19, 2012
1 parent 65c3acf commit de1deb1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions examples/example023.scad
Original file line number Original file line Diff line number Diff line change
@@ -1,30 +1,20 @@
// MCAD/fonts.scad with search() function example. // Example combining MCAD/fonts.scad with search() function.


use <MCAD/fonts.scad> use <MCAD/fonts.scad>


thisFont=8bit_polyfont(); 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]; x_shift=thisFont[0][0];
y_shift=thisFont[0][1]; 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); hours=["one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve"];
// 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); module clock_hour_words(word_offset=20.0,word_height=2.0) {
// bold_2d() outline_2d(false) example for(i=[0:(len(hours)-1)]) assign( hourHandAngle=(i+1)*360/len(hours), theseIndicies=search(hours[i],thisFont[2],1,1) ) {
for(i=[0:len(theseIndicies3)-1]) translate([i*x_shift,-2*y_shift]) { rotate(90-hourHandAngle) translate([word_offset,0])
bold_2d(bold=true,width=0.25,resolution=8) for( j=[0:(len(theseIndicies)-1)] ) translate([j*x_shift,-y_shift/2]) {
outline_2d(false,thisFont[2][theseIndicies3[i]][6][0],thisFont[2][theseIndicies3[i]][6][1]); 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);
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit de1deb1

Please sign in to comment.