Solved

How FrameRgn works

Posted on 2001-07-22
9
829 Views
Last Modified: 2012-06-21
var
   Rects  :array of TRect;
   Points :array of TPoint;

Rects is an array of rectangles that is filled indirectly by GetRegionData (and stored in the same order as they were found in the RGNDATA structure).

Points is an ordered array of points I will use to draw an outline of the region.  (This array will be identical to the array of points you would pass into CreatePolyPolygonRgn, if you were to create the region that way)

I can't use FrameRgn for two reasons:

1.  FrameRgn really isn't very powerful.  I want to draw marching ants and FrameRgn apparently only draws solid lines.
2.  I am not using the region for the purposes of directly drawing to a device context.

I would like to know the algorithm FrameRgn uses to draw the outline of a region, so I can convert Rects to Points.
0
Comment
Question by:scrapdog
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
  • 2
9 Comments
 
LVL 17

Expert Comment

by:inthe
ID: 6306313
hi scrapdog,
dunno about FrameRgn but i have an example of marching ants if its any help (it doesnt use FrameRgn etc).
0
 
LVL 5

Author Comment

by:scrapdog
ID: 6306396
No thanks, got that one figured out. =)
0
 
LVL 5

Author Comment

by:scrapdog
ID: 6306397
But if your marching ants code takes it's input from a Windows region, that would be very helpful...
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 17

Expert Comment

by:inthe
ID: 6306541
nope ,just passes x,y of mouse to lineDDA()
all other examples i have are from tomes which dont look like they help here.

so just listening..
0
 
LVL 5

Accepted Solution

by:
FengYuan earned 275 total points
ID: 6311038
Simple algorithm:

1) Suppose you use (x1,y1,x2,y2) to represent a line to draw.
2) Create a set or sequence of lines.
3) For each rectangle in the region, adding its four edges to the line set using 4).
4) When adding each line to the set, search for lines in the set which intersects with the line to be added.
5) If no intersection is found, append the line.
6) If intersection is found, remove the matched line, add the disjoint portion of the two lines if any.

7) Draw what's left in the line set.

www.fengyuan.com
0
 
LVL 5

Author Comment

by:scrapdog
ID: 6311056
In #6, intersecting two lines will create four line segments...how do I know which line segments to discard (i.e., which of these segments are inside the region)?
0
 
LVL 5

Expert Comment

by:FengYuan
ID: 6311061
I think you should only consider tw vertical lines or two horizontal lines intersect with each other.

In these cases, at most two new lines can be generated.
0
 
LVL 5

Author Comment

by:scrapdog
ID: 6311066
OK, thanks for the info.  I'll try it out.
0
 
LVL 5

Author Comment

by:scrapdog
ID: 6313693
Excellent.  It worked.  I thought everyone was stumped on this one.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month7 days, 3 hours left to enroll

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question