File: highlight.scad.fold

package info (click to toggle)
kf6-syntax-highlighting 6.13.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 47,568 kB
  • sloc: xml: 197,750; cpp: 12,850; python: 3,023; sh: 955; perl: 546; ruby: 488; pascal: 393; javascript: 161; php: 150; jsp: 132; lisp: 131; haskell: 124; ada: 119; ansic: 107; makefile: 96; f90: 94; ml: 85; cobol: 81; yacc: 71; csh: 62; erlang: 54; sql: 51; java: 47; objc: 37; awk: 31; asm: 30; tcl: 29; fortran: 18; cs: 10
file content (94 lines) | stat: -rw-r--r-- 5,718 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<beginfold id='1'>/*</beginfold id='1'>Basic test file
Written by Julian Stirling, 2018
License: MIT<endfold id='1'>*/</endfold id='1'>

// This is a comment
x=5;
y=6;
z=5;
r=2;
for (n = <beginfold id='2'>[</beginfold id='2'>-1.5:1:1.5<endfold id='2'>]</endfold id='2'>)<beginfold id='3'>{</beginfold id='3'>
    translate(<beginfold id='2'>[</beginfold id='2'>n*x,0,0<endfold id='2'>]</endfold id='2'>)<beginfold id='3'>{</beginfold id='3'>cubehole(<beginfold id='2'>[</beginfold id='2'>x,y,z<endfold id='2'>]</endfold id='2'>,r);<endfold id='3'>}</endfold id='3'>
<endfold id='3'>}</endfold id='3'>

module cubehole(size,holerad)
<beginfold id='3'>{</beginfold id='3'>
    $fn=28;
    difference()
    <beginfold id='3'>{</beginfold id='3'>
        cube(size,center=true);
        cylinder(size<beginfold id='2'>[</beginfold id='2'>2<endfold id='2'>]</endfold id='2'>+1,r=holerad,center=true);
    <endfold id='3'>}</endfold id='3'>
<endfold id='3'>}</endfold id='3'>

// some examples adapted from https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General
cube(5);
x = 4 + y;
rotate(40) square(5,10);
translate(<beginfold id='2'>[</beginfold id='2'>10, 5<endfold id='2'>]</endfold id='2'>) <beginfold id='3'>{</beginfold id='3'>
    circle(5);
    square(4);
<endfold id='3'>}</endfold id='3'>
rotate(60) color(<beginfold id='4'>"</beginfold id='4'>red<endfold id='4'>"</endfold id='4'>) <beginfold id='3'>{</beginfold id='3'>
    circle(5);
    square(4);
<endfold id='3'>}</endfold id='3'>
color(<beginfold id='4'>"</beginfold id='4'>blue<endfold id='4'>"</endfold id='4'>) <beginfold id='3'>{</beginfold id='3'>
    translate(<beginfold id='2'>[</beginfold id='2'>5, 3, 0<endfold id='2'>]</endfold id='2'>) sphere(5);
    rotate(<beginfold id='2'>[</beginfold id='2'>45, 0, 45<endfold id='2'>]</endfold id='2'>) <beginfold id='3'>{</beginfold id='3'>
        cylinder(10);
        cube(<beginfold id='2'>[</beginfold id='2'>5, 6, 7<endfold id='2'>]</endfold id='2'>);
    <endfold id='3'>}</endfold id='3'>
<endfold id='3'>}</endfold id='3'>

aNumber = 42;
aBoolean = true;
anotherBoolean = false;
aString = <beginfold id='4'>"</beginfold id='4'>foo<endfold id='4'>"</endfold id='4'>;
aRange = <beginfold id='2'>[</beginfold id='2'>0: 1: 10<endfold id='2'>]</endfold id='2'>;
aVector = <beginfold id='2'>[</beginfold id='2'>1, 2, 3<endfold id='2'>]</endfold id='2'>;
aUndef = undef;
moreNumbers = <beginfold id='2'>[</beginfold id='2'>-1, 42, 0.5, 2.99792458e+8, 1.337e3, 314e-2<endfold id='2'>]</endfold id='2'>;
echo(moreNumbers)
echo(<beginfold id='4'>"</beginfold id='4'>The quick brown fox \tjumps \"over\" the lazy dog.\rThe quick brown fox.\nThe \\lazy\\ dog. \x21 \u03a9 \U01F98A \U01f43e<endfold id='4'>"</endfold id='4'>);

