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 8124773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:34:29+00:00 2026-06-06T06:34:29+00:00

I am drawing reactangles in a loop based on the parameters that I get

  • 0

I am drawing reactangles in a loop based on the parameters that I get from the looping variable event as below :

CGRectMake(cellWidth * event.xOffset,(cellHeight / MINUTES_IN_TWO_HOURS * [event minutesSinceEvent]), cellWidth,cellHeight / MINUTES_IN_TWO_HOURS * [event durationInMinutes]);

in every loop the minutesSinceEvent and durationInMinutes changes, so a different reactangle gets drawn every time.

I want to get the lowest y value in the loop and the greatest height in the loop. Simply saying, I want to have the y value of the rectangle which is above all. And the height of the rectangle which extends below all.

Please let me know, if any other information is needed?

  • 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-06T06:34:32+00:00Added an answer on June 6, 2026 at 6:34 am

    A very simple way would be to accumulate all rectangles in a union rectangle:

    CGRect unionRect = CGRectNull;
    for (...) {
        CGRect currentRect = ...;
        unionRect = CGRectUnion(unionRect, currentRect);
    }
    NSLog(@"min Y : %f", CGRectGetMinY(unionRect));
    NSLog(@"height: %f", CGRectGetHeight(unionRect));
    

    What this does is basically to calculate a rectangle that is large enough to contain all rectangles that were created in the loop (but no larger).

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

Sidebar

Related Questions

I am drawing rectangles inside a picture box, based on data that is being
I'm drawing some UML in which a concrete class inherits from an abstract class
I wrote a drawing function that draws various on-screen sprites. These sprites can only
I have ran into a problem that i suspect has to do painting/drawing elements
I have this algorithm that are drawing a lot of pixels on a Canvas
I've been looking for a good cross-platform 2D drawing library that can be called
Basically I'm drawing a lot of transparent JPanels; profiling shows that most time is
I'm drawing some shapes on canvas, but rotation freaks me up. From tutorials I
I've got a list of System.Drawing.RectangleF objects that all overlap the same RectangleF object.
I'm trying to draw 10 rectangles, but when I use g.DrawRectangle() it is drawing

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.