Update rotation parmeters based on mouse movement
330646
def _update_rotation(self, event):
        """"""
        p1 = event.mouse_event.press_event.pos
        p2 = event.mouse_event.pos
        if self._event_value is None:
            self._event_value = self.azimuth, self.elevation
        self.azimuth = self._event_value[0] - (p2 - p1)[0] * 0.5
        self.elevation = self._event_value[1] + (p2 - p1)[1] * 0.5
642589
function(time, x, y) {
		if(time - _gestureCheckSpeedTime > 50) {
			var o = _posPoints.length > 2 ? _posPoints.shift() : {};
			o.x = x;
			o.y = y; 
			_posPoints.push(o);
			_gestureCheckSpeedTime = time;
		}
	}
749925
def do_rotation(self, mirror, rot):
        """"""
        infile = self.tmpfile
        outfile = self.basename + '.rot'
        # NOTE: pnmrotate: angle must be between -90 and 90 and
        # rotations is CCW not CW per IIIF spec
        #
        # BUG in pnmrotate: +90 and -90 rotations the output image
        # size may be off. See for example a 1000x1000 image becoming
        # 1004x1000:
        #
        # simeon@RottenApple iiif>file testimages/67352ccc-d1b0-11e1-89ae-279075081939.png
        # testimages/67352ccc-d1b0-11e1-89ae-279075081939.png: PNG image data, 1000 x 1000, 8-bit/color RGB, non-interlaced
        # simeon@RottenApple iiif>cat testimages/67352ccc-d1b0-11e1-89ae-279075081939.png  | pngtopnm | pnmrotate -90 | pnmtopng > a.png; file a.png; rm a.png
        # a.png: PNG image data, 1004 x 1000, 8-bit/color RGB, non-interlaced
        # simeon@RottenApple iiif>cat testimages/67352ccc-d1b0-11e1-89ae-279075081939.png  | pngtopnm | pnmrotate 90 | pnmtopng > a.png; file a.png; rm a.png
        # a.png: PNG image data, 1004 x 1000, 8-bit/color RGB, non-interlaced
        #
        # WORKAROUND is to add a pnmscale for the 90degree case, some
        # simeon@RottenApple iiif>cat testimages/67352ccc-d1b0-11e1-89ae-279075081939.png  | pngtopnm | pnmrotate -90| pnmscale -width 1000 -height 1000 | pnmtopng > a.png; file a.png; rm a.png
        # a.png: PNG image data, 1000 x 1000, 8-bit/color RGB, non-interlaced
        #
        # FIXME - add mirroring
        #
        if (rot == 0.0):
            # print "rotation: no rotation"
            self.tmpfile = infile
        elif (rot <= 90.0 or rot >= 270.0):
            if (rot >= 270.0):
                rot -= 360.0
            # print "rotation: by %f degrees clockwise" % (rot)
            if (self.shell_call('cat ' + infile + ' | ' + self.pnmrotate + ' -background=#FFF ' + str(-rot) + '  > ' + outfile)):
                raise IIIFError(
                    text="Oops... got nonzero output from pnmrotate.")
            self.tmpfile = outfile
        else:
            # Between 90 and 270 = flip and then -90 to 90
            rot -= 180.0
            # print "rotation: by %f degrees clockwise" % (rot)
            if (self.shell_call('cat ' + infile + ' | ' + self.pnmflip + ' -rotate180 | ' + self.pnmrotate + ' ' + str(-rot) + '  > ' + outfile)):
                raise IIIFError(
                    text="Oops... got nonzero output from pnmrotate.")
            self.tmpfile = outfile
        # Fixup size for 90s
        if (abs(rot % 180.0 - 90.0) < 0.001):
            outfile2 = self.basename + '.rot2'
            if (self.shell_call('cat ' + self.tmpfile + ' | ' + self.pnmscale + ' -width ' + str(self.height) + ' -height ' + str(self.width) + ' > ' + outfile2)):
                raise IIIFError(
                    text="Oops... failed to fixup size after pnmrotate.")
            self.tmpfile = outfile2
436876
function _wheelHandler(e) {
      var pos,
          ratio,
          animation,
          wheelDelta = sigma.utils.getDelta(e);

      if (_settings('mouseEnabled') && _settings('mouseWheelEnabled') && wheelDelta !== 0) {
        ratio = wheelDelta > 0 ?
          1 / _settings('zoomingRatio') :
          _settings('zoomingRatio');

        pos = _camera.cameraPosition(
          sigma.utils.getX(e) - sigma.utils.getCenter(e).x,
          sigma.utils.getY(e) - sigma.utils.getCenter(e).y,
          true
        );

        animation = {
          duration: _settings('mouseZoomDuration')
        };

        sigma.utils.zoomTo(_camera, pos.x, pos.y, ratio, animation);

        if (e.preventDefault)
          e.preventDefault();
        else
          e.returnValue = false;

        e.stopPropagation();
        return false;
      }
    }
