plots: add smooth option (thanks to cardinal-spline-js) and make the line thicker
This commit is contained in:
parent
02c01aa80c
commit
c8c952fed7
6 changed files with 20 additions and 22 deletions
|
|
@ -7,6 +7,7 @@
|
|||
"babel-preset-es2015": "6.24.1",
|
||||
"babelify": "7.3.0",
|
||||
"browserify": "14.4.0",
|
||||
"cardinal-spline-js": "^2.3.6",
|
||||
"electron": "1.8.0",
|
||||
"electron-packager": "9.0.1",
|
||||
"exorcist": "0.4.0",
|
||||
|
|
|
|||
|
|
@ -70,7 +70,8 @@ module.exports = class _plots_base extends _canvas_base {
|
|||
|
||||
this.draw_data()
|
||||
|
||||
this.ctx.lineWidth = 1*PXSCALE
|
||||
this.ctx.globalAlpha = 0.7
|
||||
this.ctx.lineWidth = 1.5 * PXSCALE
|
||||
this.ctx.strokeStyle = this.colors.custom
|
||||
this.ctx.stroke()
|
||||
|
||||
|
|
@ -86,11 +87,11 @@ module.exports = class _plots_base extends _canvas_base {
|
|||
this.ctx.lineTo(0,origin)
|
||||
this.ctx.closePath()
|
||||
this.ctx.fill()
|
||||
this.ctx.globalAlpha = 1
|
||||
|
||||
}
|
||||
|
||||
|
||||
this.ctx.globalAlpha = 1
|
||||
this.ctx.font = PXSCALE * 10 + 'px sans-serif'
|
||||
this.ctx.fillStyle = this.colors.text
|
||||
|
||||
|
|
@ -128,36 +129,28 @@ module.exports = class _plots_base extends _canvas_base {
|
|||
|
||||
draw_data() {
|
||||
|
||||
var first = true
|
||||
var point = []
|
||||
var points = []
|
||||
for (let i in this.data) {
|
||||
|
||||
if (this.data[i][1]>this.rangeY.max || this.data[i][1]<this.rangeY.min ||
|
||||
this.data[i][0]>this.rangeX.max || this.data[i][0]<this.rangeX.min) continue
|
||||
|
||||
var newpoint = this.data[i].length?
|
||||
[
|
||||
mapToScale(this.data[i][0],[this.rangeX.min,this.rangeX.max],[0,this.width],0,this.getProp('logScaleX'),true),
|
||||
mapToScale(this.data[i][1],[this.rangeY.min,this.rangeY.max],[this.height-PXSCALE,PXSCALE],0,this.getProp('logScaleY'),true),
|
||||
]
|
||||
:
|
||||
[
|
||||
mapToScale(i,[0,this.data.length-1],[0,this.width],0,this.getProp('logScaleX'),true),
|
||||
mapToScale(this.data[i],[this.rangeY.min,this.rangeY.max],[this.height-PXSCALE,PXSCALE],0,this.getProp('logScaleY'),true),
|
||||
]
|
||||
|
||||
|
||||
if (first) {
|
||||
this.ctx.moveTo(newpoint[0],newpoint[1])
|
||||
this.ctx.lineTo(newpoint[0],newpoint[1])
|
||||
first = false
|
||||
if (this.data[i].length) {
|
||||
points.push(mapToScale(this.data[i][0],[this.rangeX.min,this.rangeX.max],[0,this.width],0,this.getProp('logScaleX'),true))
|
||||
points.push(mapToScale(this.data[i][1],[this.rangeY.min,this.rangeY.max],[this.height-PXSCALE,PXSCALE],0,this.getProp('logScaleY'),true))
|
||||
} else {
|
||||
// this.ctx.moveTo(point[0],point[1])
|
||||
this.ctx.lineTo(newpoint[0],newpoint[1])
|
||||
points.push(mapToScale(i,[0,this.data.length-1],[0,this.width],0,this.getProp('logScaleX'),true))
|
||||
points.push(mapToScale(this.data[i],[this.rangeY.min,this.rangeY.max],[this.height-PXSCALE,PXSCALE],0,this.getProp('logScaleY'),true))
|
||||
}
|
||||
point = newpoint
|
||||
|
||||
}
|
||||
|
||||
this.ctx.curve(points, this.getProp('smooth') ? 0.25 : 0,this.width/(points.length/2 - 1))
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
setValue(v) {
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ module.exports = class Eq extends _plots_base {
|
|||
rangeY: {min:-20,max:20},
|
||||
origin: 'auto',
|
||||
logScaleX: false,
|
||||
smooth: false,
|
||||
|
||||
_osc:'osc',
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ module.exports = class Plot extends _plots_base {
|
|||
origin: 'auto',
|
||||
logScaleX: false,
|
||||
logScaleY: false,
|
||||
smooth: false,
|
||||
pips:true,
|
||||
|
||||
_osc:'osc',
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ module.exports = class Visualizer extends _plots_base {
|
|||
range: {min:0,max:1},
|
||||
origin: 'auto',
|
||||
logScale: false,
|
||||
smooth: false,
|
||||
pips:true,
|
||||
value:'',
|
||||
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ window.$ = require('jquery/dist/jquery.slim.min.js')
|
|||
require('./libs/jquery.ui')
|
||||
require('./libs/jquery.drag')
|
||||
require('./libs/jquery.resize')
|
||||
require('cardinal-spline-js/curve.js')
|
||||
|
||||
///////////////////////
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue