Handle scaling and rotation of the surface
7160
def __handle_scale_rot(self):
        """"""
        if self.__is_rot_pending:
            self.__execute_rot(self.untransformed_image)
            self.__is_rot_pending = False

            # Scale the image using the recently rotated surface to keep the orientation correct
            self.__execute_scale(self.image, self.image.get_size())
            self.__is_scale_pending = False

        # The image is not rotating while scaling, thus use the untransformed image to scale.
        if self.__is_scale_pending:
            self.__execute_scale(self.untransformed_image, self.untransformed_image.get_size())
            self.__is_scale_pending = False
1325182
def _scale_tile(self, value, width, height):
        """"""
        try:
            return self._scale_cache[value, width, height]
        except KeyError:
            tile = pygame.transform.smoothscale(self.tiles[value], (width, height))
            self._scale_cache[value, width, height] = tile
            return tile
1181003
function() {
        var layer = this.layer;
        for(var i=0; i<8; ++i) {
            if(this.rotate && i % 2 === 0) {
                layer.drawFeature(this.rotationHandles[i/2],
                    this.rotationHandleSymbolizer);
            }
            layer.drawFeature(this.handles[i], this.renderIntent);
        }
    }
160085
function () {
        var is = this.inScene,
            os = this.outScene

        /* clean up */
        is.visible = true
        is.position = geo.PointZero()
        is.scale = 1.0
        is.rotation = 0

        os.visible = false
        os.position = geo.PointZero()
        os.scale = 1.0
        os.rotation = 0

        Scheduler.sharedScheduler.schedule({
            target: this,
            method: this.setNewScene,
            interval: 0
        })
    }
626275
def roundrect(surface, rect, color, rounding=5, unit=PIXEL):
    

    if unit == PERCENT:
        rounding = int(min(rect.size) / 2 * rounding / 100)

    rect = pygame.Rect(rect)
    color = pygame.Color(*color)
    alpha = color.a
    color.a = 0
    pos = rect.topleft
    rect.topleft = 0, 0
    rectangle = pygame.Surface(rect.size, SRCALPHA)

    circle = pygame.Surface([min(rect.size) * 3] * 2, SRCALPHA)
    pygame.draw.ellipse(circle, (0, 0, 0), circle.get_rect(), 0)
    circle = pygame.transform.smoothscale(circle, (rounding, rounding))

    rounding = rectangle.blit(circle, (0, 0))
    rounding.bottomright = rect.bottomright
    rectangle.blit(circle, rounding)
    rounding.topright = rect.topright
    rectangle.blit(circle, rounding)
    rounding.bottomleft = rect.bottomleft
    rectangle.blit(circle, rounding)

    rectangle.fill((0, 0, 0), rect.inflate(-rounding.w, 0))
    rectangle.fill((0, 0, 0), rect.inflate(0, -rounding.h))

    rectangle.fill(color, special_flags=BLEND_RGBA_MAX)
    rectangle.fill((255, 255, 255, alpha), special_flags=BLEND_RGBA_MIN)

    return surface.blit(rectangle, pos)
652152
function(use3d) {
      var re = [];

      for (var i in this) {
        if (this.hasOwnProperty(i)) {
          // Don't use 3D transformations if the browser can't support it.
          if ((!support.transform3d) && (
            (i === 'rotateX') ||
            (i === 'rotateY') ||
            (i === 'perspective') ||
            (i === 'transformOrigin'))) { continue; }

          if (i[0] !== '_') {
            if (use3d && (i === 'scale')) {
              re.push(i + "3d(" + this[i] + ",1)");
            } else if (use3d && (i === 'translate')) {
              re.push(i + "3d(" + this[i] + ",0)");
            } else {
              re.push(i + "(" + this[i] + ")");
            }
          }
        }
      }

      return re.join(" ");
    }
744904
function handleScreenOrientationChange () {

	if ( hasScreenOrientationAPI ) {

		screenOrientationAngle = ( window.screen.orientation.angle || 0 ) * degToRad;

	} else {

		screenOrientationAngle = ( window.orientation || 0 ) * degToRad;

	}

}
374404
function reshape(gl, width, height)
{
   var h = height / width;
   gl.Viewport(0, 0, width, height);
   gl.MatrixMode(gl.PROJECTION);
   gl.LoadIdentity();
   gl.Frustum(-1.0, 1.0, -h, h, 5.0, 60.0);
   gl.MatrixMode(gl.MODELVIEW);
   gl.LoadIdentity();
   gl.Translatef(0.0, 0.0, -40.0);
   gl.Scalef(0.1, 0.1, 0.1);
   gl.render();
}
845463
def scale2x(self, surface):
        
        assert(self._scale == 2)
        return self._pygame.transform.scale2x(surface)
327588
def do_rotation(self, mirror, rot):
        """"""
        if (not mirror and rot == 0.0):
            self.logger.debug("rotation: no rotation (nop)")
        else:
            # FIXME - with PIL one can use the transpose() method to do 90deg
            # FIXME - rotations as well as mirroring. This would be more efficient
            # FIXME - for these cases than mirror _then_ rotate.
            if (mirror):
                self.logger.debug("rotation: mirror (about vertical axis)")
                self.image = self.image.transpose(Image.FLIP_LEFT_RIGHT)
            if (rot != 0.0):
                self.logger.debug("rotation: by %f degrees clockwise" % (rot))
                self.image = self.image.rotate(-rot, expand=True)
