3D part design with OpenSCAD #119: Adding a few more features to the text outliner code.

3 min read
By Bob
3D part design with OpenSCAD #119: Adding a few more features to the  text outliner code.

After experimenting with the text outliner I wanted to add some things like selecting the color from a drop down list, being able to make the text wider and having the capability to have a gap between the outline and the text.

Here is the code:

//

/*[Text]*/
$fn=60;//[20:1:100]
Fill=true; 
Input_Text="Text";
TextColor="white";//[Lavender,Thistle,Plum,Violet,Orchid,Fuchsia,Magenta,MediumOrchid,MediumPurple,BlueViolet,DarkViolet,DarkOrchid,DarkMagenta,Purple,Indigo,DarkSlateBlue,SlateBlue,MediumSlateBlue,IndianRed,LightCoral,Salmon,DarkSalmon,LightSalmon,Red,Crimson,FireBrick,DarkRed,Aqua,Cyan,LightCyan,PaleTurquoise,Aquamarine,Turquoise,MediumTurquoise,DarkTurquoise,CadetBlue,SteelBlue,LightSteelBlue,PowderBlue,LightBlue,SkyBlue,LightSkyBlue,DeepSkyBlue,DodgerBlue,CornflowerBlue,RoyalBlue,Blue,MediumBlue,DarkBlue,Navy,MidnightBlue,Pink,LightPink,HotPink,DeepPink,MediumVioletRed,PaleVioletRed,GreenYellow,Chartreuse,LawnGreen,Lime,LimeGreen,PaleGreen,LightGreen,MediumSpringGreen,SpringGreen,MediumSeaGreen,SeaGreen,ForestGreen,Green,DarkGreen,YellowGreen,OliveDrab,Olive,DarkOliveGreen,MediumAquamarine,DarkSeaGreen,LightSeaGreen,DarkCyan,Teal,Oranges,LightSalmon,Coral,Tomato,OrangeRed,DarkOrange,Orange,Gold,Yellow,LightYellow,LemonChiffon,LightGoldenrodYellow,PapayaWhip,Moccasin,PeachPuff,PaleGoldenrod,Khaki,DarkKhaki,Cornsilk,BlanchedAlmond,Bisque,NavajoWhite,Wheat,BurlyWood,Tan,RosyBrown,SandyBrown,Goldenrod,DarkGoldenrod,Peru,Chocolate,SaddleBrown,Sienna,Brown,Maroon,White,Snow,Honeydew,MintCream,Azure,AliceBlue,GhostWhite,WhiteSmoke,Seashell,Beige,OldLace,FloralWhite,Ivory,AntiqueWhite,Linen,LavenderBlush,MistyRose,Gainsboro,LightGrey,Silver,DarkGray,Gray,DimGray,LightSlateGray,SlateGray,DarkSlateGray,Black]
Font="";
Text_spacing=1;//[1:.01:10]
Text_size=5;//[1:.01:200]
Text_width=.2;//[0:.01:13]
Text_height=1;//[.1:.01:100]


/*[Outline]*/
OutlineColor="black";//[Lavender,Thistle,Plum,Violet,Orchid,Fuchsia,Magenta,MediumOrchid,MediumPurple,BlueViolet,DarkViolet,DarkOrchid,DarkMagenta,Purple,Indigo,DarkSlateBlue,SlateBlue,MediumSlateBlue,IndianRed,LightCoral,Salmon,DarkSalmon,LightSalmon,Red,Crimson,FireBrick,DarkRed,Aqua,Cyan,LightCyan,PaleTurquoise,Aquamarine,Turquoise,MediumTurquoise,DarkTurquoise,CadetBlue,SteelBlue,LightSteelBlue,PowderBlue,LightBlue,SkyBlue,LightSkyBlue,DeepSkyBlue,DodgerBlue,CornflowerBlue,RoyalBlue,Blue,MediumBlue,DarkBlue,Navy,MidnightBlue,Pink,LightPink,HotPink,DeepPink,MediumVioletRed,PaleVioletRed,GreenYellow,Chartreuse,LawnGreen,Lime,LimeGreen,PaleGreen,LightGreen,MediumSpringGreen,SpringGreen,MediumSeaGreen,SeaGreen,ForestGreen,Green,DarkGreen,YellowGreen,OliveDrab,Olive,DarkOliveGreen,MediumAquamarine,DarkSeaGreen,LightSeaGreen,DarkCyan,Teal,Oranges,LightSalmon,Coral,Tomato,OrangeRed,DarkOrange,Orange,Gold,Yellow,LightYellow,LemonChiffon,LightGoldenrodYellow,PapayaWhip,Moccasin,PeachPuff,PaleGoldenrod,Khaki,DarkKhaki,Cornsilk,BlanchedAlmond,Bisque,NavajoWhite,Wheat,BurlyWood,Tan,RosyBrown,SandyBrown,Goldenrod,DarkGoldenrod,Peru,Chocolate,SaddleBrown,Sienna,Brown,Maroon,White,Snow,Honeydew,MintCream,Azure,AliceBlue,GhostWhite,WhiteSmoke,Seashell,Beige,OldLace,FloralWhite,Ivory,AntiqueWhite,Linen,LavenderBlush,MistyRose,Gainsboro,LightGrey,Silver,DarkGray,Gray,DimGray,LightSlateGray,SlateGray,DarkSlateGray,Black]
Outline_width=.2;//[0:.01:13]
Outline_spacing=.2;//[0:.01:13]
Outline_height=1;//[.1:.01:50]

render()
color(OutlineColor)
translate([0,0,.01])
difference(){
linear_extrude(Outline_height,convexity=6)
offset(Outline_width)
text(Input_Text,font=Font,spacing=Text_spacing,halign="center",valign="center",size=Text_size);
linear_extrude(Outline_height+.01,convexity=6)
offset(Outline_spacing)
text(Input_Text,font=Font,spacing=Text_spacing,halign="center",valign="center",size=Text_size);
}

if(Fill)
translate([0,0,.01])
color(TextColor)
linear_extrude(Text_height,convexity=6)
offset(Text_width)
text(Input_Text,font=Font,spacing=Text_spacing,halign="center",valign="center",size=Text_size);


For some reason I was not able to link the color list to a library file to keep from cluttering up the code. I'm sure I have done that before I just don't remember how I did it, so I will have to dig through all the files I have and find it. I know there is a way to link a list from a library file and use it with the customizer.

outined text with the bend stl code from post#85