Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 365
  • Last Modified:

vc++ splines & point structure

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.




0
substand
Asked:
substand
  • 2
  • 2
1 Solution
 
Chase707Commented:
You should be able to just use this:

POINT apt[4];

Also, I don't think you aren't declaring your points correctly.  Each point is only an x,y -- therefore, for each x,y that you define, you need to increment your array counter:

apt[0].x=50;
apt[0].y=50;

apt[1].x=10;
apt[1].y=10;

apt[2].x=60;
apt[2].y=20;

apt[3].x=90;
apt[3].y=30;

Your iCount in this case should be 4.

try that out and see how it works.

Chase
0
 
substandAuthor Commented:
jeez.  i feel like such a moron now.  I didn't notice that I had copied the code and forgot to change the indexes on the array, and had forgot to change the x/y.

Wasted my points, but i still give you credit for pointing it out =)

thanks.

0
 
substandAuthor Commented:
This was a stupid question on my part.
i should have looked at my code a little longer before i posted it.
0
 
Chase707Commented:
don't feel too bad....it happens to everyone now and then.
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now