RECT構造体の座標を拡大・縮小 <TOP>
RECT構造体の座標を拡大・縮小します。
InflateRect RECT構造体の座標を拡大・縮小
@で描画した矩形から横方向に60ドット、縦方向に30ドット拡大描画A、さらにAから横方向に10ドット、縦方向に20ドット縮小描画Bします。
いずれも矩形の中心点は変わりません。
'================================================================ '= RECT構造体の座標値を拡大・縮小 '= (InflateRect.bas) '================================================================ #include "Windows.bi" Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type ' RECT構造体の座標値を拡大・縮小 Declare Function Api_InflateRect& Lib "user32" Alias "InflateRect" (lpRect As RECT, ByVal x&, ByVal y&) '================================================================ '= '================================================================ Declare Sub MainForm_Start edecl () Sub MainForm_Start() Var rct As RECT Var Ret As Long For x = 0 To 300 Step 10 Line(x, 0) - (x, 300), , 14 Next For y = 0 To 300 Step 10 Line(0, y) - (300, y), , 14 Next '@初回指定した四角形 rct.Left = 70 rct.Top = 50 rct.Right = 200 rct.Bottom = 100 SetDrawWidth 2 Line(rct.Left, rct.Top) - (rct.Right, rct.Bottom), , 0, b Symbol(rct.Left + 3, rct.Top + 3), "@", 1, 1, 0 'AX軸60ドット、Y軸30ドット拡大 Ret = Api_InflateRect(rct, 60, 30) Line(rct.Left, rct.Top) - (rct.Right, rct.Bottom), , 5, b Symbol(rct.Left + 3, rct.Top + 3), "A", 1, 1, 5 'BAに対しX軸10ドット、Y軸20ドット縮小 Ret = Api_InflateRect(rct, -10, -20) Line(rct.Left, rct.Top) - (rct.Right, rct.Bottom), , 8, b Symbol(rct.Left + 3, rct.Top + 3), "B", 1, 1, 8 End Sub '================================================================ '= '================================================================ While 1 WaitEvent Wend Stop End