楕円形の円弧の描画 <TOP>
ArcTo 楕円形の円弧の描画
X1〜X4、Y1〜Y4の数値および時計回り、反時計回り描画を変えて変化を確認しています。
X1 LeftRect
Y1 TopRect
X2 RightRect
Y2 BottomRect
X3 xStartArc
Y3 yStartArc
X4 xEndArc
Y4 yEndAr
'================================================================ '= 楕円形の円弧の描画 '= (ArcTo.bas)
'================================================================ #include "Windows.bi" #define AD_CLOCKWISE 2 '時計回り #define AD_COUNTERCLOCKWISE 1 '反時計回り ' 楕円弧を描画 Declare Function Api_ArcTo& Lib "gdi32" Alias "ArcTo" (ByVal hDC&, ByVal X1&, ByVal Y1&, ByVal X2&, ByVal Y2&, ByVal X3&, ByVal Y3&, ByVal X4&, ByVal Y4&) ' デバイスコンテキストに設定されている、円弧の現在の方向を設定 Declare Function Api_SetArcDirection& Lib "gdi32" Alias "SetArcDirection" (ByVal hDC&, ByVal ArcDirection&) ' デバイスコンテキストに設定されている、円弧の現在の方向を取得 Declare Function Api_GetArcDirection& Lib "gdi32" Alias "GetArcDirection" (ByVal hDC&) ' 指定されたウィンドウのクライアント領域または画面全体を表すディスプレイデバイスコンテキストのハンドルを取得 Declare Function Api_GetDC& Lib "user32" Alias "GetDC" (ByVal hWnd&) ' デバイスコンテキストを解放 Declare Function Api_ReleaseDC& Lib "user32" Alias "ReleaseDC" (ByVal hWnd&, ByVal hDC&) Var Shared x(3) As Long Var Shared y(3) As Long '================================================================ '= '================================================================ Declare Function Index bdecl () As Integer Function Index() Index = Val(Mid$(GetDlgRadioSelect("Radio1"), 6)) -1 End Function '================================================================ '= '================================================================ Declare Sub Button1_on edecl () Sub Button1_on() Var Ret As Long Var hDC As Long x(0) = Val(GetDlgItemText("Edit1")) 'LeftRect y(0) = Val(GetDlgItemText("Edit2")) 'TopRect x(1) = Val(GetDlgItemText("Edit3")) 'RightRect y(1) = Val(GetDlgItemText("Edit4")) 'BottomRect x(2) = Val(GetDlgItemText("Edit5")) 'xStartArc y(2) = Val(GetDlgItemText("Edit6")) 'yStartArc x(3) = Val(GetDlgItemText("Edit7")) 'xEndArc y(3) = Val(GetDlgItemText("Edit8")) 'yEndArc cls hDC = Api_GetDC(GethWnd) If Index = 0 Then Ret = Api_SetArcDirection(hDC, AD_CLOCKWISE) Else Ret = Api_SetArcDirection(hDC, AD_COUNTERCLOCKWISE) End If Line(x(0), y(0)) - (x(1), y(1)), , 5, b, Dot
Ret = Api_ArcTo(hDC, x(0), y(0), x(1), y(1), x(2), y(2), x(3), y(3))
SetDrawWidth 3 Pset(x(2), y(2)),9 Pset(x(3), y(3)),11
SetDrawWidth 0 Ret = Api_ReleaseDC(GethWnd, hDC) End Sub '================================================================ '= '================================================================ While 1 WaitEvent Wend Stop End