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


C# Drawing2D.Matrix类代码示例

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


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

示例1: Marker

 // Methods
 internal Marker(string prefix, string localname, string ns, SvgDocument doc)
     : base(prefix, localname, ns, doc)
 {
     markerTransForm = new Matrix();
     brush = new SolidColor(Color.Black);
     stroke = new Stroke();
 }
开发者ID:EdgarEDT,项目名称:myitoppsp,代码行数:8,代码来源:Marker.cs

示例2: GraphicsContainer

	// Constructor, which saves away all of the important information.
	// We assume that the lock on the "graphics" object is held by the caller.
	internal GraphicsContainer(Graphics graphics)
			{
				// Push this container onto the stack.
				this.graphics = graphics;
				next = graphics.stackTop;
				graphics.stackTop = this;

				// Save the graphics state information.
				clip = graphics.Clip;
				if(clip != null)
				{
					clip = clip.Clone();
				}
				compositingMode = graphics.CompositingMode;
				compositingQuality = graphics.CompositingQuality;
				interpolationMode = graphics.InterpolationMode;
				pageScale = graphics.PageScale;
				pageUnit = graphics.PageUnit;
				pixelOffsetMode = graphics.PixelOffsetMode;
				renderingOrigin = graphics.RenderingOrigin;
				smoothingMode = graphics.SmoothingMode;
				textContrast = graphics.TextContrast;
				textRenderingHint = graphics.TextRenderingHint;
				if (graphics.transform == null)
				{
					transform = null;
				}
				else
				{
					transform = Matrix.Clone(graphics.transform);
				}
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:34,代码来源:GraphicsContainer.cs

示例3: GetEyeOfSightImage

        private static Bitmap GetEyeOfSightImage()
        {
            var roestte = new Bitmap(120, 120);
            
            //Anyone for a more sophisticated roestte?
            using (var g = Graphics.FromImage(roestte))
            {
                var t = new Matrix(1f, 0f, 0f, 1f, 60, 60);
                g.Transform = t;

                var f = new Font("Arial", 20, FontStyle.Bold);
                var b = new SolidBrush(Color.Black);
                var p = new Pen(Color.Black, 5);
                var sf = new StringFormat(StringFormat.GenericTypographic) {Alignment = StringAlignment.Center};
                var rect = new RectangleF(- 45f, - 45f, 90f, 90f);

                foreach (var s in Directions)
                {
                    g.DrawString(s, f, b, 0, -55, sf);
                    g.DrawArc(p, rect, 290f, 50f);
                    g.RotateTransform(90f);
                }
            }
            return roestte;
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:25,代码来源:EyeOfSight.cs

示例4: OnRender

        protected override void OnRender(Graphics g, Map map)
        {
            // Render the rosetta
            base.OnRender(g, map);
            
            var clip = g.ClipBounds;
            var oldTransform = g.Transform;
            var newTransform = new Matrix(1f, 0f, 0f, 1f, clip.Left + Size.Width*0.5f, clip.Top + Size.Height*0.5f);

            g.Transform = newTransform;

            var width = Size.Width;
            var height = Size.Height;
            var pts = new[]
                          {
                              new PointF(0f, -0.35f*height),
                              new PointF(0.125f*width, 0.35f*height),
                              new PointF(0f, 0.275f*height),
                              new PointF(-0.125f*width, 0.35f*height),
                              new PointF(0f, -0.35f*height),
                          };

            // need to outline the needle
            if (NeedleOutlineWidth>0)
            {
                g.DrawPolygon(new Pen(OpacityColor(NeedleOutlineColor), NeedleOutlineWidth), pts);
            }

            // need to outline the needle
            g.FillPolygon(new SolidBrush(OpacityColor(NeedleFillColor)), pts );

            g.Transform = oldTransform;

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

示例5: TankPolygonPoints

        /// <summary>
        /// Returned points 1-4 are the left track, points 5-8 are the right track, 9-16 are the turret
        /// They should be drawn individually
        /// </summary>
        public static PointF[] TankPolygonPoints(int offsetX, int offsetY, float rotDegrees, float size)
        {
            var points = new PointF[16] {
                // Left track
                new PointF(-1, -1),
                new PointF(-1, 1),
                new PointF(-0.5f, 1),
                new PointF(-0.5f, -1),

                // Right track
                new PointF(0.5f, -1),
                new PointF(1, -1),
                new PointF(1, 1),
                new PointF(0.5f, 1),

                // Turret
                new PointF(-0.5f, -0.5f),
                new PointF(0.5f, -0.5f),
                new PointF(-0.5f, 0.5f),
                new PointF(-0.25f, 0.5f),
                new PointF(-0.25f, 1.75f),
                new PointF(0.25f, 1.75f),
                new PointF(0.25f, 0.5f),
                new PointF(0.5f, 0.5f)
            };

            var matrix = new Matrix();
            matrix.Rotate(rotDegrees, MatrixOrder.Append);
            matrix.Translate(offsetX, offsetY, MatrixOrder.Append);
            matrix.Scale(size, size);
            matrix.TransformPoints(points);
            return points;
        }
开发者ID:RogaDanar,项目名称:MineSweeper-Neural-Net,代码行数:37,代码来源:Shapes.cs

示例6: 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

示例7: Draw

        public void Draw(AnimationTrack track, SpriteBatch spBatch)
        {
            System.Drawing.Drawing2D.Matrix worldMatrix = new System.Drawing.Drawing2D.Matrix();
            worldMatrix = track.CachedMatrix;

            // fetch the image out.
            Microsoft.Xna.Framework.Rectangle rect;
            Texture2D texture = GetTexture(track, out rect);

            System.Drawing.Drawing2D.Matrix finalTransform = mViewMatrix.Clone();
            finalTransform.Multiply(worldMatrix);
            float[] gM = finalTransform.Elements;

            Microsoft.Xna.Framework.Matrix xM = new Microsoft.Xna.Framework.Matrix();

            xM.M11 = gM[0];
            xM.M12 = gM[1];
            xM.M21 = gM[2];
            xM.M22 = gM[3];
            xM.M41 = gM[4];
            xM.M42 = gM[5];
            xM.M33 = 1;
            xM.M44 = 1;
            Microsoft.Xna.Framework.Rectangle dRect = new Microsoft.Xna.Framework.Rectangle();
            dRect.X = 100;
            dRect.Y = 100;
            dRect.Width = rect.Width;
            dRect.Height = rect.Height;

            spBatch.Begin(SpriteSortMode.Immediate,BlendState.AlphaBlend,SamplerState.LinearClamp,DepthStencilState.None,RasterizerState.CullCounterClockwise,null,xM);
            spBatch.Draw(texture, dRect, rect, Microsoft.Xna.Framework.Color.White);
            spBatch.End();
        }
开发者ID:gigiwotou,项目名称:GameEdit2,代码行数:33,代码来源:Player.cs

示例8: Draw

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

            // Invert matrix:
            var m = new Matrix (1, 2, 3, 4, 0, 0);
            g.DrawString ("Original Matrix:", Font, Brushes.Black, 10, 10);
            DrawMatrix (m, g, 10, 10 + offset);
            g.DrawString ("Inverted Matrix:", Font, Brushes.Black, 10, 10 + 2 * offset);
            m.Invert ();
            DrawMatrix (m, g, 10, 10 + 3 * offset);

            // Matrix multiplication - MatrixOrder.Append:
            var m1 = new Matrix (1, 2, 3, 4, 0, 1);
            var m2 = new Matrix (0, 1, 2, 1, 0, 1);
            g.DrawString ("Original Matrices:", Font, Brushes.Black, 10, 10 + 4 * offset);
            DrawMatrix (m1, g, 10, 10 + 5 * offset);
            DrawMatrix (m2, g, 10 + 130, 10 + 5 * offset);
            m1.Multiply (m2, MatrixOrder.Append);
            g.DrawString ("Resultant Matrix - Append:", Font, Brushes.Black, 10, 10 + 6 * offset);
            DrawMatrix (m1, g, 10, 10 + 7 * offset);

            // Matrix multiplication - MatrixOrder.Prepend:
            m1 = new Matrix (1, 2, 3, 4, 0, 1);
            m1.Multiply (m2, MatrixOrder.Prepend);
            g.DrawString ("Resultant Matrix - Prepend:", Font, Brushes.Black, 10, 10 + 8 * offset);
            DrawMatrix (m1, g, 10, 10 + 9 * offset);
        }
开发者ID:mono,项目名称:sysdrawing-coregraphics,代码行数:29,代码来源:DrawingView.cs

示例9: GetBrush

 public TextureBrush GetBrush(Matrix matrix)
 {
     Bitmap bmp;
     if (_context2D != null)
     {
         bmp = _context2D.GetBitmap();
     }
     else
     {
         bmp = new Bitmap(_imagePath);
     }
     WrapMode wm = WrapMode.Tile;
     switch (_repetition)
     {
         case "repeat":
             wm = WrapMode.Tile;
             break;
         case "no-repeat":
             wm = WrapMode.Clamp;
             break;
         case "repeat-x":
             wm = WrapMode.TileFlipX;
             break;
         case "repeat-y":
             wm = WrapMode.TileFlipY;
             break;
     }
     var brush = new TextureBrush(bmp, wm);
     brush.MultiplyTransform(matrix);
     return brush;
 }
开发者ID:podlipensky,项目名称:sharpcanvas,代码行数:31,代码来源:CanvasPattern.cs

示例10: ScaleBitmapMatrix

 public static Matrix ScaleBitmapMatrix(Matrix m)
 {
     System.Drawing.Drawing2D.Matrix mx =
         new System.Drawing.Drawing2D.Matrix(m.ScaleX, m.Rotate0, m.Rotate1, m.ScaleY, m.TranslateX, m.TranslateY);
     mx.Scale(1 / 20F, 1 / 20F);
     float[] els = mx.Elements;
     return new Matrix(els[0], els[1], els[2], els[3], els[4], els[5]);
 }
开发者ID:Hamsand,项目名称:Swf2XNA,代码行数:8,代码来源:Utils.cs

示例11: Draw

 /// <summary>
 /// Draws the picture to the graphics.
 /// </summary>
 /// <param name="g">The g.</param>
 public void Draw(Graphics g)
 {
     Point drawLocation = new Point((int)(location.X - offset.X), (int)(location.Y - offset.Y));
     Matrix m = new Matrix();
     m.RotateAt(-angle, location);
     g.Transform = m;
     g.DrawImage(bitmap, new Rectangle(drawLocation.X, drawLocation.Y, bitmap.Width / this.frameCountW, bitmap.Height / this.frameCountH),
         new Rectangle(this.frameW * bitmap.Width / this.frameCountW, this.frameH * bitmap.Height / this.frameCountH, bitmap.Width / this.frameCountW, bitmap.Height / this.frameCountH), GraphicsUnit.Pixel);
 }
开发者ID:ajrod,项目名称:Ratatat,代码行数:13,代码来源:Picture.cs

示例12: drawGraphLine

        private void drawGraphLine(Graphics graphics, PointF[] points, Pen pen, float yScale, float xScale)
        {
            var matrix = new Matrix();
            matrix.Scale(xScale, yScale);
            matrix.Translate(5, 5, MatrixOrder.Append);
            matrix.TransformPoints(points);

            graphics.DrawLines(pen, points);
        }
开发者ID:RogaDanar,项目名称:MineSweeper-Neural-Net,代码行数:9,代码来源:Graph.cs

示例13: DrawMatrix

        void DrawMatrix(Matrix m, Graphics g, int x, int y)
        {
            string str = null;
            for (int i = 0; i < m.Elements.Length; i++) {
                str += m.Elements[i].ToString ();
                str += ", ";
            }

            g.DrawString (str, Font, Brushes.Black, x, y);
        }
开发者ID:mono,项目名称:sysdrawing-coregraphics,代码行数:10,代码来源:DrawingView.cs

示例14: ModifyCTM

   public ModifyCTM(
 Matrix value
 )
       : this(value.Elements[0],
   value.Elements[1],
   value.Elements[2],
   value.Elements[3],
   value.Elements[4],
   value.Elements[5])
   {
   }
开发者ID:josuecorrea,项目名称:DanfeSharp,代码行数:11,代码来源:ModifyCTM.cs

示例15: DrawableAffine

    /// <summary>
    /// Initializes a new instance of the <see cref="DrawableAffine"/> class.
    /// </summary>
    /// <param name="matrix">The matrix.</param>
    public DrawableAffine(Matrix matrix)
    {
      Throw.IfNull(nameof(matrix), matrix);

      ScaleX = matrix.Elements[0];
      ScaleY = matrix.Elements[1];
      ShearX = matrix.Elements[2];
      ShearY = matrix.Elements[3];
      TranslateX = matrix.Elements[4];
      TranslateY = matrix.Elements[5];
    }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:15,代码来源:DrawableAffine.cs


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