当前位置: 首页>>代码示例>>C#>>正文


C# Matrix.RotateAt方法代码示例

本文整理汇总了C#中System.Drawing.Drawing2D.Matrix.RotateAt方法的典型用法代码示例。如果您正苦于以下问题:C# Matrix.RotateAt方法的具体用法?C# Matrix.RotateAt怎么用?C# Matrix.RotateAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Drawing.Drawing2D.Matrix的用法示例。


在下文中一共展示了Matrix.RotateAt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetMatrix

		static public Matrix GetMatrix (int index)
		{
			// not defined (-1) or first (0)
			if (index <= 0)
				return null;

			Matrix m = new Matrix ();
			switch (index) {
			case 1:
				// empty
				break;
			case 2:
				m.Rotate (15);
				break;
			case 3:
				m.RotateAt (45, new PointF (100, 100));
				break;
			case 4:
				m.Scale (1.5f, 0.5f);
				break;
			case 5:
				m.Shear (2.0f, 2.0f);
				break;
			case 6:
				m.Translate (50, 50);
				break;
			}
			return m;
		}
开发者ID:nlhepler,项目名称:mono,代码行数:29,代码来源:Matrices.cs

示例2: Draw

        /// <summary>
        /// Draw Function.</summary>
        /// <param name="g">Graphics for Drawing</param>
        public void Draw(Graphics g, float rollAngle, float pitchAngle)
        {
            Matrix transformMatrix = new Matrix();
            transformMatrix.RotateAt(rollAngle, center);
            transformMatrix.Translate(0, pitchAngle * pixelPerDegree);

            // Previous major graduation value next to currentValue.
            int majorGraduationValue = ((int)(pitchAngle / 10) * 10);

            for (int degree = majorGraduationValue - 20; degree <= majorGraduationValue + 20; degree += 5)
            {
                if (degree == 0)
                    continue;

                int width = degree % 10 == 0 ? 60 : 30;

                GraphicsPath skyPath = new GraphicsPath();

                skyPath.AddLine(center.X - width, center.Y - degree * pixelPerDegree, center.X + width, center.Y - degree * pixelPerDegree);
                skyPath.Transform(transformMatrix);
                g.DrawPath(drawingPen, skyPath);

                //g.DrawString(degree.ToString(), SystemFonts.DefaultFont, Brushes.White, center.X - width - 15, center.Y - degree * 10);
            }
        }
开发者ID:shujaatak,项目名称:PrimaryFlightDisplay,代码行数:28,代码来源:PitchGrid.cs

示例3: OnPaint

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            Graphics myGraphics = e.Graphics;
            Pen myPen = new Pen(Color.Black, 1.0f);
            GraphicsPath gp = new GraphicsPath();
            Matrix RotationTransform;

            float centerX = this.Size.Width / 2f;
            float centerY = this.Size.Height / 2f;

            gp.AddPolygon(new PointF[] {
                new PointF(centerX, centerY - 5),
                new PointF(centerX-5, centerY + 5),
                new PointF(centerX+5, centerY + 5)
            });

            RotationTransform = new Matrix(1, 0, 0, 1, 0, 0); // rotation matrix
            PointF RotationPoint = new PointF(centerX, centerY); // rotation point
            RotationTransform.RotateAt(heading, RotationPoint);
            gp.Transform(RotationTransform);

            myGraphics.FillPath(myPen.Brush, gp);
            myGraphics.DrawPath(myPen, gp);
            myPen.Dispose();
            gp.Dispose();
        }
开发者ID:glocklueng,项目名称:helocamosun,代码行数:27,代码来源:HelicopterIcon.cs

示例4: Generate

        public static byte[] Generate()
        {
            string captchaString = random.Next(1000, 9999).ToString();
            HttpContext.Current.Session["captcha"] = captchaString;

            Bitmap image = new Bitmap(width, height);
            Graphics graphics = Graphics.FromImage(image);
            graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
            Matrix matrix = new Matrix();

            for (int i = 0; i < captchaLength; i++)
            {
                matrix.Reset();
                int x = (width / captchaLength) * i;
                int y = height / 2;
                matrix.RotateAt(random.Next(-40, 40), new PointF(x, y));
                graphics.Transform = matrix;
                graphics.DrawString(captchaString[i].ToString(),
                    new Font(FontFamily.GenericSerif, random.Next(25, 40)),
                    new SolidBrush(Color.FromArgb(random.Next(100), random.Next(100), random.Next(100))),
                    x, random.Next(5, 10));
            }

            MemoryStream ms = new MemoryStream();
            image.Save(ms, ImageFormat.Png);

            return ms.GetBuffer();
        }
