Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class MatrixTranslationDemo
public Shared Sub Main
Application.Run(New TranslationForm)
End Sub
End class
Public Class TranslationForm
Inherits System.Windows.Forms.Form
Public Sub New()
MyBase.New()
End Sub
Sub TranlationForm_Pain(ByVal sender As Object, ByVal e As PaintEventArgs) Handles MyBase.Paint
Dim g As Graphics = e.Graphics
Dim rect As RectangleF = New RectangleF(0, 0, 125, 125)
g.FillRectangle(Brushes.White, rect)
g.DrawRectangle(Pens.Black, rect.X, rect.Y, rect.Width, rect.Height)
Dim matrix As Matrix = New Matrix()
matrix.Translate(150, 150)
g.Transform = matrix
g.FillRectangle(Brushes.White, rect)
g.DrawRectangle(Pens.Black, rect.X, rect.Y, rect.Width, rect.Height)
End Sub
End Class
|