Solved
vc++ splines & point structure
Posted on 2003-03-05
In a previous question about splines in vc++ (not using MFC), I got this response:
----------------------------------------------------------
PolyBezier (hdc, apt, iCount) ;
or
PolyBezierTo (hdc, apt, iCount) ;
In both cases, apt is an array of POINT structures. With PolyBezier, the first four points indicate (in this order) the begin point, first control point, second control point, and end point of the first Bezier curve. Each subsequent Bezier requires only three more points because the begin point of the second Bezier curve is the same as the end point of the first Bezier curve, and so on. The iCount argument is always one plus three times the number of connected curves you're drawing.
The PolyBezierTo function uses the current position for the first begin point. The first and each subsequent Bezier spline requires only three points. When the function returns, the current position is set to the last end point.
One note: when you draw a series of connected Bezier splines, the point of connection will be smooth only if the second control point of the first Bezier, the end point of the first Bezier (which is also the begin point of the second Bezier), and the first control point of the second Bezier are colinear; that is, they lie on the same straight line.
--------------------------------------------------------
I want to know if anyone can tell me how do I instantiate a point structure for use in those functions?
--------------------------------------------------------
An addition to my question, the point structure type is "tagPOINT".
I was able to declare:
tagPOINT apt[4];
then I was successfully able to compile and run:
apt[0].x=50;
apt[0].y=50;
apt[0].x=10;
apt[0].x=10;
apt[0].x=60;
apt[0].x=20;
apt[0].x=90;
apt[0].x=30;
iCount=1;
Then I call
PolyBezier (DC, apt, iCount) ;
in my LRESULT CALLBACK WndProc(HWND hWnd,UINT uMessage, WPARAM wParam, LPARAM lParam) function.
Everything compiles and runs, but nothing is drawn on the screen.
Any help is greatly appreciated. I think this question is easy and I'm just missing something obvious, so currently it's only 50 points. However, I will gladly raise the points if your answer is harder than I expected.
Thanks.