开发者ID:Dragsaw,项目名称:BreadPunter,代码行数:28,代码来源:Captcha.cs

示例5: InitializeMap

        public static Map InitializeMap(float angle)
        {
            string wmsUrl = "http://dev:8080/geoserver/ows?service=wms&version=1.1.1&request=GetCapabilities";

            Map map = new Map();

            WmsLayer layWms = new WmsLayer("Demis Map", wmsUrl);

            layWms.AddLayer("sf:roads");
            //layWms.AddLayer("Topography");
            //layWms.AddLayer("Hillshading");

            layWms.SetImageFormat(layWms.OutputFormats[0]);
            layWms.ContinueOnError = true;
                //Skip rendering the WMS Map if the server couldn't be requested (if set to false such an event would crash the app)
            layWms.TimeOut = 5000; //Set timeout to 5 seconds
            layWms.SRID = 4326;
            map.Layers.Add(layWms);

            //limit the zoom to 360 degrees width
            map.MaximumZoom = 360;
            map.BackColor = Color.LightBlue;

            map.Zoom = 360;
            map.Center = new Point(0, 0);

            Matrix mat = new Matrix();
            mat.RotateAt(angle, map.WorldToImage(map.Center));
            map.MapTransform = mat;

            map.ZoomToExtents();
            return map;
        }
开发者ID:PedroMaitan,项目名称:sharpmap,代码行数:33,代码来源:WmsSample.cs

示例6: RotateImage

 public static Bitmap RotateImage(Image inputImg, double degreeAngle)
 {
     PointF[] pointF = new PointF[] { new PointF(0f, 0f), new PointF((float)inputImg.Width, 0f), new PointF(0f, (float)inputImg.Height), new PointF((float)inputImg.Width, (float)inputImg.Height) };
     PointF[] rotationPoints = pointF;
     PointMath.RotatePoints(rotationPoints, new PointF((float)inputImg.Width / 2f, (float)inputImg.Height / 2f), degreeAngle);
     Rectangle bounds = PointMath.GetBounds(rotationPoints);
     Bitmap rotatedBitmap = new Bitmap(bounds.Width, bounds.Height);
     Graphics g = Graphics.FromImage(rotatedBitmap);
     try
     {
         g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
         g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
         Matrix m = new Matrix();
         m.RotateAt((float)degreeAngle, new PointF((float)inputImg.Width / 2f, (float)inputImg.Height / 2f));
         m.Translate((float)(-bounds.Left), (float)(-bounds.Top), MatrixOrder.Append);
         g.Transform = m;
         g.DrawImage(inputImg, 0, 0);
     }
     finally
     {
         if (g != null)
         {
             ((IDisposable)g).Dispose();
         }
     }
     return rotatedBitmap;
 }
开发者ID:rlugojr,项目名称:Alferd-Spritesheet-Unpacker,代码行数:27,代码来源:Rotate.cs

