尝试填充该中心区域,不确定我在做什么错。
Imports System.Drawing.Drawing2D
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Private Sub Form1_Paint(sender As System.Object, e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
Dim gp As GraphicsPath = CreatePath(New Rectangle(New Point(200, 200), New Size(250, 100)))
e.Graphics.FillPath(New SolidBrush(Color.LightBlue), gp)
e.Graphics.DrawPath(New Pen(Color.Black), gp)
End Sub
Private Function CreatePath(ByVal area As Rectangle) As GraphicsPath
Dim gp As New GraphicsPath()
Dim rect As Rectangle = New Rectangle(area.Location, New Size(area.Width, area.Height \ 3))
gp.AddEllipse(rect)
Dim hadj As Integer = area.Height \ 4
gp.AddLine(New Point(area.X, area.Y + area.Height - hadj), New Point(area.X, area.Y + (rect.Height \ 3) + 8))
Dim gh As Integer = area.Width \ 4
Dim pts(4) As PointF
pts(0) = New PointF(area.X, area.Y + area.Height - hadj)
pts(1) = New Point(area.X + gh, area.Y + area.Height - (hadj \ 2))
pts(2) = New Point(area.X + gh * 2, area.Y + area.Height - (hadj \ 3))
pts(3) = New Point(area.X + gh * 3, area.Y + area.Height - (hadj \ 2))
pts(4) = New Point(area.X + area.Width, area.Y + area.Height - hadj)
gp.AddCurve(pts)
gp.AddLine(New PointF(area.X + area.Width, area.Y + (rect.Height \ 3) + 9), New PointF(area.X + area.Width, area.Y + area.Height - hadj))
Return gp
End Function
End Class
答案 0 :(得分:4)
尝试以下方法。默认情况下,GraphicsPath使用交替填充模式,该模式交替从填充中进行加/减。绕线填充模式使用方向从填充中添加(顺时针)或减去(逆时针)。
select REGEXP_SUBSTR(col1,'[^\^]+',1,level)||REGEXP_SUBSTR(col2,'[^\^]+',1,level) as res from A_TEST
connect by REGEXP_SUBSTR(col1,'[^\^]+',1,level) is not null;
答案 1 :(得分:3)
另一种方法,仅用于显示GraphicsPath
对象的Reset()
方法。
由于圆柱体可以看作是两个省略号和一个矩形的组合( perspective 会产生3D对象的错觉),因此在此首先填充这些形状,然后填充外部部分(形状边界)是独立绘制的。
最终,如果需要,最终将允许使用不同的画笔作为图形。
结果样本:
Private upperRect As Rectangle = New Rectangle(New Point(10, 10), New Size(180, 80))
Private lowerRect As Rectangle = New Rectangle(New Point(10, 100), New Size(180, 80))
Private Sub Form1_Paint(sender As Object, e As PaintEventArgs) Handles MyBase.Paint
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias
Dim middleRect As Rectangle = CylinderMiddleRect(upperRect, lowerRect)
Using gp As GraphicsPath = New GraphicsPath(FillMode.Winding)
gp.AddEllipse(upperRect)
gp.AddRectangle(middleRect)
gp.AddEllipse(lowerRect)
e.Graphics.FillPath(Brushes.LightBlue, gp)
gp.Reset()
gp.AddArc(lowerRect, 0, 180)
gp.AddEllipse(upperRect)
gp.AddLine(New Point(middleRect.X, middleRect.Y), New Point(upperRect.X, middleRect.Bottom))
gp.CloseFigure()
gp.AddLine(New Point(middleRect.Right, middleRect.Y), New Point(middleRect.Right, middleRect.Bottom))
gp.CloseFigure()
e.Graphics.DrawPath(Pens.Black, gp)
End Using
End Sub
Private Function CylinderMiddleRect(upperRect As Rectangle, lowerRect As Rectangle) As Rectangle
Dim distance As Integer = (lowerRect.Y + (lowerRect.Height \ 2)) - (upperRect.Y + (upperRect.Height \ 2))
Return New Rectangle(New Point(upperRect.X, upperRect.Y + (upperRect.Height \ 2)),
New Size(upperRect.Width, distance))
End Function