45 lines
1.9 KiB
JSON
45 lines
1.9 KiB
JSON
{
|
|
"source": "JSON",
|
|
"data": "BLOCK",
|
|
"version": "0.0.1",
|
|
"type": "javascript.conversion.rgb",
|
|
"language": "javascript",
|
|
"extension": "webaudio",
|
|
"help": "Creates RGB Color",
|
|
"label": "RGB",
|
|
"color": "#200200",
|
|
"group": "Conversion",
|
|
"codes": [
|
|
{
|
|
"name": "declaration",
|
|
"code": "\n// $label$\nvar r$id$ = '00';\nvar g$id$ = '00';\nvar b$id$ = '00';\nvar $port[result]$ = [];\n\nfunction update_backgroud_color$id$(){\n result = '#' + r$id$ + g$id$ + b$id$;\n for (var i = 0; i < $port[result]$.length ; i++){\n $port[result]$[i](result);\n }\n}\n\nvar $port[r]$ = function(value){\n value = Math.round(value);\n r$id$ = value.toString(16);\n if (value < 16)\n r$id$ = '0'+ r$id$;\n update_backgroud_color$id$();\n return true;\n };\n\nvar $port[g]$ = function(value){\n value = Math.round(value);\n g$id$ = value.toString(16);\n if (value < 16)\n g$id$ = '0'+ g$id$;\n update_backgroud_color$id$();\n return true;\n };\n\nvar $port[b]$ = function(value){\n value = Math.round(value);\n b$id$ = value.toString(16);\n if (value < 16)\n b$id$ = '0'+ b$id$;\n update_backgroud_color$id$();\n return true;\n };\n\n"
|
|
}
|
|
],
|
|
"properties": [],
|
|
"ports": [
|
|
{
|
|
"conn_type": "input",
|
|
"name": "r",
|
|
"label": "Red",
|
|
"type": "javascript.float"
|
|
},
|
|
{
|
|
"conn_type": "input",
|
|
"name": "g",
|
|
"label": "Green",
|
|
"type": "javascript.float"
|
|
},
|
|
{
|
|
"conn_type": "input",
|
|
"name": "b",
|
|
"label": "Blue",
|
|
"type": "javascript.float"
|
|
},
|
|
{
|
|
"conn_type": "output",
|
|
"name": "result",
|
|
"label": "Color",
|
|
"type": "javascript.color"
|
|
}
|
|
]
|
|
} |