multiXy: added pointSize option; made default size bigger; points don't overflow the pad anymore
This commit is contained in:
parent
dd0c6b896b
commit
80193568d3
4 changed files with 40 additions and 14 deletions
|
|
@ -1,7 +1,11 @@
|
|||
# Changelog
|
||||
|
||||
## 0.9.0
|
||||
## next
|
||||
|
||||
- widgets
|
||||
- multiXy: added `pointSize` option; made default size bigger; points don't overflow the pad anymore
|
||||
|
||||
## 0.9.0
|
||||
|
||||
- widgets
|
||||
- **new** `multixy` pad
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ Pads are multidimensional widgets that output multiple values.
|
|||
- usage:
|
||||
- set to `true` to send separate osc messages for `x` and `y` axis. The `path` will be the same as the widget's with `/x` or `/y` appended to it
|
||||
- can be set as an object to specify a different `path` : `{x:'/osc_path_x', y:'/osc_path_y'}`
|
||||
- note: the widget will only respond to its original osc path, not to the splitted version
|
||||
- note: the widget will only respond to its original osc path, not to the splitted version
|
||||
|
||||
----
|
||||
|
||||
|
|
@ -61,6 +61,15 @@ Pads are multidimensional widgets that output multiple values.
|
|||
}
|
||||
```
|
||||
|
||||
#### `points`
|
||||
- type: `integer`
|
||||
- default: `2`
|
||||
- usage: defines the number of points on the pad
|
||||
|
||||
#### `pointSize`
|
||||
- type: `integer`
|
||||
- default: `15`
|
||||
- usage: defines the points's size
|
||||
|
||||
#### `rangeX`
|
||||
- type: `object`
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ module.exports.options = {
|
|||
separator1:'multi xy',
|
||||
|
||||
points: 2,
|
||||
pointSize: 15,
|
||||
|
||||
separator2:'style',
|
||||
|
||||
|
|
@ -38,6 +39,9 @@ var MultiXy = module.exports.MultiXy = function(widgetData) {
|
|||
|
||||
_pads_base.apply(this,arguments)
|
||||
|
||||
this.pointSize = parseInt(this.widgetData.pointSize)
|
||||
this.widget[0].style.setProperty("--point-size",this.pointSize + 'rem')
|
||||
|
||||
this.split = this.widgetData.split?
|
||||
typeof this.widgetData.split == 'object'?
|
||||
this.widgetData.split
|
||||
|
|
@ -105,6 +109,9 @@ var MultiXy = module.exports.MultiXy = function(widgetData) {
|
|||
}
|
||||
this.setValue(v)
|
||||
|
||||
this.draw()
|
||||
this.updateHandlesPosition()
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -121,8 +128,8 @@ MultiXy.prototype.resizeHandle = function(){
|
|||
MultiXy.prototype.updateHandlesPosition = function(){
|
||||
for (var i=0;i<this.widgetData.points;i++) {
|
||||
this.handles[i][0].setAttribute('style',`
|
||||
transform:translate3d(${clip(this.pads[i].faders.x.percent,[0,100]) / 100 * this.width}px,
|
||||
${- clip(this.pads[i].faders.y.percent,[0,100]) / 100 * this.height}px,
|
||||
transform:translate3d(${clip(this.pads[i].faders.x.percent,[0,100]) / 100 * (this.width - (this.pointSize * 2 + 2) * PXSCALE) + (this.pointSize + 1) * PXSCALE}px,
|
||||
${- clip(this.pads[i].faders.y.percent,[0,100]) / 100 * (this.height - (this.pointSize * 2 + 2) * PXSCALE) - (this.pointSize + 1) * PXSCALE}px,
|
||||
0);
|
||||
`)
|
||||
}
|
||||
|
|
@ -137,11 +144,11 @@ MultiXy.prototype.draw = function(){
|
|||
this.ctx.strokeStyle = this.colors.custom
|
||||
|
||||
for (var i=0;i<this.widgetData.points;i++) {
|
||||
var x = clip(this.pads[i].faders.x.percent,[0,100]) / 100 * this.width,
|
||||
y = (100 - clip(this.pads[i].faders.y.percent,[0,100])) / 100 * this.height
|
||||
var x = clip(this.pads[i].faders.x.percent,[0,100]) / 100 * (this.width - (this.pointSize * 2 + 2) * PXSCALE) + (this.pointSize + 1) * PXSCALE,
|
||||
y = (100 - clip(this.pads[i].faders.y.percent,[0,100])) / 100 * (this.height - (this.pointSize * 2 + 2) * PXSCALE) + (this.pointSize + 1) * PXSCALE
|
||||
|
||||
this.ctx.beginPath()
|
||||
this.ctx.arc(x, y, 10 * PXSCALE, Math.PI * 2, false)
|
||||
this.ctx.arc(x, y, this.pointSize * PXSCALE, Math.PI * 2, false)
|
||||
this.ctx.stroke()
|
||||
|
||||
this.ctx.font = PXSCALE * 11 + 'px Droid Sans'
|
||||
|
|
|
|||
|
|
@ -99,11 +99,17 @@
|
|||
|
||||
.multixy-container {
|
||||
> .pad {
|
||||
--point-size:10rem;
|
||||
> .wrapper {
|
||||
padding: calc(var(--point-size) + 1rem);
|
||||
> canvas {
|
||||
top:0;
|
||||
left:0;
|
||||
}
|
||||
> .pad {
|
||||
position: absolute;
|
||||
width:100%;
|
||||
height:100%;
|
||||
width:calc(100% - calc(var(--point-size) * 2 + 2rem));
|
||||
height:calc(100% - calc(var(--point-size) * 2 + 2rem));
|
||||
pointer-events: none;
|
||||
.wrapper {
|
||||
background: transparent;
|
||||
|
|
@ -116,12 +122,12 @@
|
|||
position: absolute;
|
||||
left:0;
|
||||
bottom:0;
|
||||
width:24rem;
|
||||
height: 24rem;
|
||||
margin:0 0 -12rem -12rem;
|
||||
width:calc(var(--point-size) * 2 + 4rem);
|
||||
height: calc(var(--point-size) * 2 + 4rem);
|
||||
margin:0 0 calc(-1 * var(--point-size) - 2rem) calc(-1 * var(--point-size) - 2rem);
|
||||
text-align: center;
|
||||
line-height: 24rem;
|
||||
border-radius: 24rem;
|
||||
line-height: calc(var(--point-size) * 2 + 4rem);
|
||||
border-radius: calc(var(--point-size) * 2 + 4rem);
|
||||
cursor: -webkit-grab;
|
||||
opacity: 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue