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


C# LinearGradientBrush.TranslateTransform方法代码示例

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


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

示例1: Transform_Operations_OnScalableAngle

		public void Transform_Operations_OnScalableAngle ()
		{
			LinearGradientBrush lgb = new LinearGradientBrush (rect, c1, c2, 360f, true);
			Matrix clone = lgb.Transform.Clone ();
			Matrix mul = clone.Clone ();
			Matrix m = new Matrix ();
			m.Scale (2, 1);
			m.Translate (rect.Width, rect.Height);
			m.Rotate (30f);

			clone.Multiply (mul, MatrixOrder.Append);
			lgb.MultiplyTransform (mul, MatrixOrder.Append);
			Assert.AreEqual (lgb.Transform, clone, "Multiply/Append");

			clone.Multiply (mul, MatrixOrder.Prepend);
			lgb.MultiplyTransform (mul, MatrixOrder.Prepend);
			Assert.AreEqual (lgb.Transform, clone, "Multiply/Prepend");

			clone.Rotate (45, MatrixOrder.Append);
			lgb.RotateTransform (45, MatrixOrder.Append);
			Assert.AreEqual (lgb.Transform, clone, "Rotate/Append");

			clone.Rotate (45, MatrixOrder.Prepend);
			lgb.RotateTransform (45, MatrixOrder.Prepend);
			Assert.AreEqual (lgb.Transform, clone, "Rotate/Prepend");

			clone.Scale (0.25f, 2, MatrixOrder.Append);
			lgb.ScaleTransform (0.25f, 2, MatrixOrder.Append);
			Assert.AreEqual (lgb.Transform, clone, "Scale/Append");

			clone.Scale (0.25f, 2, MatrixOrder.Prepend);
			lgb.ScaleTransform (0.25f, 2, MatrixOrder.Prepend);
			Assert.AreEqual (lgb.Transform, clone, "Scale/Prepend");

			clone.Translate (10, 20, MatrixOrder.Append);
			lgb.TranslateTransform (10, 20, MatrixOrder.Append);
			Assert.AreEqual (lgb.Transform, clone, "Translate/Append");

			clone.Translate (30, 40, MatrixOrder.Prepend);
			lgb.TranslateTransform (30, 40, MatrixOrder.Prepend);
			Assert.AreEqual (lgb.Transform, clone, "Translate/Prepend");

			clone.Reset ();
			lgb.ResetTransform ();
			Assert.AreEqual (lgb.Transform, clone, "Reset");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:46,代码来源:LinearGradientBrushTest.cs

示例2: PaintView2

        void PaintView2(Graphics g)
        {
            // Create a LinearGradientBrush.
            Rectangle myRect = new Rectangle(20, 20, 200, 100);
            LinearGradientBrush myLGBrush = new LinearGradientBrush(
                myRect, Color.Blue, Color.Red,  0.0f, true);

            // Draw an ellipse to the screen using the LinearGradientBrush.
            g.FillEllipse(myLGBrush, myRect);

            // Rotate the LinearGradientBrush.
            myLGBrush.RotateTransform(45.0f, MatrixOrder.Prepend);

            // Rejustify the brush to start at the left edge of the ellipse.
            myLGBrush.TranslateTransform(-100.0f, 0.0f);

            // Draw a second ellipse to the screen using
            // the transformed brush.
            g.FillEllipse(myLGBrush, 20, 150, 200, 100);

            title = "PaintView2";
        }
开发者ID:mono,项目名称:sysdrawing-coregraphics,代码行数:22,代码来源:DrawingView.cs

示例3: TranslateTransform_InvalidOrder

		public void TranslateTransform_InvalidOrder ()
		{
			LinearGradientBrush lgb = new LinearGradientBrush (pt1, pt2, c1, c2);
			lgb.TranslateTransform (1, 1, (MatrixOrder) Int32.MinValue);
		}
开发者ID:nlhepler,项目名称:mono,代码行数:5,代码来源:LinearGradientBrushTest.cs

示例4: Transform_Operations

		public void Transform_Operations ()
		{
			LinearGradientBrush lgb = new LinearGradientBrush (rect, c1, c2, 45f);
			Matrix clone = lgb.Transform.Clone ();
			Matrix mul = clone.Clone ();

			clone.Multiply (mul, MatrixOrder.Append);
			lgb.MultiplyTransform (mul, MatrixOrder.Append);
			Assert.AreEqual (lgb.Transform, clone, "Multiply/Append");

			clone.Multiply (mul, MatrixOrder.Prepend);
			lgb.MultiplyTransform (mul, MatrixOrder.Prepend);
			Assert.AreEqual (lgb.Transform, clone, "Multiply/Prepend");

			clone.Rotate (45, MatrixOrder.Append);
			lgb.RotateTransform (45, MatrixOrder.Append);
			Assert.AreEqual (lgb.Transform, clone, "Rotate/Append");

			clone.Rotate (45, MatrixOrder.Prepend);
			lgb.RotateTransform (45, MatrixOrder.Prepend);
			Assert.AreEqual (lgb.Transform, clone, "Rotate/Prepend");

			clone.Scale (0.25f, 2, MatrixOrder.Append);
			lgb.ScaleTransform (0.25f, 2, MatrixOrder.Append);
			Assert.AreEqual (lgb.Transform, clone, "Scale/Append");

			clone.Scale (0.25f, 2, MatrixOrder.Prepend);
			lgb.ScaleTransform (0.25f, 2, MatrixOrder.Prepend);
			Assert.AreEqual (lgb.Transform, clone, "Scale/Prepend");

			clone.Translate (10, 20, MatrixOrder.Append);
			lgb.TranslateTransform (10, 20, MatrixOrder.Append);
			Assert.AreEqual (lgb.Transform, clone, "Translate/Append");

			clone.Translate (30, 40, MatrixOrder.Prepend);
			lgb.TranslateTransform (30, 40, MatrixOrder.Prepend);
			Assert.AreEqual (lgb.Transform, clone, "Translate/Prepend");

			clone.Reset ();
			lgb.ResetTransform ();
			Assert.AreEqual (lgb.Transform, clone, "Reset");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:42,代码来源:LinearGradientBrushTest.cs

示例5: TranslateTransform

		public void TranslateTransform ()
		{
			LinearGradientBrush lgb = new LinearGradientBrush (rect, c1, c2, 0f);
			lgb.TranslateTransform (1, 1);
			float[] elements = lgb.Transform.Elements;
			Assert.AreEqual (1, elements[0], 0.1, "matrix.0");
			Assert.AreEqual (0, elements[1], 0.1, "matrix.1");
			Assert.AreEqual (0, elements[2], 0.1, "matrix.2");
			Assert.AreEqual (1, elements[3], 0.1, "matrix.3");
			Assert.AreEqual (1, elements[4], 0.1, "matrix.4");
			Assert.AreEqual (1, elements[5], 0.1, "matrix.5");

			lgb.TranslateTransform (-1, -1);
			// strangely lgb.Transform.IsIdentity is false
			elements = lgb.Transform.Elements;
			Assert.AreEqual (1, elements[0], 0.1, "revert.matrix.0");
			Assert.AreEqual (0, elements[1], 0.1, "revert.matrix.1");
			Assert.AreEqual (0, elements[2], 0.1, "revert.matrix.2");
			Assert.AreEqual (1, elements[3], 0.1, "revert.matrix.3");
			Assert.AreEqual (0, elements[4], 0.1, "revert.matrix.4");
			Assert.AreEqual (0, elements[5], 0.1, "revert.matrix.5");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:22,代码来源:LinearGradientBrushTest.cs

示例6: Rectangle

		public void Rectangle ()
		{
			LinearGradientBrush lgb = new LinearGradientBrush (rect, c1, c2, 0f);
			CheckDefaultRectangle ("Original", lgb.Rectangle);
			lgb.MultiplyTransform (new Matrix (2, 0, 0, 2, 2, 2));
			CheckDefaultRectangle ("Multiply", lgb.Rectangle);
			lgb.ResetTransform ();
			CheckDefaultRectangle ("Reset", lgb.Rectangle);
			lgb.RotateTransform (90);
			CheckDefaultRectangle ("Rotate", lgb.Rectangle);
			lgb.ScaleTransform (4, 0.25f);
			CheckDefaultRectangle ("Scale", lgb.Rectangle);
			lgb.TranslateTransform (-10, -20);
			CheckDefaultRectangle ("Translate", lgb.Rectangle);

			lgb.SetBlendTriangularShape (0.5f);
			CheckDefaultRectangle ("SetBlendTriangularShape", lgb.Rectangle);
			lgb.SetSigmaBellShape (0.5f);
			CheckDefaultRectangle ("SetSigmaBellShape", lgb.Rectangle);
		}
开发者ID:nlhepler,项目名称:mono,代码行数:20,代码来源:LinearGradientBrushTest.cs

示例7: DrawShadowBitmap

        public static Bitmap DrawShadowBitmap(int width, int height, int borderRadius, int blur, int spread, Color color)
        {
            int ex = blur + spread;
            int w = width + ex * 2;
            int h = height + ex * 2;
            int solidW = width + spread * 2;
            int solidH = height + spread * 2;

            var bitmap = new Bitmap(w, h);
            Graphics g = Graphics.FromImage(bitmap);
            // fill background
            g.FillRectangle(new SolidBrush(color)
                , blur, blur, width + spread * 2 + 1, height + spread * 2 + 1);
            // +1 to fill the gap

            if (blur > 0)
            {
                // four dir gradiant
                {
                    // left
                    var brush = new LinearGradientBrush(new Point(0, 0), new Point(blur, 0), Color.Transparent, color);
                    // will thorw ArgumentException
                    // brush.WrapMode = WrapMode.Clamp;

                    g.FillRectangle(brush, 0, blur, blur, solidH);
                    // up
                    brush.RotateTransform(90);
                    g.FillRectangle(brush, blur, 0, solidW, blur);

                    // right
                    // make sure parttern is currect
                    brush.ResetTransform();
                    brush.TranslateTransform(w % blur, h % blur);

                    brush.RotateTransform(180);
                    g.FillRectangle(brush, w - blur, blur, blur, solidH);
                    // down
                    brush.RotateTransform(90);
                    g.FillRectangle(brush, blur, h - blur, solidW, blur);
                }

                // four corner
                {
                    var gp = new GraphicsPath();
                    //gp.AddPie(0,0,blur*2,blur*2, 180, 90);
                    gp.AddEllipse(0, 0, blur * 2, blur * 2);

                    var pgb = new PathGradientBrush(gp);
                    pgb.CenterColor = color;
                    pgb.SurroundColors = new[] { Color.Transparent };
                    pgb.CenterPoint = new Point(blur, blur);

                    // lt
                    g.FillPie(pgb, 0, 0, blur * 2, blur * 2, 180, 90);
                    // rt
                    var matrix = new Matrix();
                    matrix.Translate(w - blur * 2, 0);

                    pgb.Transform = matrix;
                    //pgb.Transform.Translate(w-blur*2, 0);
                    g.FillPie(pgb, w - blur * 2, 0, blur * 2, blur * 2, 270, 90);
                    // rb
                    matrix.Translate(0, h - blur * 2);
                    pgb.Transform = matrix;
                    g.FillPie(pgb, w - blur * 2, h - blur * 2, blur * 2, blur * 2, 0, 90);
                    // lb
                    matrix.Reset();
                    matrix.Translate(0, h - blur * 2);
                    pgb.Transform = matrix;
                    g.FillPie(pgb, 0, h - blur * 2, blur * 2, blur * 2, 90, 90);
                }
            }

            //
            return bitmap;
        }
开发者ID:tranxuanloc,项目名称:Calculator,代码行数:76,代码来源:Dropshadow.cs

示例8: RenderBackgroundGradient

       // renders the overall gradient
       private void RenderBackgroundGradient(Graphics g, Control control, Color beginColor, Color endColor, Orientation orientation) {
       
          if (control.RightToLeft == RightToLeft.Yes) {
              Color temp = beginColor;
              beginColor = endColor;
              endColor = temp;
          }
 
          if (orientation == Orientation.Horizontal) {
              Control parent = control.ParentInternal;
              if (parent != null) {
                  Rectangle gradientBounds = new Rectangle(Point.Empty, parent.Size);
                  if (!LayoutUtils.IsZeroWidthOrHeight(gradientBounds)) {
                      using (LinearGradientBrush b = new LinearGradientBrush(gradientBounds, beginColor, endColor, LinearGradientMode.Horizontal)){
                          b.TranslateTransform(parent.Width - control.Location.X, parent.Height -control.Location.Y);
                          g.FillRectangle(b, new Rectangle(Point.Empty, control.Size));
                      }
                  }
              }
              else {
                  Rectangle gradientBounds = new Rectangle(Point.Empty, control.Size);
                  if (!LayoutUtils.IsZeroWidthOrHeight(gradientBounds)) {
                      // dont have a parent that we know about so go ahead and paint the gradient as if there wasnt another container.
                      using (LinearGradientBrush b = new LinearGradientBrush(gradientBounds, beginColor, endColor, LinearGradientMode.Horizontal)){
                          g.FillRectangle(b, gradientBounds);
                      }
                  }
              }
          }
          else {
              using (Brush b = new SolidBrush(beginColor)) {
                  g.FillRectangle(b, new Rectangle(Point.Empty, control.Size));
              }
          }
      }
开发者ID:JianwenSun,项目名称:cc,代码行数:36,代码来源:ToolstripProfessionalRenderer.cs

示例9: RenderBackgroundGradient

 private void RenderBackgroundGradient( Graphics g, Control control, Color beginColor, Color endColor, Orientation orientation )
 {
     if ( control.RightToLeft == RightToLeft.Yes ) {
         Color color = beginColor;
         beginColor = endColor;
         endColor = color;
     }
     if ( orientation == Orientation.Horizontal ) {
         Control parent = control.Parent;
         if ( parent != null ) {
             Rectangle rectangle = new Rectangle ( Point.Empty, parent.Size );
             if ( rectangle.IsEmpty ) {
                 return;
             }
             using ( LinearGradientBrush brush = new LinearGradientBrush ( rectangle, beginColor, endColor, LinearGradientMode.Horizontal ) ) {
                 brush.TranslateTransform ( (float)( parent.Width - control.Location.X ), (float)( parent.Height - control.Location.Y ) );
                 g.FillRectangle ( brush, new Rectangle ( Point.Empty, control.Size ) );
                 return;
             }
         }
         Rectangle rectangle2 = new Rectangle ( Point.Empty, control.Size );
         if ( rectangle2.IsEmpty ) {
             return;
         }
         using ( LinearGradientBrush brush2 = new LinearGradientBrush ( rectangle2, beginColor, endColor, LinearGradientMode.Horizontal ) ) {
             g.FillRectangle ( brush2, rectangle2 );
             return;
         }
     }
     using ( Brush brush3 = new SolidBrush ( beginColor ) ) {
         g.FillRectangle ( brush3, new Rectangle ( Point.Empty, control.Size ) );
     }
 }
开发者ID:camalot,项目名称:droidexplorer,代码行数:33,代码来源:MainForm.cs


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