mosaicode/extensions/javascript/blocks/webaudio/Arithmetics/Modulus.json

47 lines
1.6 KiB
JSON

{
"source": "JSON",
"data": "BLOCK",
"version": "0.0.1",
"type": "javascript.arithmetics.modulus",
"language": "javascript",
"extension": "webaudio",
"help": "Modulus Operation (%)",
"label": "Modulus",
"color": "#F54A01",
"group": "Arithmetics",
"codes": [
{
"name": "onload",
"code": "\n"
},
{
"name": "declaration",
"code": "\nvar dividend$id$ = 0.0;\nvar divisor$id$ = 1.0;\n \nvar $port[rest]$ = [];\n\nfunction modulus$id$() {\n if (divisor$id$ === 0.0) {\n divisor$id$ = 1.0;\n }\n \n var rest = dividend$id$ % divisor$id$;\n for (var i = 0; i < $port[rest]$.length ; i++){\n $port[rest]$[i](rest);\n }\n \n return true;\n}\n\nvar $port[dividend]$ = function(value){\n dividend$id$ = Math.round(value);\n modulus$id$();\n return true;\n};\n\nvar $port[divisor]$ = function(value){\n divisor$id$ = Math.round(value);\n modulus$id$();\n return true;\n};\n"
},
{
"name": "execution",
"code": "\n"
}
],
"properties": [],
"ports": [
{
"conn_type": "input",
"name": "dividend",
"label": "Dividend",
"type": "javascript.float"
},
{
"conn_type": "input",
"name": "divisor",
"label": "Divisor",
"type": "javascript.float"
},
{
"conn_type": "output",
"name": "rest",
"label": "Rest",
"type": "javascript.float"
}
]
}