Matrix.Translate(Int x, Int y) : Matrix « System.Drawing.Drawing2D « VB.Net by API






Matrix.Translate(Int x, Int y)

  
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

   
    
  








Related examples in the same category

1.Matrix.Elements
2.Matrix.Invert
3.Matrix.Multiply
4.Matrix.Rotate
5.Matrix.RotateAt
6.Matrix.Shear
7.Matrix.TransformPoints