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


C# Matrix.Shear方法代码示例

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


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

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

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

示例3: CreateImage

        /// <summary>
        /// 创建图片
        /// </summary>
        /// <param name="str"></param>
        public void CreateImage(string validateCode)
        {
            int width = validateCode.Length * 30;
            Random rand = new Random();
            Bitmap bmp = new Bitmap(width + validateCode.Length * 3, 50);

            Graphics g = Graphics.FromImage(bmp);
            g.Clear(Color.FromArgb(255, 255, 255));

            DrawLine(g, bmp, RANDOM_LINE_COUNT);
            DrawPrint(bmp, RANDOM_PRINT_COUNT);

            for (int i = 0; i < validateCode.Length; i++)
            {

                Matrix matrix = new Matrix();
                matrix.Shear((float)_random.Next(0, 300) / 1000 - 0.25f, (float)_random.Next(0, 100) / 1000 - 0.05f);
                g.Transform = matrix;
                string str = validateCode.Substring(i, 1);
                LinearGradientBrush brush = new LinearGradientBrush(new Rectangle(0, 0, bmp.Width, bmp.Height), Color.Blue, Color.DarkRed, 1.2f, true);
                Point pos = new Point(i * 30 + 1 + rand.Next(3), 1 + rand.Next(5));
                Font font = new Font(Fonts[_random.Next(Fonts.Length - 1)], _random.Next(24, 30), FontStyle.Bold);
                g.DrawString(str, font, brush, pos);
            }

            MemoryStream ms = new MemoryStream();
            bmp.Save(ms, ImageFormat.Png);
            Response.ClearContent();
            Response.ContentType = "image/png";
            Response.BinaryWrite(ms.ToArray());
            g.Dispose();
            bmp.Dispose();
            Response.End();
        }
开发者ID:shouchangfayi,项目名称:mvc,代码行数:38,代码来源:VercodeController.cs

示例4: shear

 public Color[,] shear(Color[,] Org_Buffer, float sx, float sy)
 {
     flag_rotate_shear = true;
     Matrix M = new Matrix();
     M.Shear((float)sx, (float)sy);
     return Transform(Org_Buffer, M);
 }
开发者ID:ahmedelkashef,项目名称:GP,代码行数:7,代码来源:GeometryOperations.cs

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

示例6: full_transform

        public void full_transform(float ScX, float ScY, float ShX, float ShY, float RoAngle)
        {
            Matrix transform_matrix = new Matrix();
            transform_matrix.Scale(ScX, ScY, MatrixOrder.Append);
            transform_matrix.Shear(ShX, ShY, MatrixOrder.Append);
            transform_matrix.Rotate(RoAngle, MatrixOrder.Append);

            Transform(transform_matrix);
        }
开发者ID:MohamedNewhey,项目名称:IP-FCIS,代码行数:9,代码来源:ImageP.cs

示例7: Form1_Paint

        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            using (Graphics g = e.Graphics)
            {
                try
                {
                    // рисуем изображение без трасформаций 
                    g.DrawImage(new Bitmap(@"Boxs.bmp"), 0, 0, 100, 100);
                }
                catch { }
                // Создаем матрицу
                Matrix X = new Matrix();
                // Установка трансформаций
                X.RotateAt(45,new Point(150,150));
                X.Translate(100, 100);
                g.Transform = X;
                try
                {
                    // рисуем изображение
                    g.DrawImage(new Bitmap(@"Rings.bmp"), 0, 0, 100, 100);
                }
                catch { }

                // Сброс трансформаций
                X.Reset();
                // Установка трансформаций
                X.RotateAt(25, new Point(50, 150));
                X.Translate(150, 10);
                X.Shear(0.5f, 0.3f);
                g.Transform = X;
                try
                {
                    // рисуем изображение
                    g.DrawImage(new Bitmap(@"Cells.bmp"), 0, 0, 100, 100);
                }
                catch { }

            }

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

