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


C# Matrix.Multiply方法代码示例

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


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

示例1: TransformPoints

        static public void TransformPoints(PointF[] points, PointF origin, bool diagonal, bool horizontal, bool vertical)
        {
            Matrix translate = new Matrix();
            Matrix rotate = new Matrix();

            // Put the points into origin/local space
            translate.Translate(-origin.X, -origin.Y);
            translate.TransformPoints(points);

            // Apply the flips/rotations (order matters)
            if (horizontal)
            {
                Matrix h = new Matrix(-1, 0, 0, 1, 0, 0);
                rotate.Multiply(h);
            }
            if (vertical)
            {
                Matrix v = new Matrix(1, 0, 0, -1, 0, 0);
                rotate.Multiply(v);
            }
            if (diagonal)
            {
                Matrix d = new Matrix(0, 1, 1, 0, 0, 0);
                rotate.Multiply(d);
            }

            // Apply the combined flip/rotate transformation
            rotate.TransformPoints(points);

            // Put points back into world space
            translate.Invert();
            translate.TransformPoints(points);
        }
开发者ID:knunery,项目名称:Tiled2Unity,代码行数:33,代码来源:TmxMath.cs

示例2: getAffineTransformMatrix

        private static Matrix getAffineTransformMatrix(PointF p01, PointF p02, PointF p03,
                                                        PointF p11, PointF p12, PointF p13)
        {
            Matrix a = new Matrix(p02.X - p01.X,
                                  p02.Y - p01.Y,
                                  p03.X - p01.X,
                                  p03.Y - p01.Y,
                                  p01.X,
                                  p01.Y);

            Matrix b = new Matrix(p12.X - p11.X,
                                  p12.Y - p11.Y,
                                  p13.X - p11.X,
                                  p13.Y - p11.Y,
                                  p11.X,
                                  p11.Y);

            if (!a.IsInvertible)
                return null;

            a.Invert();
            a.Multiply(b, MatrixOrder.Append);

            return a;
        }
开发者ID:gkrsu,项目名称:maparound.core,代码行数:25,代码来源:RasterAlgorithms.cs

示例3: Translate

 /*
  * Translate
  * методът се ползва при скалиране
  * за нулиране на нежелан ефект при скалирнаето(изместване на фигурата в страни)
  * и за нормално транслиране - преместване
  * **/
 public virtual void Translate(float X,float Y)
 {
     Matrix tempMatrix = new Matrix();
     tempMatrix.Translate(X, Y);
     tempMatrix.Multiply(TransformationMatrix);
     TransformationMatrix = tempMatrix;
 }
开发者ID:ferry2,项目名称:2D-Vector-Graphics,代码行数:13,代码来源:MatrixHandler.cs

示例4: DrawRect

        public override void DrawRect(System.Drawing.RectangleF dirtyRect)
        {
            Graphics g = new Graphics();
            int offset = 20;

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

            // Matrix multiplication - MatrixOrder.Append:
            Matrix m1 = new Matrix(1, 2, 3, 4, 0, 1);
            Matrix m2 = new Matrix(0, 1, 2, 1, 0, 1);
            g.DrawString("Original Matrices:", this.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:", this.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:", this.Font, Brushes.Black, 10, 10 + 8 * offset);
            DrawMatrix(m1, g, 10, 10 + 9 * offset);
        }
开发者ID:stnk3000,项目名称:sysdrawing-coregraphics,代码行数:29,代码来源:DrawingView.cs

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

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

示例7: CreateTransformMatrix

 private static Matrix CreateTransformMatrix(TileInfo tileInfo)
 {
     // The code below needs no comments, it is fully intuitive.
     // I wrote in in one go and it ran correctly right away.
     var matrix = new Matrix();
     var flipMatrix = new Matrix(1, 0, 0, -1, 0, 0);
     matrix.Multiply(flipMatrix);
     matrix.Scale(
         (float) (TileWidth/tileInfo.Extent.Width),
         (float) (TileHeight/tileInfo.Extent.Height));
     matrix.Translate(-(float) tileInfo.Extent.MinX, -(float) tileInfo.Extent.MaxY);
     return matrix;
 }
