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


C# GraphicsPath.Transform方法代码示例

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


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

示例1: DrawYourSelf

        public override void DrawYourSelf(Graphics graphics)
        {
            int i = 0;
            Point[] points = new Point[this.pointsList.Count];//(Point[])pointsList.ToArray(typeof(Point));
            foreach(Point _point in this.pointsList)
            {
                points[i] = _point;
                i++;
            }

            GraphicsPath path = new GraphicsPath();
            path.AddPolygon(points);
            path.Transform(this.TMatrix.TransformationMatrix);

            Pen pen = new Pen(this.BorderColor, this.BorderWidth);

            if (IS_FILLED)
            {
                SolidBrush brush = new SolidBrush(this.FillColor);
                graphics.FillPath(brush, path);
            }

            graphics.DrawPath(pen, path);

            if (this.Selected)
            {
                this.selectionUnit = new CoveringRectangle(Rectangle.Round(ReturnBounds()));
                this.selectionUnit.DrawYourSelf(graphics);
            }
        }
开发者ID:ferry2,项目名称:2D-Vector-Graphics,代码行数:30,代码来源:PolygonShape.cs

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

示例3: Form1_Paint

        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            using (Graphics g = e.Graphics)
            {
                // Создаем траекторию
                GraphicsPath path = new GraphicsPath();
                Rectangle rect = new Rectangle(20, 20, 150, 150);
                path.AddRectangle(rect);
                // Создаем градиентную кисть
                PathGradientBrush pgBrush =
                    new PathGradientBrush(path.PathPoints);
                // Уснинавливаем цвета кисти
                pgBrush.CenterColor = Color.Red;
                pgBrush.SurroundColors = new Color[] { Color.Blue };
                // Создаем объект Matrix
                Matrix X = new Matrix();
                // Translate
                X.Translate(30.0f, 10.0f, MatrixOrder.Append);
                // Rotate
                X.Rotate(10.0f, MatrixOrder.Append);
                // Scale
                X.Scale(1.2f, 1.0f, MatrixOrder.Append);
                // Shear
                X.Shear(.2f, 0.03f, MatrixOrder.Prepend);
                // Применяем преобразование к траектории и кисти
                path.Transform(X);
                pgBrush.Transform = X;
                // Выполняем визуализацию
                g.FillPath(pgBrush, path);
            }

        }
开发者ID:xs2ranjeet,项目名称:13ns9-1spr,代码行数:32,代码来源:Form1.cs

示例4: DrawYourSelf

        public override void DrawYourSelf(Graphics graphics)
        {
            GraphicsPath path = new GraphicsPath();
            path.StartFigure();
            path.AddLine(Location.X, Location.Y + ModelSize.Height / 3, Location.X + ModelSize.Width, Location.Y + ModelSize.Height / 3);
            path.CloseFigure();
            path.StartFigure();
            path.AddLine(Location.X, Location.Y + (ModelSize.Height / 3) * 2, Location.X + ModelSize.Width, Location.Y + (ModelSize.Height * 2) / 3);
            path.CloseFigure();
            path.AddEllipse(new RectangleF(Location, ModelSize));
            path.CloseFigure();
            path.Transform(this.TMatrix.TransformationMatrix);

            Pen pen = new Pen(this.BorderColor, this.BorderWidth);
            if (IS_FILLED)
            {
                SolidBrush brush = new SolidBrush(this.FillColor);
                graphics.FillPath(brush, path);
            }
            graphics.DrawPath(pen, path);
            if (this.Selected)
            {
                this.selectionUnit = new CoveringRectangle(Rectangle.Round(ReturnBounds()));
                this.selectionUnit.DrawYourSelf(graphics);
            }
        }
开发者ID:ferry2,项目名称:2D-Vector-Graphics,代码行数:26,代码来源:EllipseLineIntersectionShape.cs

示例5: OutlinedStringSurface

        public OutlinedStringSurface(
            String str, Font font, Brush brush, Pen outlinePen,
            StringFormat stringFormat)
        {
            Contract.Requires(str != null);
            Contract.Requires(font != null);
            Contract.Requires(brush != null);
            Contract.Requires(outlinePen != null);

            _brush = brush;
            _outlinePen = outlinePen;

            // グラフィックスパスの生成
            _path = new GraphicsPath();
            _path.AddString(
                str, font.FontFamily, (int)font.Style, font.Size,
                new Point(0, 0), stringFormat);
            // サイズを取得する
            var rect = _path.GetBounds();
            Size = rect.Size.ToSize();
            // 描画時にマージンがなくなるように平行移動
            var matrix = new Matrix(1, 0, 0, 1, -rect.Left, -rect.Top);
            _path.Transform(matrix);
            // 描画位置を(0, 0)で記憶
            matrix.Reset();
            _matrix = matrix;
        }
