@niivue/niivue 0.27.0 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/niivue.es.js CHANGED
@@ -111497,6 +111497,7 @@ function Niivue(options = {}) {
111497
111497
  isCornerOrientationText: false,
111498
111498
  sagittalNoseLeft: false,
111499
111499
  isSliceMM: false,
111500
+ isHighResolutionCapable: false,
111500
111501
  logging: false,
111501
111502
  loadingText: "waiting for images...",
111502
111503
  dragAndDropEnabled: true,
@@ -111866,8 +111867,12 @@ Niivue.prototype.arrayEquals = function(a, b) {
111866
111867
  Niivue.prototype.resizeListener = function() {
111867
111868
  this.canvas.style.width = "100%";
111868
111869
  this.canvas.style.height = "100%";
111869
- this.canvas.width = this.canvas.offsetWidth;
111870
- this.canvas.height = this.canvas.offsetHeight;
111870
+ let dpr = 1;
111871
+ if (this.opts.isHighResolutionCapable)
111872
+ dpr = window.devicePixelRatio || 1;
111873
+ this.canvas.width = this.canvas.offsetWidth * dpr;
111874
+ this.canvas.height = this.canvas.offsetHeight * dpr;
111875
+ console.log("RESIZE" + dpr);
111871
111876
  this.drawScene();
111872
111877
  };
111873
111878
  Niivue.prototype.getRelativeMousePosition = function(event, target) {
@@ -112073,6 +112078,8 @@ Niivue.prototype.mouseMoveListener = function(e) {
112073
112078
  }
112074
112079
  };
112075
112080
  Niivue.prototype.resetBriCon = function(msg2 = null) {
112081
+ if (this.isDragging)
112082
+ return;
112076
112083
  let isRender = false;
112077
112084
  if (this.sliceType === this.sliceTypeRender)
112078
112085
  isRender = true;
@@ -112110,6 +112117,7 @@ Niivue.prototype.touchMoveListener = function(e) {
112110
112117
  if (this.doubleTouch && this.isDragging) {
112111
112118
  this.dragEnd[0] = e.targetTouches[0].clientX - e.target.getBoundingClientRect().left;
112112
112119
  this.dragEnd[1] = e.targetTouches[0].clientY - e.target.getBoundingClientRect().top;
112120
+ this.drawScene();
112113
112121
  return;
112114
112122
  }
112115
112123
  this.mouseClick(e.touches[0].clientX - rect.left, e.touches[0].clientY - rect.top);
@@ -112360,6 +112368,12 @@ Niivue.prototype.setSliceMM = function(isSliceMM) {
112360
112368
  Niivue.prototype.getRadiologicalConvention = function() {
112361
112369
  return this.opts.isRadiologicalConvention;
112362
112370
  };
112371
+ Niivue.prototype.setHighResolutionCapable = function(isHighResolutionCapable) {
112372
+ this.opts.isHighResolutionCapable = isHighResolutionCapable;
112373
+ console.log("HighDPI feature is experimental");
112374
+ this.resizeListener();
112375
+ this.drawScene();
112376
+ };
112363
112377
  Niivue.prototype.addVolume = function(volume) {
112364
112378
  this.volumes.push(volume);
112365
112379
  let idx = this.volumes.length === 1 ? 0 : this.volumes.length - 1;
@@ -113739,6 +113753,8 @@ Niivue.prototype.init = async function() {
113739
113753
  }
113740
113754
  this.updateGLVolume();
113741
113755
  this.initialized = true;
113756
+ if (this.opts.isHighResolutionCapable)
113757
+ this.resizeListener();
113742
113758
  this.drawScene();
113743
113759
  return this;
113744
113760
  };
@@ -114683,7 +114699,7 @@ function deg2rad(deg) {
114683
114699
  }
114684
114700
  Niivue.prototype.calculateMvpMatrix2D = function(leftTopWidthHeight, mn, mx, clipTolerance = Infinity, clipDepth = 0, azimuth = null, elevation = null, isRadiolgical) {
114685
114701
  let gl = this.gl;
114686
- gl.viewport(leftTopWidthHeight[0], this.gl.canvas.clientHeight - (leftTopWidthHeight[1] + leftTopWidthHeight[3]), leftTopWidthHeight[2], leftTopWidthHeight[3]);
114702
+ gl.viewport(leftTopWidthHeight[0], this.gl.canvas.height - (leftTopWidthHeight[1] + leftTopWidthHeight[3]), leftTopWidthHeight[2], leftTopWidthHeight[3]);
114687
114703
  let left = mn[0];
114688
114704
  let right = mx[0];
114689
114705
  let leftTopMM = [left, mn[1]];
@@ -115712,7 +115728,7 @@ Niivue.prototype.canvasPos2frac = function(canvasPos) {
115712
115728
  return [-1, -1, -1];
115713
115729
  };
115714
115730
  Niivue.prototype.scaleSlice = function(w, h, widthPadPixels = 0, heightPadPixels = 0) {
115715
- let canvasW = this.gl.canvas.clientWidth - widthPadPixels;
115731
+ let canvasW = this.canvas.width - widthPadPixels;
115716
115732
  let canvasH = this.effectiveCanvasHeight() - heightPadPixels;
115717
115733
  let scalePix = canvasW / w;
115718
115734
  if (h * scalePix > canvasH)