meta data for this page
  •  

Differences

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

Link to this comparison view

Next revision
Previous revision
en:quick_reference_parameters [2020/11/28 01:52]
Admin created
en:quick_reference_parameters [2021/05/12 08:02] (current)
JSCAD Editor
Line 1: Line 1:
 ==== Design Parameters ==== ==== Design Parameters ====
-A design can have parameters by declaring a special function; getParameterDefinitions(). 
  
-In applications and browsers, these parameters are presented to users, allowing users to interactively change designs.+A design can have interactive parameters by declaring a special function; getParameterDefinitions(). 
 + 
 +In applications and browsers, these parameters are presented to users, allowing users to change designs.
  
 === Usage === === Usage ===
 +
 This function must return an array of parameter definitions, as show below. This function must return an array of parameter definitions, as show below.
  
-<code> +<code javascript
-function getParameterDefinitions() {+const getParameterDefinitions () => {
     return [     return [
         { name: 'length', type: 'int', initial: 150, caption: 'Length?' },          { name: 'length', type: 'int', initial: 150, caption: 'Length?' }, 
         { name: 'width', type: 'int', initial: 100, caption: 'Width?' },         { name: 'width', type: 'int', initial: 100, caption: 'Width?' },
-    ];+    ]
 } }
 </code> </code>
  
 The parameters are evaluated and values are passed into the main function. Be sure to declare the main function properly. The parameters are evaluated and values are passed into the main function. Be sure to declare the main function properly.
-<code> + 
-function main(params) { +<code javascript
-  var l = params.length; +const main (params) => 
-  var w = params.width;+  var l = params.length 
 +  var w = params.width
 ... ...
 } }
Line 26: Line 29:
  
 === Parameter Types === === 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]]. 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]].
  
Line 49: Line 53:
 There is one more special parameter type called 'choice', which defines a list of choices for selection. There is one more special parameter type called 'choice', which defines a list of choices for selection.
  
-<code> +<code javascript
-function getParameterDefinitions () {+const getParameterDefinitions () => {
   return [   return [
     { name: 'rounded', type: 'choice', caption: 'Rounded edges', values: [0, 1], captions: ['No', 'Yes (slow!)'], initial: 0 }     { name: 'rounded', type: 'choice', caption: 'Rounded edges', values: [0, 1], captions: ['No', 'Yes (slow!)'], initial: 0 }
-  ];+  ]
 } }
 </code> </code>
  
-The list of captions are those shown in the HTML form, i.e. pull down list. The list of values define a value for each caption. And, the choosen value passed into the main() function.+The list of captions are those shown as a pull down list. The list of values define a value for each caption. And, the chosen value is passed into the main function.