开发者ID:xiaoqqchen,项目名称:BruTile,代码行数:13,代码来源:VectorTileConverter.cs

示例8: GetBaselinePath

        protected override GraphicsPath GetBaselinePath(ISvgRenderer renderer)
        {
            var path = this.OwnerDocument.IdManager.GetElementById(this.ReferencedPath) as SvgVisualElement;
            if (path == null) return null;
            var pathData = (GraphicsPath)path.Path(renderer).Clone();
            if (path.Transforms.Count > 0)
            {
                Matrix transformMatrix = new Matrix(1, 0, 0, 1, 0, 0);

                foreach (var transformation in path.Transforms)
                {
                    transformMatrix.Multiply(transformation.Matrix);
                }

                pathData.Transform(transformMatrix);
            }
            return pathData;
        }
开发者ID:dteunkenstt,项目名称:SVG,代码行数:18,代码来源:SvgTextPath.cs

示例9: GetParentsTransform

 private Matrix GetParentsTransform(Node node)
 {
     if (node is PseudoGroup)
     {
         return new Matrix();
     }
     if ((node == null) || (node.Parent == null))
     {
         throw new ArgumentNullException("node && parent are null!");
     }
     Matrix matrix = new Matrix();
     for (ICompositeNode node2 = node.Parent; !(node2 is Syncfusion.Windows.Forms.Diagram.Model); node2 = ((Node)node2).Parent)
     {
         Matrix transformations = ((Node)node2).GetTransformations();
         ((Node)node2).AppendFlipTransforms(transformations);
         matrix.Multiply(transformations, MatrixOrder.Append);
     }
     return matrix;
 }
开发者ID:AlexSneg,项目名称:VIRD-1.0,代码行数:19,代码来源:DiagramViewBase.cs

示例10: Draw

        public void Draw(ObjectPainter painter)
        {
            var angle = _time*90/(float) Math.PI;
            var world = new Matrix();
            if (UseTranslation)
                world.Translate(_time * 25, _time * 30);
            world.Rotate(angle);
            var scale = new Matrix();
            scale.Scale(100, 100);

            world.Multiply(scale);
            painter.Paint(world, _square);

            angle = _time*1.5f*90/(float) Math.PI;
            world = new Matrix();
            if (UseTranslation)
                world.Translate(_time * 20, _time * 25);
            world.Rotate(angle);
            scale = new Matrix();
            scale.Scale(200, 200);

            world.Multiply(scale);
            painter.Paint(world, _square);
        }
开发者ID:danbystrom,项目名称:VisionQuest,代码行数:24,代码来源:Game.cs

示例11: RenderTo

        private void RenderTo(Graphics g)
        {
            SvgDocument svgdoc = tlVectorControl1.SVGDocument;
            Matrix matrix1 = new Matrix();
            Matrix matrix2 = new Matrix();
            matrix1 = ((SVG)svgdoc.RootElement).GraphTransform.Matrix;
            matrix2.Multiply(matrix1);
            matrix1.Reset();
            matrix1.Multiply(g.Transform);
            g.ResetTransform();
            try {

                SVG svg1 = svgdoc.DocumentElement as SVG;
                svgdoc.BeginPrint = true;
                SmoothingMode mode1 = svgdoc.SmoothingMode;
                svgdoc.SmoothingMode = g.SmoothingMode;
                svg1.Draw(g, svgdoc.ControlTime);
                svgdoc.SmoothingMode = mode1;
                svgdoc.BeginPrint = false;
            } finally {
                g.Transform = matrix1.Clone();
                matrix1.Reset();
                matrix1.Multiply(matrix2);
            }
        }
开发者ID:EdgarEDT,项目名称:myitoppsp,代码行数:25,代码来源:frmMain_wh.cs

