Difference between revisions of "Template:Jscad"

From BITPlan Wiki
Jump to navigation Jump to search
Line 3: Line 3:
 
Put your JSCAD code inside a source tag and add a call of this template
 
Put your JSCAD code inside a source tag and add a call of this template
 
<pre>
 
<pre>
<source lang='javascript'></source>
+
{{jscad|code=// title      : OpenJSCAD.org Logo
{{jscad|code=function main() {
+
// author    : Rene K. Mueller
 +
// license    : MIT License
 +
// revision  : 0.003
 +
// tags      : Logo,Intersection,Sphere,Cube
 +
// file      : logo.jscad
 +
 
 +
function main () {
 +
  return union(
 +
    difference(
 +
      cube({size: 3, center: true}),
 +
      sphere({r: 2, center: true})
 +
    ),
 +
    intersection(
 +
      sphere({r: 1.3, center: true}),
 +
      cube({size: 2.1, center: true})
 +
    )
 +
  ).translate([0, 0, 1.5]).scale(10);
 
}
 
}
 
}}
 
}}
 
</pre>
 
</pre>
 
== Example ==
 
== Example ==
{{jscad|code=function main() {
+
{{jscad|code=// title      : OpenJSCAD.org Logo
 +
// author    : Rene K. Mueller
 +
// license    : MIT License
 +
// revision  : 0.003
 +
// tags      : Logo,Intersection,Sphere,Cube
 +
// file      : logo.jscad
 +
 
 +
function main () {
 +
  return union(
 +
    difference(
 +
      cube({size: 3, center: true}),
 +
      sphere({r: 2, center: true})
 +
    ),
 +
    intersection(
 +
      sphere({r: 1.3, center: true}),
 +
      cube({size: 2.1, center: true})
 +
    )
 +
  ).translate([0, 0, 1.5]).scale(10);
 
}
 
}
 
}}
 
}}

Revision as of 08:19, 10 June 2019

Usage

Put your JSCAD code inside a source tag and add a call of this template

{{jscad|code=// title      : OpenJSCAD.org Logo
// author     : Rene K. Mueller
// license    : MIT License
// revision   : 0.003
// tags       : Logo,Intersection,Sphere,Cube
// file       : logo.jscad

function main () {
  return union(
    difference(
      cube({size: 3, center: true}),
      sphere({r: 2, center: true})
    ),
    intersection(
      sphere({r: 1.3, center: true}),
      cube({size: 2.1, center: true})
    )
  ).translate([0, 0, 1.5]).scale(10);
}
}}

Example