Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8102277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:12:12+00:00 2026-06-05T23:12:12+00:00

I’ve got a list of System.Drawing.RectangleF objects that all overlap the same RectangleF object.

  • 0

I’ve got a list of System.Drawing.RectangleF objects that all overlap the same RectangleF object. In my picture below, the 3 overlapping rectangles would be the pink, yellow, and red rectangles. My main rectangle in question is the light blue rectangle.

enter image description here

Second Image:
enter image description here

I know that with RectangleF objects I can use the Intersect() method that will return me another RectangleF object representing the overlap. But as far as I can tell, this only really works when comparing two rectangles.

My question is: How could I determine the TOTAL area/percentage (i.e. the combined total overlap of the red, yellow, and pink rectangles when compared to the light blue rectangle – but it would need to be smart enough to not count the area in which the red and yellow overlaps twice, and same for the pink and yellow)?

NOTE: The green lines represent the area I’m looking for, just the total area of the blue rectangle that is not visible.

UPDATE: I’ve added a 2nd image to further demonstrate what I’m looking for. In the second image, the presence of the burgundy rectangle should have no affect on the total percent covered because that area is already covered by the yellow and green rectangles.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T23:12:15+00:00Added an answer on June 5, 2026 at 11:12 pm

    OK I think I found a solution using a Region that seems to be working for both of my example images above:

    Private Function TotalCoveredAreaPercent(ByVal oRectToCheck As RectangleF, ByVal oOverlappingRects As List(Of RectangleF)) As Double
    
        Dim oRegion As New Region(oRectToCheck)
        Dim dTotalVisibleArea As Double = 0
        Dim dTotalCoveredArea As Double = 0
    
        'now we need to exclude the intersection of our 
        'overlapping rectangles with our main rectangle:
        For Each oOverlappingRect As RectangleF In oOverlappingRects
    
            oRegion.Exclude(RectangleF.Intersect(oRectToCheck, oOverlappingRect))
    
        Next
    
        'now we have access to the non-overlapping 
        'rectangles that make up the visible area of our main rectangle:
        Dim oVisibleRects As RectangleF()
    
        oVisibleRects = oRegion.GetRegionScans(New Drawing2D.Matrix())
    
        'add the area of the visible rectangles together 
        'to find the total visible area of our main rectangle:
        For Each oVisibleRect As RectangleF In oVisibleRects
            dTotalVisibleArea += AreaOf(oVisibleRect)
        Next
    
        Dim dPercentVisible As Double = dTotalVisibleArea / AreaOf(oRectToCheck) * 100
    
        'percent covered is 100 - the visible percentage:
        Return (100 - dPercentVisible)
    
    End Function
    

    This seems to be working pretty well, and is quite simple.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
i got an object with contents of html markup in it, for example: string
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I used javascript for loading a picture on my website depending on which small
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.