Buatlah program graphics dengan tampilan sebagai berikut :
dengan membuat aplikasi windows seperti biasanya, tambahkan satu toolbox button dan berikan event seperti syntac dibawah ini;
Imports System.Drawing.Drawing2D
Imports System.Drawing
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim g As Graphics = Me.CreateGraphics
Dim br As New SolidBrush(Color.FromArgb(160, Color.Red))
Dim rect As New Rectangle
rect.X = 20
rect.Y = 100
rect.Width = 100
rect.Height = 100
g.FillRectangle(br, rect)
br.Dispose()
br = New SolidBrush(Color.FromArgb(160, Color.Yellow))
rect.X += (rect.Width \ 4)
rect.Y += (rect.Height \ 4)
g.FillRectangle(br, rect)
br.Dispose()
'Membuat gradient rectangle
Dim br2 As New LinearGradientBrush(rect, Color.Yellow, Color.Red, LinearGradientMode.ForwardDiagonal)
rect.X = 400
rect.Y = 370
g.FillRectangle(br2, rect)
'Membuat ellipse bergaris
Dim br3 As New HatchBrush(HatchStyle.ForwardDiagonal, Color.Green, Color.Yellow)
rect.X = 400
rect.Y = 100
g.FillEllipse(br3, rect)
'Membuat Rectangle miring
Dim br5 As New SolidBrush(Color.MediumPurple)
Dim point() As Point = {New Point(250, 150), New Point(200, 200), New Point(290, 290), New Point(340, 240)}
g.FillPolygon(br5, point)
'membuat layangg-layang
Dim br4 As New LinearGradientBrush(rect, Color.Aquamarine, Color.Yellow, LinearGradientMode.Horizontal)
Dim points1() As Point = {New Point(80, 255), New Point(90, 430), New Point(10, 280), New Point(30, 245)}
g.FillPolygon(br4, points1, 0)
br4.Dispose()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
untuk mendownload source code lengkapnya, klik disini!
selamat mencoba :)
Langganan:
Posting Komentar (Atom)
0 comments:
Posting Komentar