Last active
March 3, 2019 01:51
-
-
Save t-paul/7171783 to your computer and use it in GitHub Desktop.
openscad
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Image link: | |
![My Image](https://gist.github.com/t-paul/7171783#file-openscad-freetype-4-png) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/**************************************************************************** | |
* Teardrop | |
* (c) 2013 Torsten Paul <Torsten.Paul@gmx.de> | |
* License: CC-BY-SA 3.0 | |
* | |
* Based on the formula in "Modelling a Tear Drop" by by Paul Bourke | |
* (http://paulbourke.net/geometry/teardrop/) | |
*/ | |
function drop(x) = 100 * 0.5 * (1 - cos(180 * x)) * sin(180 * x) + 1; | |
function path(x) = [0, 0, 80 + 80 * cos(180 * x)]; | |
function rotate(x) = PI * pow((1 - x), 3); | |
loft(path="path", scale_x = "drop", scale_y="drop", rotate="rotate", slices=100) circle(r = 1, $fn = 12); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function path(x) = [ | |
(x / 1.5 + 0.5) * 100 * cos(6 * 360 * x), | |
(x / 1.5 + 0.5) * 100 * sin(6 * 360 * x), | |
200 * (1 - x) | |
]; | |
loft(path = "path", slices = 800, height = 100) { | |
translate([-10, -6, 0]) square([3, 6]); | |
square([20, 2], center = true); | |
translate([7, -6, 0]) square([3, 6]); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$fn = 20; | |
module segment() { | |
hull() { | |
translate([-10, -18, 0]) circle(r = 3); | |
translate([ 10, 18, 0]) circle(r = 3); | |
translate([-10, 18, 0]) circle(r = 3); | |
translate([ 10, -18, 0]) circle(r = 3); | |
} | |
} | |
module cross() { | |
segment(); | |
rotate([0, 0, 90]) segment(); | |
} | |
function rotate(x) = cos(90 * x); | |
function scale(x) = 1.5 * sin(210 * (x / 2) + 60); | |
loft(scale_x = "scale", scale_y = "scale", rotate = "rotate", height = 80, slices = 50) | |
cross(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function func0(x)= 1; | |
function func1(x) = 30 * sin(180 * x); | |
function func2(x) = -30 * sin(180 * x); | |
function func3(x) = sin(270 * (1 - x) - 90) * sqrt(6 * (1 - x)) + 2; | |
function func4(x) = PI * x / 2; | |
function func5(x) = 2 * PI * x * x * x; | |
function func6(x) = 3 - 2.5 * x; | |
loft(offset_x = "func1", offset_y = "func1", rotate = "func4", slices = 30, height = 100) square(10); | |
loft(offset_x = "func2", offset_y = "func2", rotate = "func4", slices = 30, height = 100) square(10); | |
loft(offset_x = "func1", offset_y = "func2", rotate = "func4", slices = 30, height = 100) square(10); | |
loft(offset_x = "func2", offset_y = "func1", rotate = "func4", slices = 30, height = 100) square(10); | |
translate([100, 0, 0]) | |
loft(scale_x = "func3", scale_y = "func3", rotate = "func4", slices = 50, height = 100) square(10); | |
translate([-100, 0, 0]) | |
loft(rotate = "func5", scale_x = "func6", scale_y = "func6", slices = 50, height = 100) square(10); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$fn = 50; | |
map_extrude() { | |
union() { | |
circle(r = 12); | |
translate([15, 2, 0]) square([25, 8]); | |
translate([15, -10, 0]) text(t = "Text", font = "ArialMT"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$fn = 6; | |
text = "The quick brown fox jumps over the lazy dog!"; | |
fonts = [ | |
["DejaVu Sans", "DejaVu Sans:style=Book"], | |
["DejaVu Sans", "DejaVu Sans:style=Oblique"], | |
["DejaVu Sans", "DejaVu Sans:style=Bold"], | |
["DejaVu Sans", "DejaVu Sans:style=Bold Oblique"], | |
["DejaVu Sans", "DejaVu Sans:style=Condensed"], | |
["DejaVu Sans", "DejaVu Sans:style=Condensed Bold"], | |
["DejaVu Sans", "DejaVu Sans:style=Condensed Oblique"], | |
["DejaVu Sans", "DejaVu Sans:style=Condensed Bold Oblique"], | |
["DejaVu Sans", "DejaVu Sans:style=ExtraLight"], | |
["DejaVu Sans", "DejaVu Sans Mono:style=Book"], | |
["DejaVu Sans", "DejaVu Sans Mono:style=Oblique"], | |
["DejaVu Sans", "DejaVu Sans Mono:style=Bold"], | |
["DejaVu Sans", "DejaVu Sans Mono:style=Bold Oblique"], | |
["DejaVu Serif", "DejaVu Serif:style=Book"], | |
["DejaVu Serif", "DejaVu Serif:style=Italic"], | |
["DejaVu Serif", "DejaVu Serif:style=Bold"], | |
["DejaVu Serif", "DejaVu Serif:style=Bold Italic"], | |
["DejaVu Serif", "DejaVu Serif:style=Condensed Bold Italic"], | |
["DejaVu Serif", "DejaVu Serif:style=Condensed Bold"], | |
["DejaVu Serif", "DejaVu Serif:style=Condensed Italic"], | |
["DejaVu Serif", "DejaVu Serif=Condensed"], | |
["Gentium", "Gentium Basic:style=Bold Italic"], | |
["Gentium", "Gentium Basic:style=Bold"], | |
["Gentium", "Gentium Basic:style=Italic"], | |
["Gentium", "Gentium Basic:style=Regular"], | |
["Gentium", "Gentium Book Basic:style=Bold Italic"], | |
["Gentium", "Gentium Book Basic:style=Bold"], | |
["Gentium", "Gentium Book Basic:style=Italic"], | |
["Gentium", "Gentium Book Basic:style=Regular"], | |
["Liberation", "Liberation Mono:style=Bold Italic"], | |
["Liberation", "Liberation Mono:style=Bold"], | |
["Liberation", "Liberation Mono:style=Italic"], | |
["Liberation", "Liberation Mono:style=Regular"], | |
["Liberation", "Liberation Sans:style=Bold Italic"], | |
["Liberation", "Liberation Sans:style=Bold"], | |
["Liberation", "Liberation Sans:style=Italic"], | |
["Liberation", "Liberation Sans:style=Regular"], | |
["Liberation", "Liberation Serif:style=Bold Italic"], | |
["Liberation", "Liberation Serif:style=Bold"], | |
["Liberation", "Liberation Serif:style=Italic"], | |
["Liberation", "Liberation Serif:style=Regular"], | |
["Linux", "Linux Biolinum G:style=Bold"], | |
["Linux", "Linux Biolinum G:style=Regular"], | |
["Linux", "Linux Biolinum G:style=Italic"], | |
["Linux", "Linux Libertine Display G:style=Regular"], | |
["Linux", "Linux Libertine G:style=Bold"], | |
["Linux", "Linux Libertine G:style=Bold Italic"], | |
["Linux", "Linux Libertine G:style=Regular"], | |
["Linux", "Linux Libertine G:style=Italic"], | |
["Linux", "Linux Libertine G:style=Semibold"], | |
["Linux", "Linux Libertine G:style=Semibold Italic"], | |
["Open Sans", "Open Sans:style=Regular"], | |
["Open Sans", "Open Sans:style=Italic"], | |
["Open Sans", "Open Sans:style=Bold"], | |
["Open Sans", "Open Sans:style=Bold Italic"], | |
["Open Sans", "Open Sans Extrabold:style=Italic"], | |
["Open Sans", "Open Sans Extrabold:style=Regular"], | |
["Open Sans", "Open Sans Light:style=Italic"], | |
["Open Sans", "Open Sans Light:style=Regular"], | |
["Open Sans", "Open Sans Semibold:style=Italic"], | |
["Open Sans", "Open Sans Semibold:style=Regular"], | |
["ParaType", "PT Mono:style=Regular"], | |
["ParaType", "PT Mono:style=Bold"], | |
["ParaType", "PT Sans Caption:style=Regular"], | |
["ParaType", "PT Sans Caption:style=Bold"], | |
["ParaType", "PT Sans Narrow:style=Regular"], | |
["ParaType", "PT Sans Narrow:style=Bold"], | |
["ParaType", "PT Sans:style=Regular"], | |
["ParaType", "PT Sans:style=Italic"], | |
["ParaType", "PT Sans:style=Bold"], | |
["ParaType", "PT Sans:style=Bold Italic"], | |
["ParaType", "PT Serif:style=Regular"], | |
["ParaType", "PT Serif:style=Italic"], | |
["ParaType", "PT Serif:style=Bold"], | |
["ParaType", "PT Serif:style=Bold Italic"], | |
["ParaType", "PT Serif Caption:style=Regular"], | |
["ParaType", "PT Serif Caption:style=Italic"], | |
["Source Code Pro", "Source Code Pro:style=Regular"], | |
["Source Code Pro", "Source Code Pro:style=Bold"], | |
["Source Code Pro", "Source Code Pro Black:style=Regular"], | |
["Source Code Pro", "Source Code Pro Semibold:style=Regular"], | |
["Source Code Pro", "Source Code Pro Medium:style=Regular"], | |
["Source Code Pro", "Source Code Pro Light:style=Regular"], | |
["Source Code Pro", "Source Code Pro ExtraLight:style=Regular"], | |
["Source Sans Pro", "Source Sans Pro:style=Regular"], | |
["Source Sans Pro", "Source Sans Pro:style=Italic"], | |
["Source Sans Pro", "Source Sans Pro:style=Bold"], | |
["Source Sans Pro", "Source Sans Pro:style=Bold Italic"], | |
["Source Sans Pro", "Source Sans Pro Black:style=Regular"], | |
["Source Sans Pro", "Source Sans Pro Black:style=Italic"], | |
["Source Sans Pro", "Source Sans Pro Semibold:style=Regular"] | |
["Source Sans Pro", "Source Sans Pro Semibold:style=Italic"], | |
["Source Sans Pro", "Source Sans Pro Light:style=Regular"], | |
["Source Sans Pro", "Source Sans Pro Light:style=Italic"], | |
["Source Sans Pro", "Source Sans Pro ExtraLight:style=Regular"], | |
["Source Sans Pro", "Source Sans Pro ExtraLight:style=Italic"], | |
]; | |
family="ParaType"; | |
for (a = [0 : 1000]) { | |
if (fonts[a][0] == family) { | |
linear_extrude(height = 1) { | |
translate([0, 20 * a, 0]) text(t = text, font = fonts[a][1]); | |
translate([400, 20 * a, 0]) text(t = fonts[a][1], font = fonts[a][1]); | |
} | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$fn = 20; | |
$ff = "DejaVuSansCondensed"; | |
$ff2 = "Amiri-Regular"; | |
union() { | |
#cube([130, 10, 1]); | |
linear_extrude(height = 2) | |
text(t = "OpenSCAD with Text!", size = 10, $fn = 40, font = $ff); | |
} | |
translate([0, -40, 0]) difference() { | |
cube([90, 14, 1]); | |
translate([5, 3, -1]) | |
linear_extrude(height = 40) | |
text(t = "FreeType", size = 10, font = $ff); | |
} | |
translate([0, -20, 0]) | |
linear_extrude(height = 6) | |
text(t = "it works !!!", font = $ff, size = 17); | |
s = "OpenSCAD"; | |
translate([45, 60, 5]) | |
rotate([-30, 0, 0]) | |
for (a = [0 : 7]) | |
rotate([0, 0, 135 + 90 / 7 * a]) | |
translate([0, 70, 0]) | |
rotate([90, 0, 180]) | |
translate([-5, 0, 0]) | |
linear_extrude(height = 2) | |
text(t = s[a], size = 20, font = $ff); | |
translate([0, -80, 0]) | |
rotate([90, 0, 0]) | |
linear_extrude(height = 2) | |
text(t = "ΠΠ΅Π½ΠΈΠ²ΡΠΉ ΡΡΠΆΠΈΠΉ ΠΊΠΎΡ", size = 16, font = "DejaVuSansCondensed"); | |
translate([0, -120, 0]) | |
rotate([90, 0, 0]) | |
linear_extrude(height = 2) | |
text(t = "ΩΨ³ΩΩ Ψ§ΩΨ²ΩΨ¬Ψ¨ΩΩ Ψ§ΩΩΨ·", size = 16, font = $ff2, direction = "rtl", language = "ar", script = "arabic"); | |
translate([-20, 0, 0]) | |
linear_extrude(height = 2) | |
text(t = "ζΆζ°ηε§θ²", size = 16, font = "AR-PL-New-Sung", direction = "ttb", language = "ch"); | |
/* | |
translate([0, -60, 0]) | |
linear_extrude(height = 2) | |
text(t = "Umlauts: Àâü ΓΓΓ Γ", size = 10, font = $ff); | |
translate([0, -80, 0]) | |
linear_extrude(height = 2) | |
text(t = "Smileys: πππππ πππππππππππ", size = 10, font = $ff); | |
translate([0, -100, 0]) | |
linear_extrude(height = 2) | |
text(t = "Braile: β β β β β β β β β β β β β β β ", size = 10, font = $ff); | |
translate([0, -120, 0]) | |
linear_extrude(height = 2) | |
text(t = "Cards: π‘π±ππ", size = 10, font = $ff); | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DejaVu - Bitstream Vera Fonts Copyright | |
http://dejavu-fonts.org/ | |
Gentium - SIL Open Font License, Version 1.1 | |
http://scripts.sil.org/cms/scripts/page.php?item_id=Gentium_basic | |
Liberation - SIL Open Font License, Version 1.1 | |
https://fedorahosted.org/liberation-fonts/ | |
Linux Libertine G and Linux Biolinum G fonts - SIL Open Font License, Version 1.0 | |
http://www.numbertext.org/linux/ | |
Open Sans - Apache License version 2.0 | |
http://www.opensans.com/ | |
PT-Mono / PT-Sans / PT-Serif - ParaType Free Font Licence 1.3 | |
http://www.paratype.com/public/ | |
Source Code Pro - SIL Open Font License 1.1 | |
http://sourceforge.net/projects/sourcecodepro.adobe/ | |
Source Sans Pro - SIL Open Font License 1.1 | |
http://sourceforge.net/projects/sourcesans.adobe/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function skip(a) = a == [3, 0] || a == [4, 0] || a == [6, 4]; | |
function span(a) = a == [2, 0] ? 20 : a == [5, 4] ? 10 : 0; | |
for (y = [0 : 4]) { | |
for (x = [0 : 6]) { | |
if (!skip([x, y])) { | |
translate([10 * x + 1, 10 * y + 1]) square([8 + span([x, y]), 8]); | |
} | |
} | |
} |
View raw
(Sorry about that, but we canβt show files that are this big right now.)
View raw
(Sorry about that, but we canβt show files that are this big right now.)
View raw
(Sorry about that, but we canβt show files that are this big right now.)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hiya,
I have openscad 2019.01-RC2, but loft doesn't seem to be defined..
Please can you tell me how to get loft working?
Thanks