plots: add image widget (#64)
This commit is contained in:
parent
447e14b555
commit
c403d22fdf
3 changed files with 108 additions and 3 deletions
|
|
@ -34,6 +34,7 @@ module.exports.widgets = {
|
|||
visualizer: require('./plots/visualizer'),
|
||||
meter: require('./plots/meter'),
|
||||
text: require('./plots/text'),
|
||||
image: require('./plots/image'),
|
||||
|
||||
// containers
|
||||
strip: require('./containers/strip'),
|
||||
|
|
@ -58,7 +59,7 @@ module.exports.categories = {
|
|||
'Buttons':['toggle','push','switch', 'dropdown'],
|
||||
'Pads':['xy','rgb','multixy'],
|
||||
'Matrices':['multifader','multitoggle','multipush', 'keyboard'],
|
||||
'Plots':['plot','eq','visualizer','led', 'rgbled','meter','text'],
|
||||
'Plots':['plot','eq','visualizer','led', 'rgbled','meter','text', 'image'],
|
||||
'Containers':['panel','strip','modal', 'clone'],
|
||||
'Switchers':['switcher','crossfader'],
|
||||
'Inputs':['input'],
|
||||
|
|
|
|||
76
src/browser/js/app/widgets/plots/image.js
Normal file
76
src/browser/js/app/widgets/plots/image.js
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
var {mapToScale} = require('../utils'),
|
||||
_widgets_base = require('../common/_widgets_base')
|
||||
|
||||
module.exports = class Led extends _widgets_base {
|
||||
|
||||
static defaults() {
|
||||
|
||||
return {
|
||||
type:'image',
|
||||
id:'auto',
|
||||
|
||||
_geometry:'geometry',
|
||||
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
|
||||
_style:'style',
|
||||
|
||||
label:'auto',
|
||||
// color:'auto',
|
||||
css:'',
|
||||
|
||||
_image:'image',
|
||||
|
||||
size: 'cover',
|
||||
position: 'center',
|
||||
border: true,
|
||||
cache: true,
|
||||
value:'',
|
||||
|
||||
_osc:'osc',
|
||||
|
||||
preArgs:[],
|
||||
address:'auto'
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
constructor(options) {
|
||||
|
||||
var html = `
|
||||
<div class="image"></div>
|
||||
`
|
||||
|
||||
super({...options, html: html})
|
||||
|
||||
if (!this.getProp('border')) this.container.addClass('noborder')
|
||||
|
||||
this.widget[0].style.setProperty('background-size', this.getProp('size'))
|
||||
this.widget[0].style.setProperty('background-position', this.getProp('position'))
|
||||
|
||||
|
||||
}
|
||||
|
||||
setValue(v) {
|
||||
|
||||
var s = '' + v
|
||||
|
||||
this.value = s
|
||||
|
||||
if (this.value.length) {
|
||||
|
||||
var cache_query = this.getProp('cache') || s.indexOf('base64') != -1 ? '' : (s.indexOf('?') != -1 ? '&' : '?') + Date.now()
|
||||
this.widget[0].style.setProperty('background-image', `url(${s}${cache_query})`)
|
||||
|
||||
} else {
|
||||
|
||||
this.widget[0].style.setProperty('background-image', '')
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue