Add OpenSCAD (#1097)

* add OpenSCAD

* update README.md

* test data
This commit is contained in:
Ken Chou 2024-05-13 16:53:56 +08:00 committed by GitHub
parent 9d156e1f77
commit 40bd58b692
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 42 additions and 0 deletions

View file

@ -464,6 +464,7 @@ ObjectiveC
ObjectiveCpp ObjectiveCpp
OCaml OCaml
Odin Odin
OpenSCAD
OpenQASM OpenQASM
Org Org
Oz Oz

View file

@ -1045,6 +1045,13 @@
"multi_line_comments": [["/*", "*/"]], "multi_line_comments": [["/*", "*/"]],
"quotes": [["\\\"", "\\\""], ["'", "'"]] "quotes": [["\\\"", "\\\""], ["'", "'"]]
}, },
"OpenScad": {
"name": "OpenSCAD",
"extensions": ["scad"],
"line_comment": ["//"],
"multi_line_comments": [["/*", "*/"]],
"quotes": [["\\\"", "\\\""], ["'", "'"]]
},
"OpenPolicyAgent": { "OpenPolicyAgent": {
"name": "Open Policy Agent", "name": "Open Policy Agent",
"line_comment": ["#"], "line_comment": ["#"],

34
tests/data/openscad.scad Normal file
View file

@ -0,0 +1,34 @@
//! 34 lines 15 code 16 comments 3 blanks
// https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Commented_Example_Projects
// The idea is to twist a translated circle:
// -
/*
linear_extrude(height = 10, twist = 360, scale = 0)
translate([1,0])
circle(r = 1);
*/
module horn(height = 10, radius = 6,
twist = 720, $fn = 50)
{
// A centered circle translated by 1xR and
// twisted by 360° degrees, covers a 2x(2xR) space.
// -
radius = radius/4;
// De-translate.
// -
translate([-radius,0])
// The actual code.
// -
linear_extrude(height = height, twist = twist,
scale=0, $fn = $fn)
translate([radius,0])
circle(r=radius);
}
translate([3,0])
mirror()
horn();
translate([-3,0])
horn();