开发者ID:exKAZUu,项目名称:Paraiba,代码行数:27,代码来源:OutlinedStringSurface.cs

示例6: DrawYourSelf

        /// <summary>
        /// Изчертава правоъгълника.
        /// </summary>
        /// <param name="graphics"></param>
        public override void DrawYourSelf(Graphics graphics)
        {
            GraphicsPath path = new GraphicsPath();
            path.AddRectangle(new RectangleF(Location, ModelSize));
            path.Transform(this.TMatrix.TransformationMatrix);
            /**
             * Създава се Pen, който изчертава контура, като използва
             * цвят и дебелина (определят се от конструктора)
             **/
            Pen pen = new Pen(this.BorderColor, this.BorderWidth);
            /*
             * Създава се SolidBrush, която изпълва фигурата, като използва
             * цвят (определя се от конструктора)
             */
            SolidBrush brush = new SolidBrush(this.FillColor);
            /*
               * Функция на namespace System.Drawing.Drawing2D
               * Изпълва контура на елипсата чрез SolidBrush
              */
            if (IS_FILLED)
            {
                graphics.FillPath(brush, path);
            }
            /*
             * Функция на namespace System.Drawing.Drawing2D
             * Изчертава контура на елипсата чрез Pen
            */
            graphics.DrawPath(pen, path);

            if (this.Selected)
            {
                this.selectionUnit = new CoveringRectangle(Rectangle.Round(ReturnBounds()));
                this.selectionUnit.DrawYourSelf(graphics);
            }
        }
开发者ID:ferry2,项目名称:2D-Vector-Graphics,代码行数:39,代码来源:RectangleShape.cs

示例7: DrawYourSelf

        /// <summary>
        /// Изчертава елипсите.
        /// </summary>
        /// <param name="graphics"></param>
        public override void DrawYourSelf(Graphics graphics)
        {
            GraphicsPath path = new GraphicsPath();
            path.StartFigure();
            path.AddEllipse(Location.X + ModelSize.Width / 3, Location.Y + ModelSize.Height / 3, ModelSize.Width / 3, ModelSize.Height / 3);
            path.CloseFigure();
            path.StartFigure();
            path.AddLine(Location.X + (ModelSize.Width * 2) / 3, Location.Y + ModelSize.Height / 2, Location.X + ModelSize.Width, Location.Y + ModelSize.Height / 2);
            path.CloseFigure();
            path.AddEllipse(new RectangleF(Location, ModelSize));
            path.CloseFigure();
            path.Transform(this.TMatrix.TransformationMatrix);

            /*
             * Създава се Pen, който изчертава контура, като използва
             * цвят и дебелина (определят се от конструктора)
             */
            Pen pen = new Pen(this.BorderColor, this.BorderWidth);
            // Правим същото, но за запълването
            if (IS_FILLED)
            {
                SolidBrush brush = new SolidBrush(this.FillColor);
                graphics.FillPath(brush, path);
            }
            graphics.DrawPath(pen, path);
            if (this.Selected)
            {
                this.selectionUnit = new CoveringRectangle(Rectangle.Round(ReturnBounds()));
                this.selectionUnit.DrawYourSelf(graphics);
            }
        }
开发者ID:ferry2,项目名称:2D-Vector-Graphics,代码行数:35,代码来源:ConnectedEllipses.cs

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

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

示例10: ReturnBounds

        public override RectangleF ReturnBounds()
        {
            GraphicsPath path = new GraphicsPath();
            path.AddEllipse(Location.X, Location.Y, 5, 5);
            path.Transform(this.TMatrix.TransformationMatrix);

            return path.GetBounds();
        }
开发者ID:ferry2,项目名称:2D-Vector-Graphics,代码行数:8,代码来源:PointShape.cs

