Tác giả: 1045007
Mô tả: Xoay theo 1 góc quanh 1 điểm chỉ định. Trong bài là xoay 1 elip tại tâm của nó.
Mã: Chọn hết
- Imports System.Drawing.Imaging
- Imports System.Drawing
- Imports System.Drawing.Drawing2D
-
- Dim gp As Graphics
-
- Private Sub VeElip(ByVal x As Integer, ByVal y As Integer, ByVal w As Integer, ByVal h As Integer)
- 'Khai bao 1 cai thung chua cai can ve
- Dim con As GraphicsContainer
- con = gp.BeginContainer()
- 've 6 cai
- For i As Short = 1 To 6
- con = gp.BeginContainer()
- Dim rotateMatrix As New Matrix
-
- 'Xoay 1 goc = 30 do, tai tieu cu cua Elip
- rotateMatrix.RotateAt(30.0F, New PointF((x + w / 2), (y + h / 2)))
- gp.Transform = rotateMatrix
-
- gp.SmoothingMode = SmoothingMode.AntiAlias 'che do ve muot
- gp.DrawEllipse(New Pen(Color.Black), x, y, w, h)
- rotateMatrix.Dispose()
- Next
- gp.EndContainer(con) 'Dong cai thung lai
- End Sub
-
- Private Sub bt_ve_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_ve.Click
- VeElip(Me.Width / 2, 100, 45, 250)
- End Sub
-
- Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
- gp = Me.CreateGraphics
- End Sub