From 3717cbe7429e1266be24a19ce406f601f3718410 Mon Sep 17 00:00:00 2001 From: Antoine Roy-Gobeil Date: Wed, 19 Aug 2020 11:48:29 -0400 Subject: [PATCH] Rename _isFrom(Z|Source) to _has(Z|Source) --- src/traces/image/calc.js | 4 ++-- src/traces/image/defaults.js | 10 +++++----- src/traces/image/hover.js | 4 ++-- src/traces/image/plot.js | 10 +++++----- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/traces/image/calc.js b/src/traces/image/calc.js index 26638511f5c..7a21300ed72 100644 --- a/src/traces/image/calc.js +++ b/src/traces/image/calc.js @@ -20,10 +20,10 @@ var Buffer = require('buffer/').Buffer; // note: the trailing slash is importan module.exports = function calc(gd, trace) { var h; var w; - if(trace._isFromZ) { + if(trace._hasZ) { h = trace.z.length; w = maxRowLength(trace.z); - } else if(trace._isFromSource) { + } else if(trace._hasSource) { var size = getImageSize(trace.source); h = size.height; w = size.width; diff --git a/src/traces/image/defaults.js b/src/traces/image/defaults.js index 132f94476ba..dba4fc5711c 100644 --- a/src/traces/image/defaults.js +++ b/src/traces/image/defaults.js @@ -20,11 +20,11 @@ module.exports = function supplyDefaults(traceIn, traceOut) { coerce('source'); // sanitize source to only allow for data URI representing images if(traceOut.source && !traceOut.source.match(dataUri)) delete traceOut.source; - traceOut._isFromSource = !!traceOut.source; + traceOut._hasSource = !!traceOut.source; var z = coerce('z'); - traceOut._isFromZ = !(z === undefined || !z.length || !z[0] || !z[0].length); - if(!traceOut._isFromZ && !traceOut._isFromSource) { + traceOut._hasZ = !(z === undefined || !z.length || !z[0] || !z[0].length); + if(!traceOut._hasZ && !traceOut._hasSource) { traceOut.visible = false; return; } @@ -34,11 +34,11 @@ module.exports = function supplyDefaults(traceIn, traceOut) { coerce('dx'); coerce('dy'); - if(traceOut._isFromZ) { + if(traceOut._hasZ) { coerce('colormodel'); coerce('zmin', constants.colormodel[traceOut.colormodel].min); coerce('zmax', constants.colormodel[traceOut.colormodel].max); - } else if(traceOut._isFromSource) { + } else if(traceOut._hasSource) { traceOut.colormodel = 'rgba'; traceOut.zmin = constants.colormodel[traceOut.colormodel].min; traceOut.zmax = constants.colormodel[traceOut.colormodel].max; diff --git a/src/traces/image/hover.js b/src/traces/image/hover.js index 92b49ab090d..9e977d88c83 100644 --- a/src/traces/image/hover.js +++ b/src/traces/image/hover.js @@ -29,9 +29,9 @@ module.exports = function hoverPoints(pointData, xval, yval) { var ny = Math.floor(Math.abs(yval - cd0.y0) / trace.dy); var pixel; - if(trace._isFromZ) { + if(trace._hasZ) { pixel = cd0.z[ny][nx]; - } else if(trace._isFromSource) { + } else if(trace._hasSource) { pixel = trace._canvas.el.getContext('2d').getImageData(nx, ny, 1, 1).data; } diff --git a/src/traces/image/plot.js b/src/traces/image/plot.js index 1c37aa0033f..21b8b5e2eab 100644 --- a/src/traces/image/plot.js +++ b/src/traces/image/plot.js @@ -31,7 +31,7 @@ module.exports = function plot(gd, plotinfo, cdimage, imageLayer) { var plotGroup = d3.select(this); var cd0 = cd[0]; var trace = cd0.trace; - var fastImage = supportsPixelatedImage && trace._isFromSource && compatibleAxis(xa) && compatibleAxis(ya); + var fastImage = supportsPixelatedImage && trace._hasSource && compatibleAxis(xa) && compatibleAxis(ya); trace._fastImage = fastImage; var z = cd0.z; @@ -147,9 +147,9 @@ module.exports = function plot(gd, plotinfo, cdimage, imageLayer) { .attr('style', 'image-rendering: optimizeSpeed; image-rendering: -moz-crisp-edges; image-rendering: -o-crisp-edges; image-rendering: -webkit-optimize-contrast; image-rendering: optimize-contrast; image-rendering: crisp-edges; image-rendering: pixelated;'); var p = new Promise(function(resolve) { - if(trace._isFromZ) { + if(trace._hasZ) { resolve(); - } else if(trace._isFromSource) { + } else if(trace._hasSource) { // Check if canvas already exists and has the right data if( trace._canvas && @@ -185,9 +185,9 @@ module.exports = function plot(gd, plotinfo, cdimage, imageLayer) { href = trace.source; } else { var canvas; - if(trace._isFromZ) { + if(trace._hasZ) { canvas = drawMagnifiedPixelsOnCanvas(function(i, j) {return z[j][i];}); - } else if(trace._isFromSource) { + } else if(trace._hasSource) { var context = trace._canvas.el.getContext('2d'); var data = context.getImageData(0, 0, w, h).data; canvas = drawMagnifiedPixelsOnCanvas(function(i, j) {