示例11: Draw

 /// <summary>
 /// draw the line
 /// </summary>
 /// <param name="g">drawing object</param>
 /// <param name="translate">translation between drawn sketch and geometry object</param>
 public override void Draw(Graphics g, Matrix translate)
 {
     m_transform = translate;
     GraphicsPath path = new GraphicsPath();
     path.AddLine(m_line.StartPnt, m_line.EndPnt);
     path.Transform(translate);
     g.DrawPath(m_pen, path);
 }
开发者ID:AMEE,项目名称:revit,代码行数:13,代码来源:LineSketch.cs

示例12: ReturnBounds

        public override RectangleF ReturnBounds()
        {
            GraphicsPath path = new GraphicsPath();
            path.AddBezier(pointOne, pointTwo, pointTree, pointFour);

            path.Transform(this.TMatrix.TransformationMatrix);
            return path.GetBounds();
        }
开发者ID:ferry2,项目名称:2D-Vector-Graphics,代码行数:8,代码来源:BezierCurveShape.cs

示例13: ReturnBounds

        public override RectangleF ReturnBounds()
        {
            GraphicsPath path = new GraphicsPath();
            path.AddRectangle(new RectangleF(Location.X, Location.Y, ModelSize.Width, ModelSize.Width));
            path.Transform(this.TMatrix.TransformationMatrix);

            return path.GetBounds();
        }
开发者ID:ferry2,项目名称:2D-Vector-Graphics,代码行数:8,代码来源:SquareShape.cs

示例14: Form2_Paint

        private void Form2_Paint(object sender, PaintEventArgs e)
        {
            //패스 그래디언트
            Point[] pts = { new Point(100, 0), new Point(0, 100), new Point(200, 100) };
            PathGradientBrush B = new PathGradientBrush(pts, WrapMode.Tile);
            e.Graphics.FillRectangle(B, ClientRectangle);

            //패스 그래디언트 끝
            //패스변형
            GraphicsPath Path = new GraphicsPath();
            Path.AddString("한글", new FontFamily("궁서"), 0, 100, new Point(10, 30), new StringFormat());
            //확장 후 외곽선 그리기
            Path.Widen(new Pen(Color.Black, 3));
            e.Graphics.DrawPath(Pens.Black, Path);

            //확장 후 채우기
            Path.Widen(new Pen(Color.Blue, 3));
            e.Graphics.DrawPath(Pens.Black, Path);

            //곡선 펴기
            Path.Flatten(new Matrix(), 12f);
            e.Graphics.DrawPath(Pens.Black, Path);

            //회전
            Matrix M = new Matrix();
            M.Rotate(-10);
            Path.Transform(M);
            e.Graphics.FillPath(Brushes.Blue, Path);

            //휘기
            RectangleF R = Path.GetBounds();
            PointF[] arPoint = new PointF[4];
            arPoint[0] = new PointF(R.Left, R.Top + 30);
            arPoint[1] = new PointF(R.Right, R.Top - 10);
            arPoint[2] = new PointF(R.Left + 10, R.Bottom - 10);
            arPoint[3] = new PointF(R.Right + 30, R.Bottom + 30);

            Path.Warp(arPoint, R);
            e.Graphics.FillPath(Brushes.Blue, Path);

            //클리핑

            //graphicspath path= new graphicspath();
            //path.fillmode = fillmode.winding;
            //path.addellipse(50, 10, 100, 80);
            //path.addellipse(20, 45, 160, 120);
            //e.graphics.fillpath(brushes.white, path);

            //e.graphics.setclip(path);

            //for (int y = 0; y < bottom; y+= 20)
            //{
            //    string str = "눈사람의 모양의클리핑 영역에 글자를 쓴것입니다";
            //    e.graphics.drawstring(str, font, brushes.blue, 0, y);
            //}

            //클리핑 끝
        }
开发者ID:sunnamkim,项目名称:doc,代码行数:58,代码来源:Form2.cs

示例15: ReturnBounds

        public override RectangleF ReturnBounds()
        {
            Point[] points = (Point[])pointsList.ToArray(typeof(Point));
            GraphicsPath path = new GraphicsPath();
            path.AddCurve(points,1);

            path.Transform(this.TMatrix.TransformationMatrix);
            return  path.GetBounds();
        }
开发者ID:ferry2,项目名称:2D-Vector-Graphics,代码行数:9,代码来源:CurveShape.cs


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