VB.Net Tutorial/2D Graphics/LinearGradientBrush — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 12:54, 26 мая 2010
Содержание
- 1 A diagonal brush
- 2 Blend Properties
- 3 Change the LinearGradientBrush"s WrapMode
- 4 Create a LinearGradientBrush
- 5 Interpolation Colors
- 6 LinearGradientBrush Blend
- 7 LinearGradientBrush ColorBlend
- 8 LinearGradientBrush.GammaCorrection
- 9 LinearGradientBrush: InterpolationColors
- 10 LinearGradientBrush.SetBlendTriangular
- 11 LinearGradientBrush.SetSigmaBellShape
- 12 LinearGradientBrush: too short to cross the whole rectangle
- 13 Make a rectangle that shades from black to white
- 14 Set Blend Triangular Shape for LinearGradientBrush
- 15 Set Sigma Bell Shape
- 16 Trangular brush
- 17 Transform LinearGradientBrush
A diagonal brush
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class LinearGradientBrushesDiagonalBrush
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 y As Integer = 10
Dim x As Integer = 10
Dim wid As Integer = 200
Dim hgt As Integer = 50
Dim diag_brush As New LinearGradientBrush(New Point(x, y), New Point(x + wid, y + hgt),Color.Black, Color.White)
e.Graphics.FillRectangle(diag_brush, x, y, wid, hgt)
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
Blend Properties
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class BlendProp
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 = Me.CreateGraphics()
g.Clear(Me.BackColor)
Dim brBrush As New LinearGradientBrush(New Point(0, 0), New Point(50, 20), Color.Blue, Color.Red)
Dim blend As New Blend
Dim factArray As Single() = {0.0F, 0.3F, 0.5F, 1.0F}
Dim posArray As Single() = {0.0F, 0.2F, 0.6F, 1.0F}
blend.Factors = factArray
blend.Positions = posArray
brBrush.Blend = blend
g.FillRectangle(brBrush, 10, 20, 200, 100)
g.FillEllipse(brBrush, 10, 150, 120, 120)
g.Dispose()
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
Change the LinearGradientBrush"s WrapMode
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class LinearGradientBrushesWrapModeTileFlipX
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 y As Integer = 10
Dim x As Integer = 10
Dim wid As Integer = 200
Dim hgt As Integer = 50
Dim short_brush As New LinearGradientBrush(New Point(x, y), New Point(x + 50, y),Color.Black, Color.White)
short_brush.WrapMode = WrapMode.TileFlipX
e.Graphics.FillRectangle(short_brush, x, y, wid, hgt)
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
Create a LinearGradientBrush
Imports System
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Collections
Imports System.ruponentModel
Imports System.Windows.Forms
Imports System.Data
public class LinearGradientBrushCreate
public Shared Sub Main
Application.Run(New BrushesForm)
End Sub
End class
Public Class BrushesForm
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
"This call is required by the Windows Form Designer.
InitializeComponent()
"Add any initialization after the InitializeComponent() call
End Sub
"Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
"Required by the Windows Form Designer
Private components As System.ruponentModel.IContainer
"NOTE: The following procedure is required by the Windows Form Designer
"It can be modified using the Windows Form Designer.
"Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
"
"BrushesForm
"
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Name = "BrushesForm"
Me.Text = "Form1"
End Sub
#End Region
Enum LinearGradientMode
BackwardDiagonal
ForwardDiagonal
Horizontal
Vertical
End Enum
Private Sub BrushesForm_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles MyBase.Paint
Dim g As Graphics = e.Graphics
Dim width As Integer = Me.ClientRectangle.Width
Dim height As Integer = Me.ClientRectangle.Height / 5
Dim whiteBrush As Brush = System.Drawing.Brushes.White
Dim blackBrush As Brush = System.Drawing.Brushes.Black
Dim b As Brush
b = New LinearGradientBrush(New Rectangle(0,0, width, height), Color.DarkBlue, Color.White, 45)
g.FillRectangle(b, 0, 0, width, height)
g.DrawString(b.ToString(), Me.Font, whiteBrush, 0, 0)
End Sub
End Class
Interpolation Colors
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class InterpolationColors
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 = Me.CreateGraphics()
g.Clear(Me.BackColor)
Dim brBrush As New LinearGradientBrush(New Point(0, 0), New Point(50, 20), Color.Blue, Color.Red)
Dim rect As New Rectangle(0, 0, 200, 100)
Dim clrArray As Color() = {Color.Red, Color.Blue, Color.Green, Color.Pink, Color.Yellow, Color.DarkTurquoise}
Dim posArray As Single() = {0.0F, 0.2F, 0.4F, 0.6F, 0.8F, 1.0F}
Dim colorBlend As New ColorBlend
colorBlend.Colors = clrArray
colorBlend.Positions = posArray
brBrush.InterpolationColors = colorBlend
g.FillRectangle(brBrush, rect)
rect.Y = 150
rect.Width = 100
rect.Height = 100
g.FillEllipse(brBrush, rect)
g.Dispose()
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
LinearGradientBrush Blend
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class LinearGradientBrushesColorBlend
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 y As Integer = 10
Dim x As Integer = 10
Dim wid As Integer = 200
Dim hgt As Integer = 50
" Make a rectangle that shades from black to white.
Dim black_white_brush As New LinearGradientBrush(New Point(x, y), New Point(x + wid, y),Color.Black, Color.White)
" Make a brush that makes 50 percent of the color change
" in the first 20 percent of the distance, stays there
" until 80 percent of the distance, and then finishes
" in the remaining distance.
Dim the_blend As New Blend(4)
the_blend.Factors = New Single() {0.0, 0.5, 0.5, 1.0}
the_blend.Positions = New Single() {0.0, 0.2, 0.8, 1.0}
black_white_brush.Blend = the_blend
e.Graphics.FillRectangle(black_white_brush, x, y, wid, hgt)
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
LinearGradientBrush ColorBlend
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class LinearGradientBrushesColorBlend
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 y As Integer = 10
Dim x As Integer = 10
Dim wid As Integer = 200
Dim hgt As Integer = 50
" Make a rectangle that shades from black to white.
Dim black_white_brush As New LinearGradientBrush(New Point(x, y), New Point(x + wid, y),Color.Black, Color.White)
Dim color_blend As New ColorBlend(3)
color_blend.Colors = New Color() {Color.Black, Color.White, Color.Black}
color_blend.Positions = New Single() {0.0, 0.2, 1.0}
black_white_brush.InterpolationColors = color_blend
e.Graphics.FillRectangle(black_white_brush, x, y, wid, hgt)
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
LinearGradientBrush.GammaCorrection
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class GammaCorrection
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 = Me.CreateGraphics()
g.Clear(Me.BackColor)
Dim rect As New Rectangle(20, 20, 100, 50)
Dim rgBrush As New LinearGradientBrush(rect, Color.Red, Color.Green, 0.0F, True)
g.FillRectangle(rgBrush, rect)
rect.Y = 90
rgBrush.GammaCorrection = True
g.FillRectangle(rgBrush, rect)
g.Dispose()
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
LinearGradientBrush: InterpolationColors
Imports System.Drawing.Text
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class LinearGradientInterpolationColors
public Shared Sub Main
Application.Run(New LinearGradientBrushesForm)
End Sub
End class
Public Class LinearGradientBrushesForm
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
"This call is required by the Windows Form Designer.
InitializeComponent()
"Add any initialization after the InitializeComponent() call
End Sub
"Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
"Required by the Windows Form Designer
Private components As System.ruponentModel.IContainer
"NOTE: The following procedure is required by the Windows Form Designer
"It can be modified using the Windows Form Designer.
"Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
components = New System.ruponentModel.Container()
Me.Text = "LinearGradientBrushesForm"
End Sub
#End Region
Private Sub LinearGradientBrushesForm_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles MyBase.Paint
Dim g As Graphics = e.Graphics
Dim x As Integer = 0
Dim y As Integer = 0
Dim width As Integer = Me.ClientRectangle.Width
Dim height As Integer = Me.ClientRectangle.Height / 4
Dim blackBrush As Brush = Brushes.Black
Dim b As LinearGradientBrush = New LinearGradientBrush(Me.ClientRectangle, Color.White, Color.Black, LinearGradientMode.Horizontal)
Dim blend As ColorBlend = New ColorBlend()
blend.Colors = New Color() {Color.White, Color.Red, Color.Black}
blend.Positions = New Single() {0.0, 0.5, 1.0}
b.InterpolationColors = blend
g.FillRectangle(b, x, y, width, height)
g.DrawString("Custom Colors", Me.Font, blackBrush, x, y)
End Sub
End Class
LinearGradientBrush.SetBlendTriangular
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class SetBlendTriangular
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 = Me.CreateGraphics()
g.Clear(Me.BackColor)
Dim rect As New Rectangle(20, 20, 100, 50)
Dim rgBrush As New LinearGradientBrush(rect, Color.Red, Color.Green, 0.0F, True)
g.FillRectangle(rgBrush, rect)
rect.Y = 90
rgBrush.SetBlendTriangularShape(0.5F, 1.0F)
g.FillRectangle(rgBrush, rect)
g.Dispose()
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
LinearGradientBrush.SetSigmaBellShape
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class SetSigmaBellShape
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 = Me.CreateGraphics()
g.Clear(Me.BackColor)
Dim rect As New Rectangle(20, 20, 100, 50)
Dim rgBrush As New LinearGradientBrush(rect, Color.Red, Color.Green, 0.0F, True)
g.FillRectangle(rgBrush, rect)
rect.Y = 90
rgBrush.SetSigmaBellShape(0.5F, 1.0F)
g.FillRectangle(rgBrush, rect)
" Dispose
g.Dispose()
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
LinearGradientBrush: too short to cross the whole rectangle
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class LinearGradientBrushesShort
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 y As Integer = 10
Dim x As Integer = 10
Dim wid As Integer = 200
Dim hgt As Integer = 50
Dim short_brush As New LinearGradientBrush(New Point(x, y), New Point(x + 50, y),Color.Black, Color.White)
e.Graphics.FillRectangle(short_brush, x, y, wid, hgt)
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
Make a rectangle that shades from black to white
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class LinearGradientBrushesSimple
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 y As Integer = 10
Dim x As Integer = 10
Dim wid As Integer = 200
Dim hgt As Integer = 50
" Make a rectangle that shades from black to white.
e.Graphics.DrawString("Simple", Me.Font, Brushes.Black, x, y)
y += 15
Dim black_white_brush As New _
LinearGradientBrush( _
New Point(x, y), New Point(x + wid, y), _
Color.Black, Color.White)
e.Graphics.FillRectangle(black_white_brush, 10,50,200,200)
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
Set Blend Triangular Shape for LinearGradientBrush
Imports System.Drawing.Text
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class LinearGradientSetBlendTriangularShape
public Shared Sub Main
Application.Run(New LinearGradientBrushesForm)
End Sub
End class
Public Class LinearGradientBrushesForm
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
"This call is required by the Windows Form Designer.
InitializeComponent()
"Add any initialization after the InitializeComponent() call
End Sub
"Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
"Required by the Windows Form Designer
Private components As System.ruponentModel.IContainer
"NOTE: The following procedure is required by the Windows Form Designer
"It can be modified using the Windows Form Designer.
"Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
components = New System.ruponentModel.Container()
Me.Text = "LinearGradientBrushesForm"
End Sub
#End Region
Private Sub LinearGradientBrushesForm_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles MyBase.Paint
Dim g As Graphics = e.Graphics
Dim x As Integer = 0
Dim y As Integer = 0
Dim width As Integer = Me.ClientRectangle.Width
Dim height As Integer = Me.ClientRectangle.Height / 4
Dim blackBrush As Brush = Brushes.Black
Dim b As LinearGradientBrush = New LinearGradientBrush(Me.ClientRectangle, Color.White, Color.Black, LinearGradientMode.Horizontal)
b.SetBlendTriangularShape(0.5)
g.FillRectangle(b, x, y, width, height)
g.DrawString("Triangle", Me.Font, blackBrush, x, y)
End Sub
End Class
Set Sigma Bell Shape
Imports System.Drawing.Text
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class LinearGradientSetSigmaBellShape
public Shared Sub Main
Application.Run(New LinearGradientBrushesForm)
End Sub
End class
Public Class LinearGradientBrushesForm
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
"This call is required by the Windows Form Designer.
InitializeComponent()
"Add any initialization after the InitializeComponent() call
End Sub
"Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
"Required by the Windows Form Designer
Private components As System.ruponentModel.IContainer
"NOTE: The following procedure is required by the Windows Form Designer
"It can be modified using the Windows Form Designer.
"Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
components = New System.ruponentModel.Container()
Me.Text = "LinearGradientBrushesForm"
End Sub
#End Region
Private Sub LinearGradientBrushesForm_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles MyBase.Paint
Dim g As Graphics = e.Graphics
Dim x As Integer = 0
Dim y As Integer = 0
Dim width As Integer = Me.ClientRectangle.Width
Dim height As Integer = Me.ClientRectangle.Height / 4
Dim blackBrush As Brush = Brushes.Black
Dim b As LinearGradientBrush = New LinearGradientBrush(Me.ClientRectangle, Color.White, Color.Black, LinearGradientMode.Horizontal)
b.SetSigmaBellShape(0.5)
g.FillRectangle(b, x, y, width, height)
g.DrawString("Bell", Me.Font, blackBrush, x, y)
End Sub
End Class
Trangular brush
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class LinearGradientBrushesSetBlendTriangularShape
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 y As Integer = 10
Dim x As Integer = 10
Dim wid As Integer = 200
Dim hgt As Integer = 50
" Make a rectangle that shades from black to white.
Dim black_white_brush As New LinearGradientBrush(New Point(x, y), New Point(x + wid, y),Color.Black, Color.White)
black_white_brush.SetBlendTriangularShape(0.5)
e.Graphics.FillRectangle(black_white_brush,x, y, wid, hgt)
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
Transform LinearGradientBrush
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class TransformLinearGradientBrush
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 = Me.CreateGraphics()
g.Clear(Me.BackColor)
" Create a LinearGradientBrush object
Dim rect As New Rectangle(20, 20, 200, 100)
Dim lgBrush As New LinearGradientBrush(rect, Color.Red, Color.Green, 0.0F, True)
Dim ptsArray As Point() = {New Point(20, 50), New Point(200, 50), New Point(20, 100)}
Dim M As New Matrix(rect, ptsArray)
" Multiply transform
lgBrush.MultiplyTransform(M, MatrixOrder.Prepend)
" Rotate transform
lgBrush.RotateTransform(45.0F, MatrixOrder.Prepend)
" Scale Transform
lgBrush.ScaleTransform(2, 1, MatrixOrder.Prepend)
" Draw a rectangle after transformation
g.FillRectangle(lgBrush, 0, 0, 200, 100)
" Reset transform.
lgBrush.ResetTransform()
" Draw a rectangle after Reset transform
g.FillRectangle(lgBrush, 220, 0, 200, 100)
" Dispose
lgBrush.Dispose()
g.Dispose()
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