vector1 = <beginfold id='2'>[</beginfold id='2'>1,2,3<endfold id='2'>]</endfold id='2'>; vector2 = <beginfold id='2'>[</beginfold id='2'>4<endfold id='2'>]</endfold id='2'>; vector3 = <beginfold id='2'>[</beginfold id='2'>5,6<endfold id='2'>]</endfold id='2'>;
new_vector = concat(vector1, vector2, vector3); // [1,2,3,4,5,6]

string_vector = concat(<beginfold id='4'>"</beginfold id='4'>abc<endfold id='4'>"</endfold id='4'>,<beginfold id='4'>"</beginfold id='4'>def<endfold id='4'>"</endfold id='4'>);                 // ["abc", "def"]
one_string = str(string_vector<beginfold id='2'>[</beginfold id='2'>0<endfold id='2'>]</endfold id='2'>,string_vector<beginfold id='2'>[</beginfold id='2'>1<endfold id='2'>]</endfold id='2'>); // "abcdef"

a = <beginfold id='2'>[</beginfold id='2'>1,2,3<endfold id='2'>]</endfold id='2'>; echo(len(a));   //  3

// Example which defines a 2D rotation matrix
mr = <beginfold id='2'>[</beginfold id='2'>
    <beginfold id='2'>[</beginfold id='2'>cos(angle), -sin(angle)<endfold id='2'>]</endfold id='2'>,
    <beginfold id='2'>[</beginfold id='2'>sin(angle),  cos(angle)<endfold id='2'>]</endfold id='2'>
<endfold id='2'>]</endfold id='2'>;

// modifiers
% cube(<beginfold id='2'>[</beginfold id='2'>10, 10, 10<endfold id='2'>]</endfold id='2'>);  // background
# cube(<beginfold id='2'>[</beginfold id='2'>10, 10, 10<endfold id='2'>]</endfold id='2'>);  // debug
! cube(<beginfold id='2'>[</beginfold id='2'>10, 10, 10<endfold id='2'>]</endfold id='2'>);  // root
* cube(<beginfold id='2'>[</beginfold id='2'>10, 10, 10<endfold id='2'>]</endfold id='2'>);  // disable

// if example taken from https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Other_Language_Features#Rounding_examples
if(a==b)<beginfold id='3'>{</beginfold id='3'>
    echo (<beginfold id='4'>"</beginfold id='4'>a==b<endfold id='4'>"</endfold id='4'>);
<endfold id='3'>}</endfold id='3'>else if(a>b)<beginfold id='3'>{</beginfold id='3'>
    echo (<beginfold id='4'>"</beginfold id='4'>a>b<endfold id='4'>"</endfold id='4'>);
<endfold id='3'>}</endfold id='3'>else if(a<b)<beginfold id='3'>{</beginfold id='3'>
    echo (<beginfold id='4'>"</beginfold id='4'>a<b<endfold id='4'>"</endfold id='4'>);
<endfold id='3'>}</endfold id='3'>else<beginfold id='3'>{</beginfold id='3'>
    echo (<beginfold id='4'>"</beginfold id='4'>???<endfold id='4'>"</endfold id='4'>);
<endfold id='3'>}</endfold id='3'>

// assert example taken from https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Other_Language_Features#assert
module row(cnt = 3)<beginfold id='3'>{</beginfold id='3'>
    // Count has to be a positive integer greater 0
    assert(cnt > 0);
    for (i = <beginfold id='2'>[</beginfold id='2'>1 : cnt<endfold id='2'>]</endfold id='2'>) <beginfold id='3'>{</beginfold id='3'>
        translate(<beginfold id='2'>[</beginfold id='2'>i * 2, 0, 0<endfold id='2'>]</endfold id='2'>) sphere();
    <endfold id='3'>}</endfold id='3'>
<endfold id='3'>}</endfold id='3'>
row(0);