1062500
private long rotateMapWidth(long width, long height) {
    if (rotation != null && (rotation == ROTATE_90 || rotation == ROTATE_270)) {
      return height;
    }
    else {
      return width;
    }
  }
478373
private void ScaleControl(GVRSceneObject gvrWebViewSceneObjectFinal, GVRSceneObject  gvrSceneObjectAnchorFinal, String urlFinal) {
        GVRScene mainScene = gvrContext.getMainScene();
        GVRCameraRig gvrCameraRig = mainScene.getMainCameraRig();
        initialCameralookAt = gvrCameraRig.getLookAt();

        gvrWebViewSceneObjectFinal.getTransform().getModelMatrix4f().getTranslation(translationObjectTranslationGlobal);
        gvrWebViewSceneObjectFinal.getTransform().getLocalModelMatrix4f().getTranslation(translationObjectTranslationLocal);

        if (gvrTextScaleObject != null) {
            gvrTextScaleObject.setTextColor(textColorIsActive);
        }
        webViewScale = true;

        for (int i = 0; i < 3; i++ ) {
            initialHitPoint[i] = (initialCameralookAt[i] * translationObjectTranslationGlobal.z) / initialCameralookAt[2];
        }
        beginWebPagePlusUIScale[0] = webPagePlusUIScale[0];
        beginWebPagePlusUIScale[1] = webPagePlusUIScale[1];

        mOnDrawFrame = new DrawFrame();
        gvrContext.registerDrawFrameListener(mOnDrawFrame);
    }
349565
def on_resize(self, event):
        
        if self._aspect is None:
            return
        w, h = self._canvas.size
        aspect = self._aspect / (w / h)
        self.scale = (self.scale[0], self.scale[0] / aspect)
        self.shader_map()
1246027
function () {
        var localTransform = this.localTransform.array;
        var worldTransform = this.worldTransform.array;
        if (this._parent) {
            mat4.multiplyAffine(
                worldTransform,
                this._parent.worldTransform.array,
                localTransform
            );
        }
        else {
            mat4.copy(worldTransform, localTransform);
        }
    }
1059339
function() {
        var geom;
        for(var i=0; i<8; ++i) {
            geom = this.box.geometry.components[i];
            geom._handle.destroy();
            geom._handle = null;
            geom._rotationHandle && geom._rotationHandle.destroy();
            geom._rotationHandle = null;
        }
        this.center = null;
        this.feature = null;
        this.handles = null;
        this.rotationHandleSymbolizer = null;
        this.rotationHandles = null;
        this.box.destroy();
        this.box = null;
        this.layer = null;
        this.dragControl.destroy();
        this.dragControl = null;
        OpenLayers.Control.prototype.destroy.apply(this, arguments);
    }
216361
function _rotateToOrientaion(width, height, orientation) {
			switch (orientation) {
				case 5:
				case 6:
				case 7:
				case 8:
					_canvas.width = height;
					_canvas.height = width;
					break;
				default:
					_canvas.width = width;
					_canvas.height = height;
			}

			/**
			1 = The 0th row is at the visual top of the image, and the 0th column is the visual left-hand side.
			2 = The 0th row is at the visual top of the image, and the 0th column is the visual right-hand side.
			3 = The 0th row is at the visual bottom of the image, and the 0th column is the visual right-hand side.
			4 = The 0th row is at the visual bottom of the image, and the 0th column is the visual left-hand side.
			5 = The 0th row is the visual left-hand side of the image, and the 0th column is the visual top.
			6 = The 0th row is the visual right-hand side of the image, and the 0th column is the visual top.
			7 = The 0th row is the visual right-hand side of the image, and the 0th column is the visual bottom.
			8 = The 0th row is the visual left-hand side of the image, and the 0th column is the visual bottom.
			*/

			var ctx = _canvas.getContext('2d');
			switch (orientation) {
				case 2:
					// horizontal flip
					ctx.translate(width, 0);
					ctx.scale(-1, 1);
					break;
				case 3:
					// 180 rotate left
					ctx.translate(width, height);
					ctx.rotate(Math.PI);
					break;
				case 4:
					// vertical flip
					ctx.translate(0, height);
					ctx.scale(1, -1);
					break;
				case 5:
					// vertical flip + 90 rotate right
					ctx.rotate(0.5 * Math.PI);
					ctx.scale(1, -1);
					break;
				case 6:
					// 90 rotate right
					ctx.rotate(0.5 * Math.PI);
					ctx.translate(0, -height);
					break;
				case 7:
					// horizontal flip + 90 rotate right
					ctx.rotate(0.5 * Math.PI);
					ctx.translate(width, -height);
					ctx.scale(-1, 1);
					break;
				case 8:
					// 90 rotate left
					ctx.rotate(-0.5 * Math.PI);
					ctx.translate(-width, 0);
					break;
			}
		}
401879
def scale_to(self, width_height=Vector2()):
        """"""
        scale_amt = Vector2()
        scale_amt.X = float(width_height.X) / self.image.get_width()
        scale_amt.Y = float(width_height.Y) / self.image.get_height()
        self.set_scale(scale_amt)