eq/plot: smoother curves

This commit is contained in:
jean-emmanuel 2025-03-11 08:16:04 +01:00
parent f9902e01e0
commit c829d87eae
2 changed files with 5 additions and 5 deletions

View file

@ -11,6 +11,7 @@
- eq: adapt sampling frequency to the x-axis range
- xy/multixy: add `auto` choice to to `axisLock` (locks on the first moved axis)
- file: `extension` can now be an array of strings
- plot/eq: smoother curves
## 1.27.5

View file

@ -123,22 +123,21 @@ module.exports = class Plot extends StaticProperties(Canvas, {bypass: true, inte
var points = [],
padding = this.cssVars.padding + this.cssVars.lineWidth,
decimals = this.getProp('smooth') ? 1 : 0,
length = this.value.length,
x, y, i, previousValue, nx, ny
for (i = 0; i < length; i++) {
if (this.value[i].length) {
points.push(mapToScale(this.value[i][0], [this.rangeX.min, this.rangeX.max], [padding, this.width - padding], decimals, this.logScaleX, true))
points.push(mapToScale(this.value[i][1], [this.rangeY.min, this.rangeY.max], [this.height - 2 * PXSCALE - padding, 2 * PXSCALE + padding], decimals, this.logScaleY, true))
points.push(mapToScale(this.value[i][0], [this.rangeX.min, this.rangeX.max], [padding, this.width - padding], -1, this.logScaleX, true))
points.push(mapToScale(this.value[i][1], [this.rangeY.min, this.rangeY.max], [this.height - 2 * PXSCALE - padding, 2 * PXSCALE + padding], -1, this.logScaleY, true))
} else {
if (i < length - 2 && this.value[i] === previousValue && this.value[i+1] === previousValue) {
continue
}
nx = mapToScale(i, [0, this.value.length - 1], [padding, this.width - padding], decimals, this.logScaleX, true)
ny = mapToScale(this.value[i], [this.rangeY.min, this.rangeY.max], [this.height - 2 * PXSCALE - padding, 2 * PXSCALE + padding], decimals, this.logScaleY, true)
nx = mapToScale(i, [0, this.value.length - 1], [padding, this.width - padding], -1, this.logScaleX, true)
ny = mapToScale(this.value[i], [this.rangeY.min, this.rangeY.max], [this.height - 2 * PXSCALE - padding, 2 * PXSCALE + padding], -1, this.logScaleY, true)
if (x !== nx || y !== ny) {
points.push(nx)