示例12: AddElement

        public SvgElement AddElement(ISvgElement mypath)
        {
            //			AttributeFunc.SetAttributeValue((XmlElement)mypath,"layer",SvgDocument.currentLayer);
            XmlNode node1 = OwnerDocument.RootElement;
            XmlNode newNode =null;

                Matrix matrix1 = new Matrix();
            //				if (node1 is IGraph)
            //				{
            //					matrix1 = ((IGraph) node1).GraphTransform.Matrix.Clone();
            //					Matrix matrix2 = this.coordTransform.Clone();
            //					matrix2.Invert();
            //					matrix1.Multiply(matrix2, MatrixOrder.Append);
            //				}
            //				matrix1.Invert();
            //				matrix1 = TransformFunc.RoundMatrix(matrix1, 2);
                bool flag1 = OwnerDocument.AcceptChanges;
                //				OwnerDocument.AcceptChanges = false;
                OwnerDocument.AcceptChanges = true;
                if (mypath is IGraphPath)
                {
                    ISvgBrush brush1 = ((IGraphPath) mypath).GraphBrush;
                    if ((brush1 is ITransformBrush) && (((SvgElement) brush1).ParentNode == null))
                    {
                        bool flag2 = OwnerDocument.AcceptChanges;
                        OwnerDocument.AcceptChanges = true;
                        OwnerDocument.NumberOfUndoOperations++;
                        XmlNode node2 = OwnerDocument.AddDefsElement((SvgElement) brush1);
                        OwnerDocument.AcceptChanges = false;
                        if (node2 is ITransformBrush)
                        {
                            string text1 = ((SvgElement) node2).ID;
                            AttributeFunc.SetAttributeValue((SvgElement) mypath, "fill", "url(#" + text1 + ")");
                        }
                        OwnerDocument.AcceptChanges = flag2;
                    }
                    brush1 = ((IGraphPath) mypath).GraphStroke.Brush;
                    if ((brush1 is ITransformBrush) && (((SvgElement) brush1).ParentNode == null))
                    {
                        bool flag3 = OwnerDocument.AcceptChanges;
                        OwnerDocument.AcceptChanges = true;
                        OwnerDocument.NumberOfUndoOperations++;
                        XmlNode node3 = OwnerDocument.AddDefsElement((SvgElement) brush1);
                        OwnerDocument.AcceptChanges = false;
                        if (node3 is ITransformBrush)
                        {
                            string text2 = ((SvgElement) node3).ID;
                            AttributeFunc.SetAttributeValue((SvgElement) mypath, "stroke", "url(#" + text2 + ")");
                        }
                        OwnerDocument.AcceptChanges = flag3;
                    }
                }
                if (!matrix1.IsIdentity && (mypath is IGraph))
                {
                    bool flag4 = OwnerDocument.AcceptChanges;
                    OwnerDocument.AcceptChanges = false;
                    Matrix matrix3 = ((IGraph) mypath).Transform.Matrix.Clone();
                    matrix1.Multiply(matrix3);
                    Transf transf1 = new Transf();
                    transf1.setMatrix(matrix1);
                    AttributeFunc.SetAttributeValue((SvgElement) mypath, "transform", transf1.ToString());
                    OwnerDocument.AcceptChanges = flag4;
                }
                if (((SvgElement) mypath).ParentNode != node1)
                {
                    if (((ContainerElement) node1).IsValidChild((SvgElement) mypath))
                    {
                        //						node1.AppendChild((SvgElement) mypath);
                        SvgElement element1 =(SvgElement) mypath;//(SvgElement)OwnerDocument.ImportNode((SvgElement) mypath,true);
                        newNode = node1.AppendChild(element1);
                        OwnerDocument.Render(element1);
                    }
                }
                OwnerDocument.AcceptChanges = flag1;

            return newNode!=null?newNode as SvgElement:null;
        }
开发者ID:EdgarEDT,项目名称:myitoppsp,代码行数:77,代码来源:Layer.cs

示例13: Translate

 public void Translate()
 {
     foreach (var shape in Selection)
     {
         Matrix m = new Matrix();
         m.Translate(EndPoint.X - StartPoint.X, EndPoint.Y - StartPoint.Y);
         m.Multiply(shape.TransformMatrix.GetMatrix());
         shape.TransformMatrix.GetElements(m);
         IsChanged = true;
     }
     StartPoint = EndPoint;
 }
开发者ID:iprodanov,项目名称:IPDrawing,代码行数:12,代码来源:DialogProcessor.cs

示例14: OnMouseMove


