Link to home
Avatar of PMH4514

asked on

Help me figure out how to draw this.

Ok, I'm using VC++ 6.0 and MFC.  I have a CPtrList* pList that has N nodes, each node is an instance of CAction.  CAction has a member variable CPoint* m_pPoint

That is, I have a collection of points that is tracking how the user panned around over an image.

To see what I need to draw based on this collection of points grab a pencil and a sheet of paper and do the following:

1. Draw an random/irregular line across the sheet of paper. (It can back over/loop back onto itself)
2. Starting at the beginning of this line, draw a heavy dot on the line every 1cm or so. These dots correspond to my collection of points.
3. Now consider that each point is the center-point of a 3cm rectangle. These numbers are arbitrary, the point being, the distance between center-points is less than the width of the rectangle, so each rectangle is overlapping other rectangles.
4. Draw these rectangles centered over each point.
5. So now you have a bunch of overlapping rectangles, forming a big messy blob that more or less outlines the path of points.
6. With your pencil, draw a heavy border around the outside edges of the overlapped rectangles.

If you were to erase everything but the heavy outside border you drew, you'd be left with a long skinny and squiggly N-sided polygon where the original collection of points would map down the center.

I need to draw this N-sided polygon onto my DC.

Currently I have all the code working to draw the rectangles. But they overlap, so I'm looking for a way to determine the path formed by the outer edges of the collection of rectangles, formed by creating rectangles centered on a collection of points.

I hope that made sense! If not, ask away

Avatar of Jaime Olivares
Jaime Olivares
Flag of Peru image

Blurred text
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of PMH4514


interesting.. I didn't know CRgn existed!
Avatar of PMH4514


so it looks like CombineRgn() conbimes two existing into a new one.. What if I want to maintain a class member m_pCumulativeRegion to which I simply keep adding a temporary scoped CRgn I created with CreateRectRgn() ?
Avatar of PMH4514


ie. would this work:
CRgn frameRegion;
nCombineResult  = m_pCumulativeFrameRegion->CombineRgn(m_pCumulativeFrameRegion, &frameRegion, RGN_XOR);
That's the idea.
but not XOR, it must be RGN_OR, i think.
Avatar of PMH4514


>>XOR, it must be RGN_OR
yup, I just realized that :)

Anyway - yes, this was exceedingly simple.. Nice big points for ya :)