1232897
def ms_rotate(self, viewer, event, data_x, data_y, msg=True):
        
        if not self.canrotate:
            return True
        msg = self.settings.get('msg_rotate', msg)

        x, y = self.get_win_xy(viewer)

        if event.state == 'move':
            self._rotate_xy(viewer, x, y)

        elif event.state == 'down':
            if msg:
                viewer.onscreen_message("Rotate (drag around center)",
                                        delay=1.0)
            self._start_x, self._start_y = x, y
            self._start_rot = viewer.get_rotation()

        else:
            viewer.onscreen_message(None)
        return True
602717
function calculateMirrorOffset({sensorEvent, sourceRect, options, ...args}) {
  return withPromise((resolve) => {
    const top = options.cursorOffsetY === null ? sensorEvent.clientY - sourceRect.top : options.cursorOffsetY;
    const left = options.cursorOffsetX === null ? sensorEvent.clientX - sourceRect.left : options.cursorOffsetX;

    const mirrorOffset = {top, left};

    resolve({sensorEvent, sourceRect, mirrorOffset, options, ...args});
  });
}
619022
function getBarrelCurveConstants(width, height) {
  return {
    heightOffset: Math.min(15, 0.05 * height),
    widthOffset: Math.min(100, 0.25 * width),
    ctrlPtOffsetPct: 0.05
  };
}
1344439
def _update_camera_pos(self):
        

        # transform will be updated several times; do not update camera
        # transform until we are done.
        ch_em = self.events.transform_change
        with ch_em.blocker(self._update_transform):
            tr = self.transform
            tr.reset()

            up, forward, right = self._get_dim_vectors()

            # Create mapping so correct dim is up
            pp1 = np.array([(0, 0, 0), (0, 0, -1), (1, 0, 0), (0, 1, 0)])
            pp2 = np.array([(0, 0, 0), forward, right, up])
            tr.set_mapping(pp1, pp2)

            tr.translate(-self._actual_distance * forward)
            self._rotate_tr()
            tr.scale([1.0/a for a in self._flip_factors])
            tr.translate(np.array(self.center))
656182
def mouse_rotate(self, dx, dy):
        '''

        '''
        fact = 1.5
        self.orbit_y(-dx*fact)
        self.orbit_x(dy*fact)
1210074
function updateMetrics() {
		var dprM;

		isVwDirty = false;
		DPR = window.devicePixelRatio;
		cssCache = {};
		sizeLengthCache = {};

		dprM = (DPR || 1) * cfg.xQuant;

		if(!cfg.uT){
			cfg.maxX = Math.max(1.3, cfg.maxX);
			dprM = Math.min( dprM, cfg.maxX );

			ri.DPR = dprM;
		}

		units.width = Math.max(window.innerWidth || 0, docElem.clientWidth);
		units.height = Math.max(window.innerHeight || 0, docElem.clientHeight);

		units.vw = units.width / 100;
		units.vh = units.height / 100;

		units.em = ri.getEmValue();
		units.rem = units.em;

		lazyFactor = cfg.lazyFactor / 2;

		lazyFactor = (lazyFactor * dprM) + lazyFactor;

		substractCurRes = 0.4 + (0.1 * dprM);

		lowTreshHold = 0.5 + (0.2 * dprM);

		partialLowTreshHold = 0.5 + (0.25 * dprM);

		tMemory = dprM + 1.3;

		if(!(isLandscape = units.width > units.height)){
			lazyFactor *= 0.9;
		}
		if(supportAbort){
			lazyFactor *= 0.9;
		}

		evalID = [units.width, units.height, dprM].join('-');
	}
263813
function (frameTime) {
        var target = this.target;

        var position = this.target.position;
        var xAxis = target.localTransform.x.normalize();
        var zAxis = target.localTransform.z.normalize();

        if (this.verticalMoveLock) {
            zAxis.y = 0;
            zAxis.normalize();
        }

        var speed = this.speed * frameTime / 20;

        if (this._moveForward) {
            // Opposite direction of z
            position.scaleAndAdd(zAxis, -speed);
        }
        if (this._moveBackward) {
            position.scaleAndAdd(zAxis, speed);
        }
        if (this._moveLeft) {
            position.scaleAndAdd(xAxis, -speed / 2);
        }
        if (this._moveRight) {
            position.scaleAndAdd(xAxis, speed / 2);
        }

        target.rotateAround(target.position, this.up, -this._offsetPitch * frameTime * Math.PI / 360);
        var xAxis = target.localTransform.x;
        target.rotateAround(target.position, xAxis, -this._offsetRoll * frameTime * Math.PI / 360);

        this._offsetRoll = this._offsetPitch = 0;
    }
