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>
{{jscad|code=// title      : OpenJSCAD.org Logo
+
{{jscad|title=OpenJSCAD.org Logo|code=// title      : OpenJSCAD.org Logo
 
// author    : Rene K. Mueller
 
// author    : Rene K. Mueller
 
// license    : MIT License
 
// license    : MIT License
Line 91: Line 91:
 
   }
 
   }
 
</script>
 
</script>
<h1>Title</h1>
+
<h1>{{{title|}}}</h1>
 
<div id="jscadviewer"></div>
 
<div id="jscadviewer"></div>
 
<h2>Source code</h2>
 
<h2>Source code</h2>
Below is the OpenJsCad script for this demo. To build your own models, create a .jscad script
+
Below is the OpenJsCad script.
and use the <a href="processfile.html"><b>OpenJsCad parser</b></a>. For more information see the
 
<a href="index.html">OpenJsCad documentation</a>.
 
<br><br>
 
 
<textarea id='code' style="height: 500px">{{{code|}}}</textarea>
 
<textarea id='code' style="height: 500px">{{{code|}}}</textarea>
 
<input type="submit" value="Update" onclick="updateSolid(); return false;">
 
<input type="submit" value="Update" onclick="updateSolid(); return false;">

Revision as of 10:47, 10 June 2019

Usage

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

{{jscad|title=OpenJSCAD.org Logo|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

Source code

Below is the OpenJsCad script.