程序5-4 Bezier
来源:互联网 发布:阴阳师伤害计算软件 编辑:程序博客网 时间:2024/04/29 16:41
program Bezier;
uses
Windows,
Messages;
procedure DrawBezier(hdc1: HDC; apt: array of TPoint);
begin
PolyBezier(hdc1, apt, 4); //贝塞尔曲线
// 绘制控制点与端点连线
MoveToEx(hdc1, apt[0].X, apt[0].Y, nil);
LineTo(hdc1, apt[1].X, apt[1].Y);
MoveToEx(hdc1, apt[2].X, apt[2].Y, nil);
LineTo(hdc1, apt[3].X, apt[3].Y);
end;
function WndProc(hWindow: HWND; msg, wParam, lParam: LongInt): LRESULT; stdcall;
const
{$J+}
apt: array[0..3] of TPoint = (
(X:0; Y:0), (X:0; Y:0), (X:0; Y:0), (X:0; Y:0)
);
{$J-}
var
ps: TPaintStruct;
hdc1: HDC;
cxClient, cyClient: Integer;
begin
Result:= 0;
case msg of
WM_CREATE:
begin
end;
WM_DESTROY:
begin
PostQuitMessage(0);
end;
WM_SIZE:
begin
cxClient:= LoWord(lParam);
cyClient:= HiWord(lParam);
//起点
apt[0].X:= cxClient div 4;
apt[0].Y:= cyClient div 2;
//第一控制点
apt[1].X:= cxClient div 2;
apt[1].Y:= cyClient div 4;
//第二控制点
apt[2].X:= cxClient div 2;
apt[2].Y:= 3 * cyClient div 4;
//终点
apt[3].X:= 3 * cxClient div 4;
apt[3].Y:= cyClient div 2;
end;
WM_LBUTTONDOWN,
WM_RBUTTONDOWN,
WM_MOUSEMOVE:
begin
if ((wParam and MK_LBUTTON <> 0) or (wParam and MK_RBUTTON <> 0)) then
begin
hdc1:= GetDC(hWindow);
//清除旧线
SelectObject(hdc1, GetStockObject(WHITE_PEN));//TE_BRUSH
DrawBezier(hdc1, apt);
if wParam and MK_LBUTTON <> 0 then
begin
apt[1].X:= LoWord(lParam);
apt[1].Y:= HiWord(lParam);
end;
if wParam and MK_RBUTTON <> 0 then
begin
apt[2].X:= LoWord(lParam);
apt[2].Y:= HiWord(lParam);
end;
//绘制新线
SelectObject(hdc1, GetStockObject(BLACK_PEN));//TE_BRUSH
DrawBezier(hdc1, apt);
ReleaseDC(hWindow, hdc1);
end;
end;
WM_PAINT:
begin
hdc1:= BeginPaint(hWindow, ps);
DrawBezier(hdc1, apt);
EndPaint(hWindow, ps);
end
else
Result:= DefWindowProc(hWindow, msg, wParam, lParam);
end;
end;
const
szAppName = 'Bezier';
var
wndclass1: TWndClass;
hWindow: HWND;
msg: TMsg;
begin
wndclass1.style:= CS_VREDRAW or CS_HREDRAW;
wndclass1.lpfnWndProc:= @WndProc;
wndclass1.cbClsExtra:= 0;
wndclass1.cbWndExtra:= 0;
wndclass1.hInstance:= HInstance;
wndclass1.hIcon:= LoadIcon(0, 0);
wndclass1.hCursor:= LoadCursor(0, 0);
wndclass1.hbrBackground:= GetStockObject(0);
wndclass1.lpszMenuName:= nil;
wndclass1.lpszClassName:= szAppName;
if RegisterClass(wndclass1) = 0 then
begin
MessageBox(0, 'This program requires Windows NT!', szAppName, MB_ICONERROR);
exit;
end;
hWindow:= CreateWindow(szAppName, 'Bezier Splines', WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
0, 0, HInstance, nil);
ShowWindow(hWindow, CmdShow);
UpdateWindow(hWindow);
while GetMessage(msg, 0, 0, 0) do
begin
TranslateMessage(msg);
DispatchMessage(msg);
end;
end.
- 程序5-4 Bezier
- BEZIER程序
- bezier
- bezier
- C语言生成Bezier曲线程序
- [OpenGL]课后案例19:Bezier曲线程序
- Bezier曲线重要性质及程序实现(可人机交互)
- 机械版CG 实验5 Bezier曲线
- CG实验4th:Bezier曲线
- 7.5.5编程实例-Bezier曲线曲面绘制
- 2次三次4次Bezier曲线实践
- java 画的4个点的Bezier曲线
- Bezier曲线:
- bezier 曲线
- Bezier曲线
- Bezier曲线
- Curve Bezier
- bezier曲线和bezier曲面
- ubuntu Grub修复
- 转贴,哈哈
- 寻桃花不见
- 免软驱免重装开启AHCI的最佳方法
- 编译链接详解
- 程序5-4 Bezier
- Project Management
- 黄炎培——职业教育实施之希望
- 用 PHP开发多任务应用程序
- 做一个下花痴又有什么关系?
- Windows下基于Apache服务器的PHP环境搭建
- OpenCMS 7 Develement 章节翻译-1 Chapter3 - Registering the Content Type
- JAVA字符集和字符串的编码
- 我迷失在你的背影中