VB.Net by API/System.Drawing.Drawing2D/PathGradientBrush
Содержание
New PathGradientBrush
Imports System
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Collections
Imports System.ruponentModel
Imports System.Windows.Forms
Imports System.Data
public class PathGradientBrushCreate
public Shared Sub Main
Application.Run(New BrushesForm)
End Sub
End class
Public Class BrushesForm
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
"This call is required by the Windows Form Designer.
InitializeComponent()
"Add any initialization after the InitializeComponent() call
End Sub
"Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
"Required by the Windows Form Designer
Private components As System.ruponentModel.IContainer
"NOTE: The following procedure is required by the Windows Form Designer
"It can be modified using the Windows Form Designer.
"Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
"
"BrushesForm
"
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Name = "BrushesForm"
Me.Text = "Form1"
End Sub
#End Region
Enum LinearGradientMode
BackwardDiagonal
ForwardDiagonal
Horizontal
Vertical
End Enum
Private Sub BrushesForm_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles MyBase.Paint
Dim g As Graphics = e.Graphics
Dim width As Integer = Me.ClientRectangle.Width
Dim height As Integer = Me.ClientRectangle.Height / 5
Dim whiteBrush As Brush = System.Drawing.Brushes.White
Dim blackBrush As Brush = System.Drawing.Brushes.Black
Dim b As Brush
Dim points As Point() = New Point() {New Point(0,0), New Point(width, 0), New Point(width, height), New Point(0, height)}
b = New PathGradientBrush(points)
g.FillRectangle(b, 0, 0, width, height)
g.DrawString(b.ToString(), Me.Font, whiteBrush, 0, 0)
End Sub
End Class
PathGradientBrush.CenterColor
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
Imports System.Math
public class PathGradientBrushesCenterColorSurroundColors
public Shared Sub Main
Application.Run(New Form1)
End Sub
End class
public class Form1
Inherits System.Windows.Forms.Form
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
Dim x As Integer = 10
Dim y As Integer = 10
Dim wid As Integer = 100
Dim hgt As Integer = 50
Dim rect_pts() As Point = { _
New Point(x, y), _
New Point(x + wid, y), _
New Point(x + wid, y + hgt), _
New Point(x, y + hgt) _
}
Dim path_brush As New PathGradientBrush(rect_pts)
Dim ellipse_path As New GraphicsPath
ellipse_path.AddEllipse(x, y, wid, hgt)
path_brush = New PathGradientBrush(ellipse_path)
path_brush.CenterColor = Color.White
path_brush.SurroundColors = New Color() {Color.Black}
e.Graphics.FillEllipse(path_brush, x, y, wid, hgt)
End Sub
Public Sub New()
MyBase.New()
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
End Sub
End Class
PathGradientBrush.SetBlendTriangularShape
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
Imports System.Math
public class PathGradientBrushesSetBlendTriangularShape
public Shared Sub Main
Application.Run(New Form1)
End Sub
End class
public class Form1
Inherits System.Windows.Forms.Form
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
Dim x As Integer = 10
Dim y As Integer = 10
Dim wid As Integer = 100
Dim hgt As Integer = 50
Dim rect_pts() As Point = { _
New Point(x, y), _
New Point(x + wid, y), _
New Point(x + wid, y + hgt), _
New Point(x, y + hgt) _
}
Dim path_brush As New PathGradientBrush(rect_pts)
Dim ellipse_path As New GraphicsPath
ellipse_path = New GraphicsPath
ellipse_path.AddEllipse(x, y, wid, hgt)
path_brush = New PathGradientBrush(ellipse_path)
path_brush.CenterColor = Color.White
path_brush.SurroundColors = New Color() {Color.Black}
path_brush.SetBlendTriangularShape(0.5)
e.Graphics.FillEllipse(path_brush, x, y, wid, hgt)
End Sub
Public Sub New()
MyBase.New()
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
End Sub
End Class
PathGradientBrush.SetSigmaBellShape
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
Imports System.Math
public class PathGradientBrushesSetSigmaBellShape
public Shared Sub Main
Application.Run(New Form1)
End Sub
End class
public class Form1
Inherits System.Windows.Forms.Form
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
Dim x As Integer = 10
Dim y As Integer = 10
Dim wid As Integer = 100
Dim hgt As Integer = 50
Dim rect_pts() As Point = { _
New Point(x, y), _
New Point(x + wid, y), _
New Point(x + wid, y + hgt), _
New Point(x, y + hgt) _
}
Dim path_brush As New PathGradientBrush(rect_pts)
Dim ellipse_path As New GraphicsPath
ellipse_path = New GraphicsPath
ellipse_path.AddEllipse(x, y, wid, hgt)
path_brush = New PathGradientBrush(ellipse_path)
path_brush.CenterColor = Color.White
path_brush.SurroundColors = New Color() {Color.Black}
path_brush.SetSigmaBellShape(0.5, 1)
e.Graphics.FillEllipse(path_brush, x, y, wid, hgt)
End Sub
Public Sub New()
MyBase.New()
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
End Sub
End Class
PathGradientBrush.SurroundColors
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
Imports System.Math
public class PathGradientBrushesCenterColorSurroundColors
public Shared Sub Main
Application.Run(New Form1)
End Sub
End class
public class Form1
Inherits System.Windows.Forms.Form
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
Dim x As Integer = 10
Dim y As Integer = 10
Dim wid As Integer = 100
Dim hgt As Integer = 50
Dim rect_pts() As Point = { _
New Point(x, y), _
New Point(x + wid, y), _
New Point(x + wid, y + hgt), _
New Point(x, y + hgt) _
}
Dim path_brush As New PathGradientBrush(rect_pts)
Dim ellipse_path As New GraphicsPath
ellipse_path.AddEllipse(x, y, wid, hgt)
path_brush = New PathGradientBrush(ellipse_path)
path_brush.CenterColor = Color.White
path_brush.SurroundColors = New Color() {Color.Black}
e.Graphics.FillEllipse(path_brush, x, y, wid, hgt)
End Sub
Public Sub New()
MyBase.New()
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
End Sub
End Class
PathGradientBrush.WrapMode
Imports System.Drawing.Text
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class PathGradientBrushQuadPoints
public Shared Sub Main
Application.Run(New PathGradientBrushesForm)
End Sub
End class
Public Class PathGradientBrushesForm
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
"This call is required by the Windows Form Designer.
InitializeComponent()
"Add any initialization after the InitializeComponent() call
End Sub
"Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
"Required by the Windows Form Designer
Private components As System.ruponentModel.IContainer
"NOTE: The following procedure is required by the Windows Form Designer
"It can be modified using the Windows Form Designer.
"Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
components = New System.ruponentModel.Container()
Me.Text = "PathGradientBrushesForm"
End Sub
#End Region
Private Sub PathGradientBrushesForm_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles MyBase.Paint
Dim g As Graphics = e.Graphics
Dim width As Integer = Me.ClientRectangle.Width / 2
Dim height As Integer = Me.ClientRectangle.Height / 2
Dim b As PathGradientBrush
Dim x As Integer = 0
Dim y As Integer = 0
Dim quadPoints As Point() = New Point() {New Point(0, 0), New Point(width, 0), New Point(width, height), New Point(0, height)}
b = New PathGradientBrush(quadPoints)
b.WrapMode = WrapMode.Tile
g.FillRectangle(b, x, y, width, height)
End Sub
End Class