visualizer & plot can receive osc

This commit is contained in:
jean-emmanuel 2016-03-14 20:45:38 +01:00
parent d435d067ae
commit 925694d874
3 changed files with 95 additions and 22 deletions

View file

@ -20,7 +20,11 @@ module.exports.options = {
rangeX: {min:0,max:1},
rangeY: {min:0,max:1},
logScaleX: false,
logScaleY: false
logScaleY: false,
separator3:'osc',
path:'auto'
}
module.exports.create = function(widgetData,container) {
@ -193,9 +197,13 @@ module.exports.create = function(widgetData,container) {
}
widget.data = data
if (data.length) widget.data = data
}
widget.setValue = function(v) {
widget.data = v
requestAnimationFrame(widget.draw)
}
return widget
}

View file

@ -21,6 +21,9 @@ module.exports.options = {
range: {min:0,max:1},
logScale: false,
separator3:'osc',
path:'auto'
}
module.exports.create = function(widgetData,container) {
@ -67,24 +70,28 @@ module.exports.create = function(widgetData,container) {
$('body').on('sync',function(e,id,w){
if (widgetData.curve!=id || !document.contains(widget[0])) return
if (widget.cancel) clearTimeout(widget.cancel)
widget.cancel = setTimeout(function(){
clearInterval(widget.loop)
widget.loop = false
},1000*widgetData.duration)
if (widget.loop) return
widget.loop = widget.createLoop()
widget.handleSync()
})
widget.cancel = false
widget.loop = false
widget.createLoop = function(){
return setInterval(function(){
widget.fetchValue()
widget.draw()
widget.startLoop = function(){
if (widget.cancel) clearTimeout(widget.cancel)
widget.cancel = setTimeout(function(){
clearInterval(widget.loop)
widget.loop = false
widget.cancel = false
},1000*widgetData.duration)
if (widget.loop) return
widget.loop = setInterval(function(){
widget.fetchValue()
widget.draw()
},1000*widgetData.duration/widget.length)
}
@ -141,12 +148,22 @@ module.exports.create = function(widgetData,container) {
widget.fetchValue = function(){
var id = widgetData.curve
if (!typeof id == 'string' || !WIDGETS[id] || !WIDGETS[id].length ) return
widget.data.push(WIDGETS[id][WIDGETS[id].length-1].getValue())
if (typeof id == 'string' && WIDGETS[id]) {
widget.data.push(WIDGETS[id][WIDGETS[id].length-1].getValue())
} else {
widget.data.push(widget.data[widget.data.length-1])
}
widget.data.splice(0,1)
}
widget.setValue = function(v) {
widget.data.push(v)
widget.data.splice(0,1)
widget.handleSync()
}
return widget
}

View file

@ -126,7 +126,8 @@
"max": 1
},
"logScaleX": false,
"logScaleY": false
"logScaleY": false,
"path": "/plot_1"
},
{
"type": "visualizer",
@ -180,7 +181,8 @@
"logScaleX": false,
"logScaleY": false,
"id": "plot_2",
"label": "plot_2 (rgb)"
"label": "plot_2 (rgb)",
"path": "/plot_2"
}
]
},
@ -226,7 +228,8 @@
"max": 1
},
"logScaleX": false,
"logScaleY": false
"logScaleY": false,
"path": "/plot_3"
},
{
"type": "multitoggle",
@ -266,7 +269,52 @@
},
"logScaleX": false,
"logScaleY": false,
"id": "plot_4"
"id": "plot_4",
"path": "/plot_4"
}
]
},
{
"label": "Another plot",
"widgets": [
{
"type": "plot",
"id": "plot_5",
"left": "auto",
"top": "auto",
"width": 612,
"height": 309,
"css": "",
"rangeX": {
"min": 0,
"max": 5
},
"rangeY": {
"min": 0,
"max": 5
},
"logScaleX": false,
"logScaleY": false,
"path": "/plot_5",
"label": "plot_5",
"points": []
},
{
"type": "visualizer",
"id": "visualizer_1",
"label": "visualizer_1",
"left": "auto",
"top": "auto",
"width": "auto",
"height": "auto",
"css": "",
"curve": "",
"duration": 1,
"range": {
"min": 0,
"max": 1
},
"logScale": false
}
]
}