Skip to content

Commit

Permalink
Rename _isFrom(Z|Source) to _has(Z|Source)
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinerg committed Aug 19, 2020
1 parent 2960e55 commit 3717cbe
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/traces/image/calc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions src/traces/image/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/traces/image/hover.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
10 changes: 5 additions & 5 deletions src/traces/image/plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 &&
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 3717cbe

Please sign in to comment.