960623
function (deltaTime) {

        deltaTime = deltaTime || 16;

        if (this._rotating) {
            var radian = (this.autoRotateDirection === 'cw' ? 1 : -1)
                * this.autoRotateSpeed / 180 * Math.PI;
            this._phi -= radian * deltaTime / 1000;
            this._needsUpdate = true;
        }
        else if (this._rotateVelocity.len() > 0) {
            this._needsUpdate = true;
        }

        if (Math.abs(this._zoomSpeed) > 0.01 || this._panVelocity.len() > 0) {
            this._needsUpdate = true;
        }

        if (!this._needsUpdate) {
            return;
        }

        // Fixed deltaTime
        this._updateDistanceOrSize(Math.min(deltaTime, 50));
        this._updatePan(Math.min(deltaTime, 50));

        this._updateRotate(Math.min(deltaTime, 50));

        this._updateTransform();

        this.target.update();

        this.trigger('update');

        this._needsUpdate = false;
    }
421847
function(ms) {
    var axes = this._cam.mainAxes();
    var intervals = [ new utils.Range(), new utils.Range(), new utils.Range() ];
    this.forEach(function(obj) {
      if (!obj.visible()) {
        return;
      }
      obj.updateProjectionIntervals(axes[0], axes[1], axes[2], intervals[0],
                                    intervals[1], intervals[2]);
    });
    this._fitToIntervals(axes, intervals, ms);
  }
510004
function (event) {
    var direction;
    var movementX;
    var movementY;
    var pitchObject = this.pitchObject;
    var previousMouseEvent = this.previousMouseEvent;
    var yawObject = this.yawObject;

    // Not dragging or not enabled.
    if (!this.data.enabled || (!this.mouseDown && !this.pointerLocked)) { return; }

    // Calculate delta.
    if (this.pointerLocked) {
      movementX = event.movementX || event.mozMovementX || 0;
      movementY = event.movementY || event.mozMovementY || 0;
    } else {
      movementX = event.screenX - previousMouseEvent.screenX;
      movementY = event.screenY - previousMouseEvent.screenY;
    }
    this.previousMouseEvent = event;

    // Calculate rotation.
    direction = this.data.reverseMouseDrag ? 1 : -1;
    yawObject.rotation.y += movementX * 0.002 * direction;
    pitchObject.rotation.x += movementY * 0.002 * direction;
    pitchObject.rotation.x = Math.max(-PI_2, Math.min(PI_2, pitchObject.rotation.x));
  }
978511
def on_press(self, window, key, scancode, action, mods):
        

        # controls for moving position
        if key == glfw.KEY_W:
            self.pos[0] -= self._pos_step  # dec x
        elif key == glfw.KEY_S:
            self.pos[0] += self._pos_step  # inc x
        elif key == glfw.KEY_A:
            self.pos[1] -= self._pos_step  # dec y
        elif key == glfw.KEY_D:
            self.pos[1] += self._pos_step  # inc y
        elif key == glfw.KEY_F:
            self.pos[2] -= self._pos_step  # dec z
        elif key == glfw.KEY_R:
            self.pos[2] += self._pos_step  # inc z

        # controls for moving orientation
        elif key == glfw.KEY_Z:
            drot = rotation_matrix(angle=0.1, direction=[1., 0., 0.])[:3, :3]
            self.rotation = self.rotation.dot(drot)  # rotates x
        elif key == glfw.KEY_X:
            drot = rotation_matrix(angle=-0.1, direction=[1., 0., 0.])[:3, :3]
            self.rotation = self.rotation.dot(drot)  # rotates x
        elif key == glfw.KEY_T:
            drot = rotation_matrix(angle=0.1, direction=[0., 1., 0.])[:3, :3]
            self.rotation = self.rotation.dot(drot)  # rotates y
        elif key == glfw.KEY_G:
            drot = rotation_matrix(angle=-0.1, direction=[0., 1., 0.])[:3, :3]
            self.rotation = self.rotation.dot(drot)  # rotates y
        elif key == glfw.KEY_C:
            drot = rotation_matrix(angle=0.1, direction=[0., 0., 1.])[:3, :3]
            self.rotation = self.rotation.dot(drot)  # rotates z
        elif key == glfw.KEY_V:
            drot = rotation_matrix(angle=-0.1, direction=[0., 0., 1.])[:3, :3]
            self.rotation = self.rotation.dot(drot)
827385
def __execute_rot(self, surface):
        """"""
        self.image = pygame.transform.rotate(surface, self.__rotation)
        self.__resize_surface_extents()
939289
function rotatePixels(buffer, width, height, degrees) {
  let loops = degrees / 90
  while (loops > 0) {
    const newBuffer = Buffer.alloc(buffer.length)
    let newOffset = 0
    for (let x = 0; x < width; x += 1) {
      for (let y = height - 1; y >= 0; y -= 1) {
        const offset = (width * y + x) << 2
        const pixel = buffer.readUInt32BE(offset, true)
        newBuffer.writeUInt32BE(pixel, newOffset, true)
        newOffset += 4
      }
    }
    buffer = newBuffer
    const newHeight = width
    width = height
    height = newHeight
    loops -= 1
  }
  return buffer
}