示例7: InitializeDXF

        private static Map InitializeDXF(float angle)
        {
            Map map = new Map();
            //Set the datasource to a shapefile in the App_data folder
            Ogr provider;
            try
            {
                provider = new Ogr("GeoData/SampleDXF.dxf",0);
            }
            catch (TypeInitializationException ex)
            {
                if (ex.Message == "The type initializer for 'OSGeo.OGR.Ogr' threw an exception.")
                {
                    throw new Exception(
                        String.Format(
                            "The application threw a PINVOKE exception. You probably need to copy the unmanaged dll's to your bin directory. They are a part of fwtools {0}. You can download it from: http://home.gdal.org/fwtools/",
                            GdalRasterLayer.FWToolsVersion));
                }
                throw;
            }
            VectorLayer lay = new VectorLayer("SampleDXF", provider);
            map.Layers.Add(lay);
            map.ZoomToExtents();
            Matrix mat = new Matrix();
            mat.RotateAt(angle, map.WorldToImage(map.Center));
            map.MapTransform = mat;

            _ogrSampleDataset = "SampleDXF";
            return map;

        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:31,代码来源:OgrSample.cs

示例8: mRotateImage

        public static Image mRotateImage(Image inputImg, double degreeAngle)
        {
            //ъглите на image
            PointF[] rotationPoints = { new PointF(0, 0),
                                        new PointF(inputImg.Width, 0),
                                        new PointF(0, inputImg.Height),
                                        new PointF(inputImg.Width, inputImg.Height)};

            //роатция на ъглите
            PointMath.RotatePoints(rotationPoints, new PointF(inputImg.Width / 2.0f, inputImg.Height / 2.0f), degreeAngle);

            //Получаваме новите стойности след ротацията на ъглите

            Rectangle bounds = PointMath.GetBounds(rotationPoints);

            //Празен bitmap за получения завъртян образ
            Bitmap rotatedBitmap = new Bitmap(bounds.Width, bounds.Height);

            using (Graphics g = Graphics.FromImage(rotatedBitmap))
            {
                //Transformation matrix
                Matrix m = new Matrix();
                m.RotateAt((float)degreeAngle, new PointF(inputImg.Width / 2.0f, inputImg.Height / 2.0f));

                g.Transform = m;
                g.DrawImage(inputImg, 0, 0);
            }
            return (Image)rotatedBitmap;
        }
开发者ID:bambucha,项目名称:TheGame,代码行数:29,代码来源:uStaticClasses.cs

示例9: Rotate

 public virtual void Rotate(float angle, PointF center)
 {
     Matrix tempMatrix = new Matrix();
     tempMatrix.RotateAt(angle, center);
     tempMatrix.Multiply(TransformationMatrix);
     TransformationMatrix = tempMatrix;
 }
开发者ID:ferry2,项目名称:2D-Vector-Graphics,代码行数:7,代码来源:MatrixHandler.cs

示例10: RotateImage

        public static Bitmap RotateImage(Image img, float theta)
        {
            Matrix matrix = new Matrix();
            matrix.Translate(img.Width / -2, img.Height / -2, MatrixOrder.Append);
            matrix.RotateAt(theta, new Point(0, 0), MatrixOrder.Append);
            using (GraphicsPath gp = new GraphicsPath())
            {
                gp.AddPolygon(new Point[] { new Point(0, 0), new Point(img.Width, 0), new Point(0, img.Height) });
                gp.Transform(matrix);
                PointF[] pts = gp.PathPoints;

                Rectangle bbox = BoundingBox(img, matrix);
                Bitmap bmpDest = new Bitmap(bbox.Width, bbox.Height);

                using (Graphics gDest = Graphics.FromImage(bmpDest))
                {
                    Matrix mDest = new Matrix();
                    mDest.Translate(bmpDest.Width / 2, bmpDest.Height / 2, MatrixOrder.Append);
                    gDest.Transform = mDest;
                    gDest.CompositingQuality = CompositingQuality.HighQuality;
                    gDest.InterpolationMode = InterpolationMode.HighQualityBicubic;
                    gDest.DrawImage(img, pts);
                    return bmpDest;
                }
            }
        }
开发者ID:dmitriydel,项目名称:sharexmod,代码行数:26,代码来源:GraphicsHelper.cs

示例11: Draw

		public void Draw(Graphics aGfx, int lX, int lY,bool abBorder,bool abHighLight, int alRotation)
		{
			Matrix Mtx = new Matrix();
			
			float fX = (float)lX;
			float fY = (float)lY;
			
			//Stupid bad fix.
			if(alRotation==1)fY+=0.95f;
			if(alRotation==3)fX+=0.95f;
			PointF vRotPoint = new PointF((float)(lX+mTileImage.Width/2),(float)(lY+mTileImage.Height/2));
			
			Mtx.RotateAt(alRotation*90,vRotPoint, MatrixOrder.Append);
			aGfx.Transform = Mtx;
			
			aGfx.DrawImage(mTileImage,fX,fY,mTileImage.Width,mTileImage.Height);
			
			Mtx.Reset();
			aGfx.Transform = Mtx;
						
			if(abBorder)
			{
				Pen BorderPen; 
				if(abHighLight)BorderPen= new Pen(Color.FromArgb(100,255,100));
				else  BorderPen= new Pen(Color.FromArgb(255,0,255));
				
				if(abHighLight)
					aGfx.DrawRectangle(BorderPen,lX,lY,mTileImage.Width-1, mTileImage.Height-1);
				else
					aGfx.DrawRectangle(BorderPen,lX,lY,mTileImage.Width, mTileImage.Height);

				BorderPen.Dispose();
			}
		}
开发者ID:whztt07,项目名称:HPL1Engine,代码行数:34,代码来源:cTileData.cs

示例12: Draw

        public override void Draw(CGRect rect)
        {
            Graphics g = Graphics.FromCurrentContext ();
            int offset = 20;

            // Scale:
            var m = new Matrix(1, 2, 3, 4, 0, 1);
            g.DrawString ("Original Matrix:", Font, Brushes.Black, 10, 10);
            DrawMatrix (m, g, 10, 10 + offset);
            g.DrawString ("Scale - Prepend:", Font, Brushes.Black, 10, 10 + 2 * offset);
            m.Scale (1, 0.5f, MatrixOrder.Prepend);
            DrawMatrix (m, g, 10, 10 + 3 * offset);
            g.DrawString ("Scale - Append:", Font, Brushes.Black, 10, 10 + 4 * offset);
            m = new Matrix (1, 2, 3, 4, 0, 1);
            m.Scale (1, 0.5f, MatrixOrder.Append);
            DrawMatrix (m, g, 10, 10 + 5 * offset);

            // Translation:
            m = new Matrix (1, 2, 3, 4, 0, 1);
            g.DrawString ("Translation - Prepend:", Font, Brushes.Black, 10, 10 + 6 * offset);
            m.Translate (1, 0.5f, MatrixOrder.Prepend);
            DrawMatrix (m, g, 10, 10 + 7 * offset);
            g.DrawString ("Translation - Append:", Font, Brushes.Black, 10, 10 + 8 * offset);
            // Reset m to the original matrix:
            m = new Matrix(1, 2, 3, 4, 0, 1);
            m.Translate (1, 0.5f, MatrixOrder.Append);
            DrawMatrix (m, g, 10, 10 + 9 * offset);

            m = new Matrix (1, 2, 3, 4, 0, 1);
            g.DrawString ("Rotation - Prepend:", Font, Brushes.Black, 10, 10 + 10 * offset);
            m.Rotate (45, MatrixOrder.Prepend);
            DrawMatrix (m, g, 10, 10 + 11 * offset);
            g.DrawString ("Rotation - Append:", Font, Brushes.Black, 10, 10 + 12 * offset);
            // Reset m to the original matrix:
            m = new Matrix (1, 2, 3, 4, 0, 1);
            m.Rotate (45, MatrixOrder.Append);
            DrawMatrix (m, g, 10, 10 + 13 * offset);

            // Rotation at (x = 1, y = 2):
            m = new Matrix (1, 2, 3, 4, 0, 1);
            g.DrawString ("Rotation At - Prepend:", Font, Brushes.Black, 10, 10 + 14 * offset);
            m.RotateAt (45, new Point (1, 2), MatrixOrder.Prepend);
            DrawMatrix (m, g, 10, 10 + 15 * offset);
            g.DrawString ("Rotation At - Append:", Font, Brushes.Black, 10, 10 + 16 * offset);
            m = new Matrix (1, 2, 3, 4, 0, 1);
            m.RotateAt (45, new Point (1, 2), MatrixOrder.Append);
            DrawMatrix(m, g, 10, 10 + 17 * offset);

            // Shear:
            m = new Matrix (1, 2, 3, 4, 0, 1);
            g.DrawString ("Shear - Prepend:", Font, Brushes.Black, 10, 10 + 18 * offset);
            m.Shear (1, 2, MatrixOrder.Prepend);
            DrawMatrix (m, g, 10, 10 + 19 * offset);
            g.DrawString ("Shear - Append:", Font, Brushes.Black, 10, 10 + 20 * offset);
            // Reset m to the original matrix:
            m = new Matrix (1, 2, 3, 4, 0, 1);
            m.Shear (1, 2, MatrixOrder.Append);
            DrawMatrix (m, g, 10, 10 + 21 * offset);
        }
开发者ID:mono,项目名称:sysdrawing-coregraphics,代码行数:59,代码来源:DrawingView.cs

示例13: Rotate

 /// <summary>
 /// Rotate figure.
 /// </summary>
 public void Rotate(float angle)
 {
     Clear();
     Matrix matrix = new Matrix();
     matrix.RotateAt(angle, Center);
     graphics.Transform = matrix;
     Draw();
 }
开发者ID:oleksandrkin,项目名称:graphics,代码行数:11,代码来源:Figure.cs

示例14: UpdatePath

        protected override void UpdatePath()
        {
            InternalPath = new GraphicsPath();
            InternalPath.AddPie(this.Left, this.Top, this.Width, this.Height, this.StartAngle, this.SweepAngle);

            Matrix mtx = new Matrix();
            mtx.RotateAt(this.Rotation, InternalRotationBasePoint);
            InternalPath.Transform(mtx);
        }
开发者ID:westybsa,项目名称:MP.LSharp,代码行数:9,代码来源:ShapePie.cs

示例15: Rotate

		public void Rotate(float degrees)
		{
			Matrix translateMatrix = new Matrix();
			RectangleF rectF = mPath.GetBounds();
			
			translateMatrix.RotateAt(degrees, new PointF(rectF.Width / 2, rectF.Height /2));
			mPath.Transform(translateMatrix);
			translateMatrix.Dispose();
		}
开发者ID:savagemat,项目名称:arcgis-diagrammer,代码行数:9,代码来源:Definition.cs


注:本文中的System.Drawing.Drawing2D.Matrix.RotateAt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。