Mega Code Archive

 
Categories / VB.Net Tutorial / 2D Graphics
 

Graphics ResetClip

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class ResetClip    public Shared Sub Main         Application.Run(New Form1)    End Sub End class public class Form1   Inherits System.Windows.Forms.Form   Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)         Dim g As Graphics = Graphics.FromHwnd(Me.Handle)         g.Clear(Me.BackColor)         Dim clipRect As New Rectangle(0, 0, 200, 200)         g.SetClip(clipRect)         Dim intersectRectF As New RectangleF(100.0F, 100.0F, 200.0F, 200.0F)         g.IntersectClip(intersectRectF)         g.FillRectangle(New SolidBrush(Color.Blue), 0, 0, 500, 500)         g.ResetClip()         g.DrawRectangle(New Pen(Color.Black), clipRect)         g.DrawRectangle(New Pen(Color.Red), Rectangle.Round(intersectRectF))   End Sub   Public Sub New()         MyBase.New()     Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)     Me.ClientSize = New System.Drawing.Size(292, 273)     Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen   End Sub End Class