Jsmath
Intro
Use JavaScript to perform mathematical operations on values.
UI
Expression - An area to input mathematical operations/JavaScript expressions.
Result - A read only attribute previewing the result of the Expression.
Add - Use this button to add more indices to the UI.
0: Number - The first index in the array.
To reference a row in the expression use the syntax n[index number]
. For example, to reference the index labelled 0: Number use the syntax n0.
Any strings with n
followed by a value
will be coloured to help visually identify them within an expression.
Adding the values of two attributes together.
- Create 3 Shapes.
- Create a Jsmath Utility.
- Connect basicShape1.position.x→jsmath.number0.
- Connect basicShape2.position.x→jsmath.number1.
- Enter
n0 + n1
into the Expression input. - Connect jsmath.id→basicShape3.position.x to output the result.
Move Shape1 in X at a value of .
- Create 2 Shapes.
- Create a Jsmath Utility.
- Connect basicShape1.position.x→jsmath.number0
- Enter
Math.sqrt(n0)
into the Expression input. - Connect jsmath.id→basicShape2.position.x
See https://htmlcheatsheet.com/js/ for some JavaScript syntax.
To remove indices from the array, select a row or rows, right click and choose Delete Selected Attribute(s).
Right click on an index row and select Rename to rename an index.
Reorder indices by right clicking on a index row and select Reorder.
It's possible to write If Statements with the Jsmath Layer. For example...
if (n0 > n1) {1} else {0}
or the equivalent ternary n0 > n1 ? 1 : 0
...translate to "If n0
is greater than n1
then output 1
. If not, output 0
"