VB.Net Tutorial/2D Graphics/SmoothingMode — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 16:40, 26 мая 2010
Содержание
Graphics.SmoothingMode
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class SmoothingModeAntiNone
public Shared Sub Main
Application.Run(New SmoothingModesForm)
End Sub
End class
Public Class SmoothingModesForm
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()
"
"SmoothingModesForm
"
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(448, 110)
Me.Name = "SmoothingModesForm"
Me.Text = "SmoothingModesForm"
End Sub
#End Region
Private Sub SmoothingModesForm_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles MyBase.Paint
Dim g As Graphics = e.Graphics
Dim x As Integer = 0
Dim y As Integer = 0
Dim width As Integer = Me.ClientRectangle.Width / 2
Dim height As Integer = Me.ClientRectangle.Height
Dim pen As Pen = New Pen(Color.Red, 4)
g.SmoothingMode = SmoothingMode.None
g.DrawCurve(pen, New PointF() {New PointF(x + 20, y + height - 20), New PointF(x + width - 20, y + height - 20), New PointF(x + 20, y + 20), New PointF(x + width - 20, y + 20)}, 1.0)
End Sub
End Class
SmoothingMode.AntiAlias
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class SmoothingModeAntiAlias
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 g As Graphics = Me.CreateGraphics()
g.Clear(Me.BackColor)
Dim redPen As New Pen(Color.Red, 6)
Dim bluePen As New Pen(Color.Blue, 10)
Dim blackPen As New Pen(Color.Black, 5)
g.SmoothingMode = SmoothingMode.AntiAlias
g.DrawRectangle(bluePen, 10, 20, 100, 50)
g.DrawEllipse(redPen, 10, 150, 100, 50)
g.DrawLine(blackPen, 150, 100, 250, 220)
g.Dispose()
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
SmoothingMode.Default
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class SmoothingModeDefault
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 smoothing_mode As Drawing2D.SmoothingMode = Drawing2D.SmoothingMode.Default
e.Graphics.DrawString(smoothing_mode.ToString, Me.Font, Brushes.Black, 10, 10)
e.Graphics.SmoothingMode = smoothing_mode
e.Graphics.DrawEllipse(Pens.Black, 10, 30, 20, 20)
e.Graphics.FillEllipse(Brushes.Black, 40, 30, 20, 20)
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
SmoothingMode.HighQuality
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class SmoothingHighQuality
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 smoothing_mode As Drawing2D.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
e.Graphics.DrawString(smoothing_mode.ToString, Me.Font, Brushes.Black, 10, 10)
e.Graphics.SmoothingMode = smoothing_mode
e.Graphics.DrawEllipse(Pens.Black, 10, 30, 20, 20)
e.Graphics.FillEllipse(Brushes.Black, 40, 30, 20, 20)
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
SmoothingMode.HighSpeed
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class SmoothingModeHighSpeed
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 smoothing_mode As Drawing2D.SmoothingMode = Drawing2D.SmoothingMode.HighSpeed
e.Graphics.DrawString(smoothing_mode.ToString, Me.Font, Brushes.Black, 10, 10)
e.Graphics.SmoothingMode = smoothing_mode
e.Graphics.DrawEllipse(Pens.Black, 10, 30, 20, 20)
e.Graphics.FillEllipse(Brushes.Black, 40, 30, 20, 20)
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
SmoothingMode.None
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class SmoothingModeNone
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 smoothing_mode As Drawing2D.SmoothingMode = Drawing2D.SmoothingMode.None
e.Graphics.DrawString(smoothing_mode.ToString, Me.Font, Brushes.Black, 10, 10)
e.Graphics.SmoothingMode = smoothing_mode
e.Graphics.DrawEllipse(Pens.Black, 10, 30, 20, 20)
e.Graphics.FillEllipse(Brushes.Black, 40, 30, 20, 20)
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