示例8: DrawRect

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

            // Scale:
            Matrix m = new Matrix(1, 2, 3, 4, 0, 1);
            g.DrawString("Original Matrix:", this.Font,
                         Brushes.Black, 10, 10);
            DrawMatrix(m, g, 10, 10 + offset);
            g.DrawString("Scale - Prepend:", this.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:", this.Font,
                         Brushes.Black, 10, 10 + 4 * offset);
            // Reset m to the original matrix:
            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:", this.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:", this.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);

            // Rotation:
            m = new Matrix(1, 2, 3, 4, 0, 1);
            g.DrawString("Rotation - Prepend:", this.Font,
                         Brushes.Black, 10, 10 + 10 * offset);
            m.Rotate(45, MatrixOrder.Prepend);
            DrawMatrix(m, g, 10, 10 + 11 * offset);
            g.DrawString("Rotation - Append:", this.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:", this.Font,
                         Brushes.Black, 10, 10 + 14 * offset);
            m.RotateAt(45, new PointF(1, 2), MatrixOrder.Prepend);
            DrawMatrix(m, g, 10, 10 + 15 * offset);
            g.DrawString("Rotation At - Append:", this.Font,
                         Brushes.Black, 10, 10 + 16 * offset);
            // Reset m to the original matrix:
            m = new Matrix(1, 2, 3, 4, 0, 1);
            m.RotateAt(45, new PointF(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:", this.Font,
                         Brushes.Black, 10, 10 + 18 * offset);
            m.Shear(1, 2, MatrixOrder.Prepend);
            DrawMatrix(m, g, 10, 10 + 19 * offset);
            g.DrawString("Shear - Append:", this.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:stnk3000,项目名称:sysdrawing-coregraphics,代码行数:73,代码来源:DrawingView.cs

示例9: CreateCache

        /// <summary>
        /// Create cache
        /// </summary>
        /// <param name="rectBound">The bound rectangle</param>
        /// <param name="bevelRate">Bevel rate</param>
        /// <param name="segmentWidth">Width of the segment</param>
        /// <param name="segmentInterval">Interval between segments</param>
        private void CreateCache(Rectangle rectBound, float bevelRate, float segmentWidth, float segmentInterval)
        {
            Matrix mx = new Matrix(1, 0, 0, 1, 0, 0);
            mx.Shear(-0.1f, 0);
            PointF[] pathPointCollection = new PointF[6];
            PointF[] pathDotCollection = new PointF[4];
            for(int i = 0; i < 8; ++i)
            {
                if(m_CachedPaths[i] == null)
                    m_CachedPaths[i] = new GraphicsPath();
            }
            // top '-'
            pathPointCollection[0].X = segmentWidth * bevelRate + segmentInterval;
            pathPointCollection[0].Y = segmentWidth * bevelRate;
            pathPointCollection[1].X = segmentInterval + segmentWidth * bevelRate * 2;
            pathPointCollection[1].Y = 0;
            pathPointCollection[2].X = rectBound.Width - segmentInterval - segmentWidth * bevelRate * 2;
            pathPointCollection[2].Y = 0;
            pathPointCollection[3].X = rectBound.Width - segmentInterval - segmentWidth * bevelRate;
            pathPointCollection[3].Y = segmentWidth * bevelRate;
            pathPointCollection[4].X = rectBound.Width - segmentInterval - segmentWidth;
            pathPointCollection[4].Y = segmentWidth;
            pathPointCollection[5].X = segmentWidth + segmentInterval;
            pathPointCollection[5].Y = segmentWidth;
            m_CachedPaths[0].AddPolygon(pathPointCollection);
            m_CachedPaths[0].CloseFigure();
            if (UseItalicStyle) m_CachedPaths[0].Transform(mx);

            // upper right '|'
            pathPointCollection[0].X = rectBound.Width - segmentWidth;
            pathPointCollection[0].Y = segmentWidth + segmentInterval;
            pathPointCollection[1].X = rectBound.Width - segmentWidth * bevelRate;
            pathPointCollection[1].Y = segmentWidth * bevelRate + segmentInterval;
            pathPointCollection[2].X = rectBound.Width + 1;
            pathPointCollection[2].Y = segmentWidth * bevelRate * 2 + segmentInterval + 1;
            pathPointCollection[3].X = rectBound.Width + 1;
            pathPointCollection[3].Y = (rectBound.Height >> 1) - segmentWidth * 0.5f - segmentInterval - 1;
            pathPointCollection[4].X = rectBound.Width - segmentWidth * 0.5f;
            pathPointCollection[4].Y = (rectBound.Height >> 1) - segmentInterval;
            pathPointCollection[5].X = rectBound.Width - segmentWidth;
            pathPointCollection[5].Y = (rectBound.Height >> 1) - segmentWidth * 0.5f - segmentInterval;
            m_CachedPaths[1].AddPolygon(pathPointCollection);
            m_CachedPaths[1].CloseFigure();
            if (UseItalicStyle) m_CachedPaths[1].Transform(mx);

            // bottom right '|'
            pathPointCollection[0].X = rectBound.Width - segmentWidth;
            pathPointCollection[0].Y = (rectBound.Height >> 1) + segmentInterval + segmentWidth * 0.5f;
            pathPointCollection[1].X = rectBound.Width - segmentWidth * 0.5f;
            pathPointCollection[1].Y = (rectBound.Height >> 1) + segmentInterval;
            pathPointCollection[2].X = rectBound.Width + 1;
            pathPointCollection[2].Y = (rectBound.Height >> 1) + segmentInterval + segmentWidth * 0.5f + 1;
            pathPointCollection[3].X = rectBound.Width + 1;
            pathPointCollection[3].Y = rectBound.Height - segmentInterval - segmentWidth * bevelRate * 2 - 1;
            pathPointCollection[4].X = rectBound.Width - segmentWidth * bevelRate;
            pathPointCollection[4].Y = rectBound.Height - segmentWidth * bevelRate - segmentInterval;
            pathPointCollection[5].X = rectBound.Width - segmentWidth;
            pathPointCollection[5].Y = rectBound.Height - segmentWidth - segmentInterval;
            m_CachedPaths[2].AddPolygon(pathPointCollection);
            m_CachedPaths[2].CloseFigure();
            if (UseItalicStyle) m_CachedPaths[2].Transform(mx);

            // bottom '-'
            pathPointCollection[0].X = segmentWidth * bevelRate + segmentInterval;
            pathPointCollection[0].Y = rectBound.Height - segmentWidth * bevelRate;
            pathPointCollection[1].X = segmentWidth + segmentInterval;
            pathPointCollection[1].Y = rectBound.Height - segmentWidth;
            pathPointCollection[2].X = rectBound.Width - segmentInterval - segmentWidth;
            pathPointCollection[2].Y = rectBound.Height - segmentWidth;
            pathPointCollection[3].X = rectBound.Width - segmentInterval - segmentWidth * bevelRate;
            pathPointCollection[3].Y = rectBound.Height - segmentWidth * bevelRate;
            pathPointCollection[4].X = rectBound.Width - segmentInterval - segmentWidth * bevelRate * 2;
            pathPointCollection[4].Y = rectBound.Height;
            pathPointCollection[5].X = segmentWidth * bevelRate * 2 + segmentInterval;
            pathPointCollection[5].Y = rectBound.Height;
            m_CachedPaths[3].AddPolygon(pathPointCollection);
            m_CachedPaths[3].CloseFigure();
            if (UseItalicStyle) m_CachedPaths[3].Transform(mx);

            // bottom left '|'
            pathPointCollection[0].X = 0f;
            pathPointCollection[0].Y = (rectBound.Height >> 1) + segmentInterval + segmentWidth * 0.5f;
            pathPointCollection[1].X = segmentWidth * 0.5f;
            pathPointCollection[1].Y = (rectBound.Height >> 1) + segmentInterval;
            pathPointCollection[2].X = segmentWidth;
            pathPointCollection[2].Y = (rectBound.Height >> 1) + segmentInterval + segmentWidth * 0.5f;
            pathPointCollection[3].X = segmentWidth;
            pathPointCollection[3].Y = rectBound.Height - segmentWidth - segmentInterval;
            pathPointCollection[4].X = segmentWidth * bevelRate;
            pathPointCollection[4].Y = rectBound.Height - segmentWidth * bevelRate - segmentInterval;
            pathPointCollection[5].X = 0f;
            pathPointCollection[5].Y = rectBound.Height - segmentInterval - segmentWidth * bevelRate * 2;
            m_CachedPaths[4].AddPolygon(pathPointCollection);
//.........这里部分代码省略.........
开发者ID:ViniciusConsultor,项目名称:geansoft,代码行数:101,代码来源:LxLedControl.cs

示例10: CreateImage

        /// <summary>
        /// Create Validation Code Image
        /// </summary>
        private byte[] CreateImage(string str_ValidateCode)
        {
            int int_ImageWidth = str_ValidateCode.Length * 22;
            Random newRandom = new Random();

            Bitmap theBitmap = new Bitmap(int_ImageWidth + 6, 38);
            Graphics theGraphics = Graphics.FromImage(theBitmap);

            theGraphics.Clear(Color.White);

            drawLine(theGraphics, theBitmap, newRandom);
            theGraphics.DrawRectangle(new Pen(Color.LightGray, 1), 0, 0, theBitmap.Width - 1, theBitmap.Height - 1);

            for (int int_index = 0; int_index < str_ValidateCode.Length; int_index++)
            {
                Matrix X = new Matrix();
                X.Shear((float)newRandom.Next(0, 300) / 1000 - 0.25f, (float)newRandom.Next(0, 100) / 1000 - 0.05f);
                theGraphics.Transform = X;
                string str_char = str_ValidateCode.Substring(int_index, 1);
                System.Drawing.Drawing2D.LinearGradientBrush newBrush = new System.Drawing.Drawing2D.LinearGradientBrush(new Rectangle(0, 0, theBitmap.Width, theBitmap.Height), Color.Blue, Color.DarkRed, 1.2f, true);
                Point thePos = new Point(int_index * 21 + 1 + newRandom.Next(3), 1 + newRandom.Next(13));

                Font theFont = new Font(Fonts[newRandom.Next(Fonts.Length - 1)], newRandom.Next(14, 18), FontStyle.Bold);

                theGraphics.DrawString(str_char, theFont, newBrush, thePos);
            }

            drawPoint(theBitmap, newRandom);

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

            var ret = ms.ToArray();
            theGraphics.Dispose();
            theBitmap.Dispose();
            ms.Close();
            return ret;
        }
开发者ID:BeanHsiang,项目名称:SpeechLoginDemo,代码行数:41,代码来源:HomeController.cs

示例11: NextImage

        /// <summary>
        /// 生产图片验证码
        /// </summary>
        /// <returns></returns>
        public static Bitmap NextImage(int width = 70, int height = 34, int length = 4)
        {
            //获取随机字符
            Random rand = new Random();
            string str = RandomString(length);
            HttpContext.Current.Session["verificationCode"] = str;

            //创建画板
            Bitmap image = new Bitmap(width, height);
            Graphics g = Graphics.FromImage(image);
            //g.InterpolationMode = InterpolationMode.HighQualityBicubic;
            g.InterpolationMode = InterpolationMode.Low;
            //g.CompositingMode = CompositingMode.SourceOver;
            //g.CompositingQuality = CompositingQuality.HighQuality;
            g.CompositingQuality = CompositingQuality.HighSpeed;
            g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
            g.SmoothingMode = SmoothingMode.AntiAlias;

            //绘制渐变背景
            Rectangle rect = new Rectangle(0, 0, image.Width, image.Height);
            Brush brushBack = new LinearGradientBrush(rect, Color.FromArgb(rand.Next(150, 256), 255, 255), Color.FromArgb(255, rand.Next(150, 256), 255), rand.Next(90));
            g.FillRectangle(brushBack, rect);

            //绘制干扰曲线
            for (int i = 0; i < 2; i++)
            {
                Point p1 = new Point(0, rand.Next(image.Height));
                Point p2 = new Point(rand.Next(image.Width), rand.Next(image.Height));
                Point p3 = new Point(rand.Next(image.Width), rand.Next(image.Height));
                Point p4 = new Point(image.Width, rand.Next(image.Height));
                Point[] p = { p1, p2, p3, p4 };
                Pen pen = new Pen(Color.Gray, 1);
                g.DrawBeziers(pen, p);
            }

            //逐个绘制文字
            for (int i = 0; i < str.Length; i++)
            {
                string strChar = str.Substring(i, 1);
                int deg = rand.Next(-15, 15);
                float x = (image.Width / str.Length / 2) + (image.Width / str.Length) * i;
                float y = image.Height / 2;
                //随机字体大小
                Font font = new Font("Consolas", rand.Next(16, 24), FontStyle.Regular);
                SizeF size = g.MeasureString(strChar, font);
                Matrix m = new Matrix();
                //旋转
                m.RotateAt(deg, new PointF(x, y), MatrixOrder.Append);
                //扭曲
                m.Shear(rand.Next(-10, 10) * 0.03f, 0);
                g.Transform = m;
                //随机渐变画笔
                Brush brushPen = new LinearGradientBrush(rect, Color.FromArgb(rand.Next(0, 256), 0, 0), Color.FromArgb(0, 0, rand.Next(0, 256)), rand.Next(90));
                g.DrawString(str.Substring(i, 1), font, brushPen, new PointF(x - size.Width / 2, y - size.Height / 2));

                g.Transform = new Matrix();
            }

            g.Save();
            g.Dispose();

            return image;
        }
开发者ID:huamouse,项目名称:Taoqi,代码行数:67,代码来源:VerificationCode.cs

示例12: Shear

        public static Color[,] Shear(Color[,] sourceBuffer, int oWidth, int oHeight)
        {
            Color[,] Buff;
               Buff = sourceBuffer;
               Matrix TrsMat = new Matrix();
               TrsMat.Shear(1, 0);

               Point[] mypoint = new Point[1];
               mypoint[0].X = 0;
               mypoint[0].Y = 0;
               TrsMat.TransformPoints(mypoint);
               int X0 = mypoint[0].X;
               int Y0 = mypoint[0].Y;
               mypoint[0].X = oWidth;
               mypoint[0].Y = 0;
               TrsMat.TransformPoints(mypoint);
               int X1 = mypoint[0].X;
               int Y1 = mypoint[0].Y;
               mypoint[0].X = 0;
               mypoint[0].Y = oHeight;
               TrsMat.TransformPoints(mypoint);
               int X2 = mypoint[0].X;
               int Y2 = mypoint[0].Y;
               mypoint[0].X = oWidth;
               mypoint[0].Y = oHeight;
               TrsMat.TransformPoints(mypoint);
               int X3 = mypoint[0].X;
               int Y3 = mypoint[0].Y;

               int MinX = Math.Min(X0, X1);
               MinX = Math.Min(MinX, X2);
               MinX = Math.Min(MinX, X3);

               int MinY = Math.Min(Y0, Y1);
               MinY = Math.Min(MinY, Y2);
               MinY = Math.Min(MinY, Y3);

               int MaxX = Math.Max(X0, X1);
               MaxX = Math.Max(MaxX, X2);
               MaxX = Math.Max(MaxX, X3);

               int MaxY = Math.Max(Y0, Y1);
               MaxY = Math.Max(MaxY, Y2);
               MaxY = Math.Max(MaxY, Y3);

               int nWidth = MaxX - MinX;
               int nHeight = MaxY - MinY;
               TrsMat.Translate(-MinX, -MinY);
               TrsMat.Invert();
               Buff = new Color[nWidth, nHeight];

               for (int i = 0; i < nHeight; i++)
               {
               for (int j = 0; j < nWidth; j++)
               {
                   mypoint[0].X = j;
                   mypoint[0].Y = i;
                   TrsMat.TransformPoints(mypoint);
                   if (mypoint[0].X < oWidth && mypoint[0].X >= 0 && mypoint[0].Y < oHeight && mypoint[0].Y >= 0)
                   {
                       Buff[j, i] = sourceBuffer[mypoint[0].X, mypoint[0].Y];
                   }
                   else
                   {
                       Buff[j, i] = Color.FromArgb(0);
                   }

               }
               }

               return Buff;
        }
开发者ID:IPTasks,项目名称:IP_TASK_1,代码行数:72,代码来源:Functions.cs

示例13: Shear

		public void Shear ()
		{
			Matrix matrix = new Matrix (10, 20, 30, 40, 50, 60);
			matrix.Shear (2, 4);

			Assert.AreEqual (130, matrix.Elements[0], "H#1");
			Assert.AreEqual (180, matrix.Elements[1], "H#2");
			Assert.AreEqual (50, matrix.Elements[2], "H#3");
			Assert.AreEqual (80, matrix.Elements[3], "H#4");
			Assert.AreEqual (50, matrix.Elements[4], "H#5");
			Assert.AreEqual (60, matrix.Elements[5], "H#6");
			
			matrix = new Matrix (5, 3, 9, 2, 2, 1);
			matrix.Shear  (10, 20);			
			
			Assert.AreEqual (185, matrix.Elements[0], "H#7");
			Assert.AreEqual (43, matrix.Elements[1], "H#8");
			Assert.AreEqual (59, matrix.Elements[2], "H#9");
			Assert.AreEqual (32, matrix.Elements[3], "H#10");
			Assert.AreEqual (2, matrix.Elements[4], "H#11");
			Assert.AreEqual (1, matrix.Elements[5], "H#12");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:22,代码来源:TestMatrix.cs

示例14: ProjectiveLetter

 void ProjectiveLetter()
 {
     try
     {
         Bitmap bmp = new Bitmap(300, 200);
         Graphics g = Graphics.FromImage(bmp);
         g.Clear(Color.White);
         g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;   //设置文本输出的质量
         g.SmoothingMode = SmoothingMode.AntiAlias;                  //消除绘制时出现的锯齿
         Font font = new Font("宋体", 48);
         Matrix martix = new Matrix();
         martix.Shear(-1.4F, 0.0F);                                  //设置投影
         martix.Scale(1, 0.5F);                                      //设置缩放
         martix.Translate(168, 118);                                 //设置平移
         g.Transform = martix;                                       //设置坐标平面变换
         SolidBrush wordBrush = new SolidBrush(Color.Gray);            //设置文字的画刷
         SolidBrush shadowBrush = new SolidBrush(Color.SlateBlue);       //设置投影的画刷
         string str = "Test";
         g.DrawString(str, font, wordBrush, new PointF(0, 60));
         g.ResetTransform();                                             //变换矩阵重置为单位矩阵
         g.DrawString(str, font, shadowBrush, new PointF(0, 60));
         MemoryStream ms = new MemoryStream();
         bmp.Save(ms, ImageFormat.Gif);
         Response.ClearContent();
         Response.ContentType = "image/Gif";
         Response.BinaryWrite(ms.ToArray());
     }
     catch (Exception ex)
     {
         Response.Write(ex.Message);
     }
 }
开发者ID:ZhuangChen,项目名称:CSharpBasicTraining,代码行数:32,代码来源:19.GDI+Application.aspx.cs

示例15: Transform_Matrix

		public void Transform_Matrix()
		{
			path = new GraphicsPath ();
			path.AddLine (new Point (100, 100), new Point (200, 100));
			path.AddLine (new Point (200, 200), new Point (10, 100));

			path.StartFigure();
			path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
			path.StartFigure();
			path.AddRectangle (new Rectangle (10, 20, 200, 200));

			path.StartFigure();
			path.AddLine (new Point (200, 200), new Point (200, 10));

			Matrix matrix = new Matrix ();
			matrix.Scale (1.2f, 1.4f);
			matrix.Shear (0.9f, -1.15f);
			matrix.Rotate (5);

			path.Transform (matrix);

			PointF [] expectedPoints = new PointF [] {	new PointF(226.0865f, 5.313778f), 
														new PointF(355.0427f, -142.8718f), 
														new PointF(452.173f, 10.62756f), 
														new PointF(110.0259f, 138.6808f), 
														new PointF(22.60865f, 0.5313778f), 
														new PointF(307.3039f, 309.6555f), 
														new PointF(133.8127f, -140.5106f), 
														new PointF(529.8773f, 133.427f), 
														new PointF(32.32168f, 15.88131f), 
														new PointF(290.234f, -280.4898f), 
														new PointF(484.4947f, 26.50887f), 
														new PointF(226.5823f, 322.8799f), 
														new PointF(452.173f, 10.62756f), 
														new PointF(267.6254f, -281.0212f)};
			
			for(int i = 0; i < path.PointCount; i++) {
				DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
			}

			byte [] expectedTypes = new byte [] {	(byte) PathPointType.Start, 
													(byte) PathPointType.Line, 
													(byte) PathPointType.Line, 
													(byte) PathPointType.Line, 
													(byte) PathPointType.Start, 
													(byte) PathPointType.Bezier3, 
													(byte) PathPointType.Bezier3, 
													(byte) PathPointType.Bezier3, 
													(byte) PathPointType.Start, 
													(byte) PathPointType.Line, 
													(byte) PathPointType.Line, 
													(byte) (PathPointType.Line  |  PathPointType.CloseSubpath), 
													(byte) PathPointType.Start, 
													(byte) PathPointType.Line};

			for (int i=0; i < expectedTypes.Length; i++) {
				Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
			}	

			t.Graphics.DrawPath (p, path);
			t.Show ();
			//t.AssertCompare ();
		}
开发者ID:nlhepler,项目名称:mono,代码行数:63,代码来源:GraphicsPath.cs


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