From 754be9108c6e1bd14be52b11b3eeaa7a558a117a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Thu, 17 Mar 2016 15:10:02 -0400 Subject: [PATCH 1/3] scale contour intensity to intensityBounds --- surface.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/surface.js b/surface.js index bbe231d..67aebe8 100644 --- a/surface.js +++ b/surface.js @@ -968,6 +968,9 @@ proto.update = function (params) { // Save intensity this.intensity = params.intensity || this._field[2] + + // Save intensity bound + this.intensityBounds = [lo_intensity, hi_intensity] } // Update level crossings @@ -1049,7 +1052,7 @@ proto.update = function (params) { if (dd < 2) { f = this._field[iu].get(r, c) } else { - f = this.intensity.get(r, c) + f = (this.intensity.get(r, c) - this.intensityBounds[0]) / (this.intensityBounds[1] - this.intensityBounds[0]) } if (!isFinite(f) || isNaN(f)) { hole = true From e3882cb52dc71e255d42a6c826d811dc1d7e93f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Thu, 17 Mar 2016 16:04:37 -0400 Subject: [PATCH 2/3] update README --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f408b45..954ba8a 100644 --- a/README.md +++ b/README.md @@ -50,8 +50,9 @@ Creates a surface plot object. `params` is an object with any of the following * `gl` is a WebGL context * `field` a new 2D field encoded as an ndarray * `coords` is an array of 3 2D fields, each encoded as ndarrays (for parameteric surfaces) -* `colormap` the name of the new color map for the surface -* `colorBounds` sets the z range for the colormap +* `intensity` a 2D intensity field (defaults to `field` or `coords[2] is not present) +* `colormap` the name of the new color map for the surface (see list of names in `colormap` [docs](https://github.com/bpostlethwaite/colormap)) +* `intensityBounds` sets the intensity range for the colormap * `ticks` is a pair of arrays of ticks representing the spacing of the points for the axes of the surface * `showSurface` if set, draw the surface * `showContour` if set, draw contour lines From 95a8207d3dd150cd23b99b7863b65c2aefa4a9d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Mon, 21 Mar 2016 11:00:11 -0400 Subject: [PATCH 3/3] update level colors on updates --- surface.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/surface.js b/surface.js index 67aebe8..4f3cc08 100644 --- a/surface.js +++ b/surface.js @@ -97,6 +97,7 @@ function SurfacePlot ( this.gl = gl this.shape = shape this.bounds = bounds + this.intensityBounds = []; this._shader = shader this._pickShader = pickShader @@ -750,6 +751,7 @@ proto.update = function (params) { } var field = params.field || (params.coords && params.coords[2]) || null + var levelsChanged = false if (!field) { if (this._field[2].shape[0] || this._field[2].shape[2]) { @@ -969,12 +971,15 @@ proto.update = function (params) { // Save intensity this.intensity = params.intensity || this._field[2] + if(this.intensityBounds[0] !== lo_intensity || this.intensityBounds[1] !== hi_intensity) { + levelsChanged = true + } + // Save intensity bound this.intensityBounds = [lo_intensity, hi_intensity] } // Update level crossings - var levelsChanged = false if ('levels' in params) { var levels = params.levels if (!Array.isArray(levels[0])) {