http://zip.nvp.com.tw/forum.php?mod=viewthread&tid=954&extra=page%3D36
Imports System.Drawing.Drawing2D Public Class Form1 Dim g As Graphics Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load g = Me.CreateGraphics Label1.BorderStyle = BorderStyle.Fixed3D Label2.BorderStyle = BorderStyle.Fixed3D Label3.BorderStyle = BorderStyle.Fixed3D Label1.Text = Color.Red.R.ToString Label2.Text = Color.Green.G.ToString Label3.Text = Color.Blue.B.ToString HScrollBar1.SmallChange = 1 HScrollBar1.LargeChange = 10 HScrollBar1.Minimum = 0 HScrollBar1.Maximum = 255 + HScrollBar1.LargeChange - 1 HScrollBar1.Value = Color.Red.R HScrollBar2.SmallChange = 1 HScrollBar2.LargeChange = 10 HScrollBar2.Minimum = 0 HScrollBar2.Maximum = 255 + HScrollBar2.LargeChange - 1 HScrollBar2.Value = Color.Green.G HScrollBar3.SmallChange = 1 HScrollBar3.LargeChange = 10 HScrollBar3.Minimum = 0 HScrollBar3.Maximum = 255 + HScrollBar3.LargeChange - 1 HScrollBar3.Value = Color.Blue.B End Sub Private Sub draw_data() Dim path1 As New GraphicsPath Dim path2 As New GraphicsPath Dim path3 As New GraphicsPath Dim Rregion, Gregion, Bregion As Region Dim region1, region2, region3, region4, region5, region6, region7 As Region Dim brush1, brush2, brush3, brush4, brush5, brush6, brush7 As SolidBrush path1.AddEllipse(75 - 50 + 25 2, 0, 100, 100) path2.AddEllipse(0, 50, 100, 100) path3.AddEllipse(50 + 25 2, 50, 100, 100) Rregion = New Region(path1) Gregion = New Region(path2) Bregion = New Region(path3) region1 = New Region(path1) region1.Exclude(Gregion) region1.Exclude(Bregion) region2 = New Region(path2) region2.Exclude(Rregion) region2.Exclude(Bregion) region3 = New Region(path3) region3.Exclude(Rregion) region3.Exclude(Gregion) region4 = New Region(path1) region4.Intersect(Gregion) region4.Exclude(Bregion) region5 = New Region(path2) region5.Intersect(Bregion) region5.Exclude(Rregion) region6 = New Region(path3) region6.Intersect(Rregion) region6.Exclude(Gregion) region7 = New Region(path1) region7.Intersect(Gregion) region7.Intersect(Bregion) brush1 = New SolidBrush(Color.FromArgb(HScrollBar1.Value, 0, 0)) brush2 = New SolidBrush(Color.FromArgb(0, HScrollBar2.Value, 0)) brush3 = New SolidBrush(Color.FromArgb(0, 0, HScrollBar3.Value)) brush4 = New SolidBrush(Color.FromArgb(HScrollBar1.Value, HScrollBar2.Value, 0)) brush5 = New SolidBrush(Color.FromArgb(0, HScrollBar2.Value, HScrollBar3.Value)) brush6 = New SolidBrush(Color.FromArgb(HScrollBar1.Value, 0, HScrollBar3.Value)) brush7 = New SolidBrush(Color.FromArgb(HScrollBar1.Value, HScrollBar2.Value, HScrollBar3.Value)) g.FillRegion(brush1, region1) g.FillRegion(brush2, region2) g.FillRegion(brush3, region3) g.FillRegion(brush4, region4) g.FillRegion(brush5, region5) g.FillRegion(brush6, region6) g.FillRegion(brush7, region7) End Sub Private Sub HScrollBar1_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles HScrollBar1.Scroll Label1.Text = e.NewValue.ToString draw_data() End Sub Private Sub HScrollBar2_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles HScrollBar2.Scroll Label2.Text = e.NewValue.ToString draw_data() End Sub Private Sub HScrollBar3_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles HScrollBar3.Scroll Label3.Text = e.NewValue.ToString draw_data() End Sub Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint draw_data() End Sub End Class |