Polygon Picture1.hdc, Point(0), 5 End Sub'=============== 下面的程序在模块中 '==============Option ExplicitType POINTAPI x As Long y As Long End TypeDeclare Function Polygon Lib "gdi32" (ByVal hdc As Long, lpPoint As POINTAPI, ByVal nCount As Long) As Long
Option Explicit Const Pi As Double = 3.14159265 Private Sub Draw(r As Double, x As Double, y As Double, c As Long) Dim i As Long Dim R1 As Double Dim x1 As Double Dim y1 As Double Dim a1 As Double Dim a2 As Double
Me.FillColor = c Me.FillStyle = 0 R1 = r * Cos(Pi / 10) + r * Sin(Pi / 10) / Atn(54 / 180 * Pi)
For i = 1 To 5 x1 = x + r * Cos((72 * (i - 1) + 90) / 180 * Pi) y1 = y - r * Sin((72 * (i - 1) + 90) / 180 * Pi)
a1 = (36 + (i + 2) * 72) / 180 * Pi a2 = ((i + 3) * 72) / 180 * Pi
If a2 > Pi * 2 Then a1 = a1 - Pi * 2 a2 = a2 - Pi * 2 End If Me.Circle (x1, y1), R1, c, -a1, -a2 Next i End SubPrivate Sub Command1_Click() Draw 200, 4000, 2000, RGB(255, 0, 0) End Sub
放个commandbox就行了 Private Sub Draw(r As Double, x As Double, y As Double, c As Long) r 半径 x y 中心坐标 c 填充色 用角度算的,过程就不告诉你了:)
定义合适的字体、前景色,然后: picture1.print "★"
Dim Point(0 To 10) As POINTAPI
Point(0).x = 0: Point(0).y = 50
Point(1).x = 100: Point(1).y = 50
Point(2).x = 33: Point(2).y = 100
Point(3).x = 50: Point(3).y = 0
Point(4).x = 66: Point(4).y = 100
Polygon Me.hdc, Point(0), 5
End SubPrivate Sub Command2_Click()
Dim Point(0 To 10) As POINTAPI
Point(0).x = 0: Point(0).y = 50
Point(1).x = 100: Point(1).y = 50
Point(2).x = 33: Point(2).y = 100
Point(3).x = 50: Point(3).y = 0
Point(4).x = 66: Point(4).y = 100
Polygon Picture1.hdc, Point(0), 5
End Sub'===============
下面的程序在模块中
'==============Option ExplicitType POINTAPI
x As Long
y As Long
End TypeDeclare Function Polygon Lib "gdi32" (ByVal hdc As Long, lpPoint As POINTAPI, ByVal nCount As Long) As Long
这个方法绝了!偶真想给你分.....可惜我还是初级用户,没法给.
ColdMooon(月光寒), 谢谢。
我开始发的贴
http://expert.csdn.net/Expert/topic/2873/2873636.xml?temp=7.674807E-02我还是想了解一下用绘制五角星的算法,所以才发这个贴,
flyingZFX(飞翔)的回答不错,但我不知道,它那十个点的坐标是如何得来得?(虽然可以用几何计算得到,但不知道有没有更简单得算法),我想任意给出一个五角星得外接圆半径,及中心坐标,画出一个五角星,并填充颜色继续讨论。
http://expert.csdn.net/Expert/topic/2559/2559303.xml?temp=.962002
Const Pi As Double = 3.14159265
Private Sub Draw(r As Double, x As Double, y As Double, c As Long)
Dim i As Long
Dim R1 As Double
Dim x1 As Double
Dim y1 As Double
Dim a1 As Double
Dim a2 As Double
Me.FillColor = c
Me.FillStyle = 0
R1 = r * Cos(Pi / 10) + r * Sin(Pi / 10) / Atn(54 / 180 * Pi)
For i = 1 To 5
x1 = x + r * Cos((72 * (i - 1) + 90) / 180 * Pi)
y1 = y - r * Sin((72 * (i - 1) + 90) / 180 * Pi)
a1 = (36 + (i + 2) * 72) / 180 * Pi
a2 = ((i + 3) * 72) / 180 * Pi
If a2 > Pi * 2 Then
a1 = a1 - Pi * 2
a2 = a2 - Pi * 2
End If
Me.Circle (x1, y1), R1, c, -a1, -a2
Next i
End SubPrivate Sub Command1_Click()
Draw 200, 4000, 2000, RGB(255, 0, 0)
End Sub
Private Sub Draw(r As Double, x As Double, y As Double, c As Long)
r 半径 x y 中心坐标 c 填充色
用角度算的,过程就不告诉你了:)