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

  • Home
  • SEARCH
  • 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 990003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:52:52+00:00 2026-05-16T05:52:52+00:00

I am working on a drawing program and am trying to figure out the

  • 0

I am working on a drawing program and am trying to figure out the best way to imitate the ‘magnet’ behavior found in applications such as Omnigraffle. The idea is: as a line is drawn between two objects (visual objects on screen, not OOP objects), as the line from the first object approaches the second, a ‘magnet’ or ‘node’ on the second will highlight or the second object will highlight.

I was looking to keep all of the on-screen objects in an array and using notifications to send that array the position of the end of the line as it moves. This way, I could have each object do its own comparison and say “Hey, I have a node near the line, I think I’ll light it up”.

I was also wondering if it would be the same approach if I wanted to have two objects, say boxes for instance, that would snap together, side by side, when they came into proximity with each other. This way, it would be possible to line up the boxes on the same X or Y coordinate

I’m not concerned about the highlighting or having the line snap to the position of a node, I’m just wondering about the best way to implement the ‘edge proximity detection’ part of this problem.

  • 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-05-16T05:52:53+00:00Added an answer on May 16, 2026 at 5:52 am

    If you are using CGRect types I’d suggest you use the two functions CGRectInset() and CGRectIntersectsRect()

    Use CGRectInset() to expand one or both rects and then use CGRectIntersectsRect() to see if you have a match. You could also use (at the same time) CGRectIntersectsRect() on the original rects to see that you only have are close and not covering each other.

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

Sidebar

Related Questions

I am currently trying to program an online drawing program using the HTML5 canvas.
I am working on making a simple drawing program. So far I am able
I am working on kind of drawing program but I have a problem with
I'm trying to make a working program from this example: http://msdn.microsoft.com/en-us/library/ms741870.aspx . I think
I'm working on drawing an SVG grid using Javascript. I've managed to get the
I am working on a drawing-based product where I want to produce versions for
I'm adding mouse rotation to my 2D drawing program. I've got all the code
I am working on drawing anti-aliased lines in OpenGL-ES on iPhone. I am using
If you have an application with a GUI totally working on 2D drawing, what
I'm working on a simple modelling program concept for Android, and I've come 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.