User Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
jscad_quick_reference [2018/01/28 01:21]
openjscadorgadmin
jscad_quick_reference [2018/03/24 13:06] (current)
z3dev
Line 1: Line 1:
-====== ​JSCAD - Quick Reference ====== +====== Quick Reference ======
-The following sections provide quick reference to OpenJSCAD, CSG libraries, and the JavaScript language.+
  
-**[[https://​github.com/​Spiritdude/​OpenJSCAD.org/​wiki/​User-Guide|User Guide]]** +The following sections provide quick reference to the JSCAD application programming interface (API), the heart of making designs.
- +
-**[[http://​joostn.github.io/​OpenJsCad/​|CSG and CAG User Guide]]**+
  
 //Note: **Default values** and **notes** are highlighted in **bold fonts**.// //Note: **Default values** and **notes** are highlighted in **bold fonts**.//
  
 {{page>​quick_reference_intro}} {{page>​quick_reference_intro}}
- 
-===== General Usage ===== 
-^  OpenJSCAD Functions ​ ^  JavaScript Statements ​ ^ 
-| function main(parameters) { ...; return var; } **/* required */** | var name = my_box( {attribute: 1, ...} ); | 
-| function getParameterDefinitions() {return [ definition... ]; } **/* optional */**  | function my_box( param ) { ...; return shape; } **/* create a function */**  | 
-| OpenJsCad.log("​message"​); ​ **/* display message and time stamp */** | console.log("​message"​);​ /* display message */  | 
-| include... ​ | for (index = 0; index < array.length;​ index--;) { ... };  | 
- 
-//Note: Messages are displayed in the Javascript console in browsers.// 
  
 {{page>​quick_reference_shapes}} {{page>​quick_reference_shapes}}
Line 48: Line 36:
 | var path = vector_char(10,​-10,​ '​A'​);​ **/* X axis, Y axis, character */**  |  | | var path = vector_char(10,​-10,​ '​A'​);​ **/* X axis, Y axis, character */**  |  |
 | var array_of_paths = vector_text(10,​-10,​ '​Letters'​); ​ **/* X axis, Y axis, string of characters */**  | ::: | | var array_of_paths = vector_text(10,​-10,​ '​Letters'​); ​ **/* X axis, Y axis, string of characters */**  | ::: |
-===== Interactive Parameters ===== 
-A design can have interactive parameters by declaring a special function; getParameterDefinitions(). 
- 
-==== Usage ==== 
-This function must return an array of parameter definitions,​ as show below. 
- 
-<​code>​ 
-function getParameterDefinitions() { 
-    return [ 
-        { name: '​length',​ type: '​int',​ initial: 150, caption: '​Length?'​ },  
-        { name: '​width',​ type: '​int',​ initial: 100, caption: '​Width?'​ }, 
-    ]; 
-} 
-</​code>​ 
- 
-The parameters are evaluated and values are passed into the main function. Be sure to declare the main function properly. 
-<​code>​ 
-function main(params) { 
-  var l = params.length;​ 
-  var w = params.width;​ 
-... 
-} 
-</​code>​ 
-==== Parameter Types ==== 
-The parameters are defined as input fields on a single HTML5 form, i.e. the list of parameters. For more information on HTML5 input fields, see some examples at [[http://​www.w3schools.com/​html/​html_form_input_types.asp|W3 Schools]]. 
- 
-**Note: Browsers are NOT the same and will treat unsupported parameter types as TEXT.** 
- 
-^  Type  ^  Example ​ ^  Returned Value  ^ 
-| checkbox ​ | {name: '​bigorsmall',​ type: '​checkbox',​ checked: true, caption: '​Big?'​} ​ | if checked true, else false  | 
-| checkbox ​ | {name: '​bigorsmall',​ type: '​checkbox',​ checked: true, initial: 20, caption: '​Big?'​} ​ | if checked 20, else false   | 
-| color  | { name: '​color',​ type: '​color',​ initial: '#​FFB431',​ caption: '​Color?'​ }  | "#​rrggbb",​ use html2rgb() to convert ​ | 
-| date  | {name: '​birthday', ​ type: '​date',​ caption: '​Birthday?'​} ​ | "​YYYY-MM-DD" ​ | 
-| email  | {name: '​address',​ type: '​email',​ caption: 'Email Address?'​} ​ | string value  | 
-| float  | {name: '​angle',​ type: '​number',​ initial: 2.5, step: 0.5, caption: '​Angle?'​} ​ | float value  | 
-| int  | {name: '​age',​ type: '​int',​ initial: 20, caption: '​Age?'​} ​ | integer value  | 
-| number ​ | {name: '​angle',​ type: '​number',​ initial: 2.5, step: 0.5, caption: '​Angle?'​} ​ | float value  | 
-| password ​ | {name: '​password',​ type: '​password',​ caption: '​Secret?'​} ​ | string value  | 
-| slider ​ | {name: '​count',​ type: '​slider',​ min: 2, max: 10, caption: 'How many?'​} ​ | float value  | 
-| text  | {name: '​name',​ type: '​text',​ caption: '​Name?'​} ​ | string value  | 
-| url  | {name: '​webpage',​ type: '​url',​ caption: 'Web page URL?'​} ​ | string value  | 
-| group  | { name: '​balloon',​ type: '​group',​ caption: '​Balloons'​ }  | none, only displayed ​ | 
  
-//Note: The parameters accept additional restrictions and assistance. These include '​initial',​ '​max',​ '​maxLength',​ '​min',​ '​pattern',​ '​placeholder',​ '​size',​ and '​step'​.//​+{{page>​quick_reference_parameters}}