Rotate() публичный Метод

public Rotate ( double radians ) : void
radians double
Результат void
Пример #1
0
        public static Matrix GetTransform(this Node node)
        {
            double anchorX = node.AnchorX * node.Width;
            double anchorY = node.AnchorY * node.Height;

            Matrix transform = new Matrix ();
            transform.Translate (node.X + anchorX, node.Y + anchorY);
            transform.Rotate (node.Rotation);
            transform.Scale (node.Scale, node.Scale);
            transform.Translate (-anchorX, -anchorY);

            return transform;
        }
Пример #2
0
        //
        // this functions calculates the transformation needed to center and completely fill the
        // viewport with the Surface at the given tilt
        //
        public Matrix Fill(Gdk.Rectangle viewport, double tilt)
        {
            if (tilt == 0.0)
                return Fill (viewport);

            Matrix m = new Matrix ();
            m.InitIdentity ();

            double len;
            double orig_len;
            if (Bounds.Width > Bounds.Height) {
                len = viewport.Height;
                orig_len = Bounds.Height;
            } else {
                len = viewport.Width;
                orig_len = Bounds.Width;
            }

            double a = Math.Sqrt (viewport.Width * viewport.Width + viewport.Height * viewport.Height);
            double alpha = Math.Acos (len / a);
            double theta = alpha - Math.Abs (tilt);

            double slen = a * Math.Cos (theta);

            double scale = slen / orig_len;

            double x_offset = (viewport.Width  - Bounds.Width * scale) / 2.0;
            double y_offset = (viewport.Height  - Bounds.Height * scale) / 2.0;

            m.Translate (x_offset, y_offset);
            m.Scale (scale, scale);
            m.Invert ();
            m.Translate (viewport.Width * 0.5, viewport.Height * 0.5);
            m.Rotate (tilt);
            m.Translate (viewport.Width * -0.5, viewport.Height * -0.5);
            m.Invert ();
            return m;
        }
Пример #3
0
        public void Rotate (double angle, Size new_size)
        {
			double radians = (angle / 180d) * Math.PI;
		    var old_size = PintaCore.Workspace.ImageSize;

            var xform = new Matrix ();
            xform.Translate (new_size.Width / 2.0, new_size.Height / 2.0);
            xform.Rotate (radians);
            xform.Translate (-old_size.Width / 2.0, -old_size.Height / 2.0);

            ApplyTransform (xform, new_size);
        }
Пример #4
0
	    private static Matrix ComputeMatrix (RotateZoomData data)
	    {
	        var xform = new Matrix ();
	        var image_size = PintaCore.Workspace.ImageSize;
            var center_x = image_size.Width / 2.0;
            var center_y = image_size.Height / 2.0;

            xform.Translate ((1 + data.Pan.X) * center_x, (1 + data.Pan.Y) * center_y);
            xform.Rotate ((-data.Angle / 180d) * Math.PI);
            xform.Scale (data.Zoom, data.Zoom);
	        xform.Translate (-center_x, -center_y);

	        return xform;
	    }