//.........这里部分代码省略.........
                                    xTranslate = -spBounds2.X - spBounds2.Width;
                                    yTranslate = -spBounds2.Y - spBounds2.Height;
                                    break;

                                case Edge.Top:
                                    allowConstrain = false;
                                    xTranslate = 0;
                                    yTranslate = -spBounds2.Y - spBounds2.Height;
                                    break;

                                case Edge.TopRight:
                                    allowConstrain = true;
                                    xTranslate = -spBounds2.X;
                                    yTranslate = -spBounds2.Y - spBounds2.Height;
                                    break;

                                case Edge.Left:
                                    allowConstrain = false;
                                    xTranslate = -spBounds2.X - spBounds2.Width;
                                    yTranslate = 0;
                                    break;

                                case Edge.Right:
                                    allowConstrain = false;
                                    xTranslate = -spBounds2.X;
                                    yTranslate = 0;
                                    break;

                                case Edge.BottomLeft:
                                    allowConstrain = true;
                                    xTranslate = -spBounds2.X - spBounds2.Width;
                                    yTranslate = -spBounds2.Y;
                                    break;

                                case Edge.Bottom:
                                    allowConstrain = false;
                                    xTranslate = 0;
                                    yTranslate = -spBounds2.Y;
                                    break;

                                case Edge.BottomRight:
                                    allowConstrain = true;
                                    xTranslate = -spBounds2.X;
                                    yTranslate = -spBounds2.Y;
                                    break;
                            }

                            translateMatrix.Translate(xTranslate, yTranslate, MatrixOrder.Append);

                            float newWidth = spBounds2.Width + xulen;
                            float newHeight = spBounds2.Height + yulen;
                            float xScale = newWidth / spBounds2.Width;
                            float yScale = newHeight / spBounds2.Height;

                            if (allowConstrain && (this.ModifierKeys & Keys.Shift) != 0)
                            {
                                ConstrainScaling(this.context.liftedBounds, spBounds2.Width, spBounds2.Height,
                                    newWidth, newHeight, out xScale, out yScale);
                            }

                            translateMatrix.Scale(xScale, yScale, MatrixOrder.Append);
                            translateMatrix.Translate(-xTranslate, -yTranslate, MatrixOrder.Append);
                            translateMatrix.RotateAt(+tAngle, sp2BoundsCenter, MatrixOrder.Append);

                            break;

                        default:
                            throw new InvalidEnumArgumentException();
                    }

                    this.context.deltaTransform.Reset();
                    this.context.deltaTransform.Multiply(this.context.liftTransform, MatrixOrder.Append);
                    this.context.deltaTransform.Multiply(translateMatrix, MatrixOrder.Append);

                    translateMatrix.Multiply(this.context.baseTransform, MatrixOrder.Prepend);

                    Selection.SetInterimTransform(translateMatrix);

                    interim.Dispose();
                    interim = null;
                }

                // advertise our angle of rotation to any host (i.e. mainform) that might want to use that information
                this.hostShouldShowAngle = this.rotateNub.Visible;
                this.hostAngle = -this.rotateNub.Angle;

                Selection.PerformChanged();
                dontDrop = false;

                Render(newOffset, true);
                Update();

                this.context.offset = newOffset;

                if (this.enableOutline)
                {
                    DocumentWorkspace.ResetOutlineWhiteOpacity();
                }
            }
        }
开发者ID:leejungho2,项目名称:xynotecgui,代码行数:101,代码来源:MoveToolBase.cs

示例15: CheckForIterater

        /// <summary>
        /// Check if the line is a Iterator element. if true, reset the new P1, P2 by OffsetTransform
        /// The new P1, P2 will be used to compute the intersections
        /// </summary>
        private void CheckForIterater()
        {
            if (this.m_HasIterator)
            {
                Matrix totalOffset = new Matrix(1, 0, 0, 1, 0, 0);
                for (int i = 0; i < this.m_IteratorIndex; i++)
                    totalOffset.Multiply(this.m_OffsetTransform);

                PointF[] points={this.m_Line.P1,this.m_Line.P2};
                totalOffset.TransformPoints(points);

                this.m_Line.P1 = points[0];
                this.m_Line.P2 = points[1];
            }
        }
开发者ID:ClassroomPresenter,项目名称:CP3,代码行数:19,代码来源:LinePrimitiveRenderer.cs


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