TranslateClip() public method

public TranslateClip ( float dx, float dy ) : void
dx float
dy float
return void
        public void TranslateClip(Graphics g)
        {
            Pen myPen = new Pen(Color.FromArgb(196, 0xC3, 0xC9, 0xCF), (float)0.6);
            SolidBrush myBrush = new SolidBrush(Color.FromArgb(127, 0xDD, 0xDD, 0xF0));

            // Create the first rectangle and draw it to the screen in blue.
            Rectangle regionRect = new Rectangle(100, 50, 100, 100);
            g.DrawRectangle(myPen, regionRect);
            g.FillRectangle (myBrush, regionRect);

            // Create a region using the first rectangle.
            Region myRegion = new Region(regionRect);

            g.Clip = myRegion;

            // Apply the translation to the region.
            g.TranslateClip(150, 100);

            // Fill the transformed region with red and draw it to the screen in red.
            myBrush.Color = Color.FromArgb(127, 0x66, 0xEF, 0x7F);
            myPen.Color = Color.FromArgb(255, 0, 0x33, 0);
            g.FillRectangle(myBrush, new Rectangle(0,0,500,500) );
        }
        void DrawImageTranslateClip(Graphics g)
        {
            // Create rectangle for clipping region.
            var clipRect = new Rectangle (0, 0, 100, 100);

            // Set clipping region of graphics to rectangle.
            g.SetClip (clipRect);

            // Translate clipping region.
            int dx = 50;
            int dy = 50;
            g.TranslateClip (dx, dy);

            // Fill rectangle to demonstrate translated clip region.
            g.FillRectangle (new SolidBrush (Color.Black), 0, 0, 500, 300);
            title = "DrawImageTranslateClip";
        }
Esempio n. 3
0
 public static void Clip(Graphics g, int time, IGraph graph)
 {
     ClipPath path1 = graph.ClipPath;
     if ((path1 != null) && path1.ShowClip)
     {
         GraphicsPath path2 = path1.GetGraphicsPath(g, time);
         if (path1.ClipPathUnit == Units.ObjectBoundingBox)
         {
             GraphicsPath path3 = (GraphicsPath) graph.GPath.Clone();
             RectangleF ef1 = path3.GetBounds();
             float single1 = ef1.Left;
             RectangleF ef2 = path3.GetBounds();
             float single2 = ef2.Top;
             RectangleF ef3 = path3.GetBounds();
             float single3 = ef3.Width;
             RectangleF ef4 = path3.GetBounds();
             float single4 = ef4.Height;
             Matrix matrix1 = new Matrix();
             matrix1.Scale(single3, single4);
             path2.Transform(matrix1);
             g.SetClip(path2, CombineMode.Intersect);
             g.TranslateClip(single1, single2);
         }
         else
         {
             g.SetClip(path2, CombineMode.Intersect);
         }
     }
 }