【发布时间】:2016-03-12 06:06:33
【问题描述】:
我应该使用绘制函数 f(x)= x^2 绘图的 win32 API 编写应用程序。为此,我被要求使用 HBRUSH 结构,但在 win32 API 中似乎没有适当的过程。它们有很多,主要用于绘制完整的形状。
有没有我可以用来逐点绘制情节的?
【问题讨论】:
我应该使用绘制函数 f(x)= x^2 绘图的 win32 API 编写应用程序。为此,我被要求使用 HBRUSH 结构,但在 win32 API 中似乎没有适当的过程。它们有很多,主要用于绘制完整的形状。
有没有我可以用来逐点绘制情节的?
【问题讨论】:
Brush 用于绘制曲面、矩形区域、填充等;你真的需要笔
试试这个:
HDC hdc = /* init this */;
HPEN pen = CreatePen(PS_SOLID, 0, RGB(0, 0, 0));
HGDIOBJ old_pen = SelectObject(hdc, pen);
// move to first poing in plot
MoveToEx(hdc, startingpoint_x, statingpoint_y, NULL);
// executes for each point in plot
LineTo(hdc, pointx, pointy);
// clean up
SelectObject(hdc, old_pen);
DeleteObject(pen);
【讨论】: