A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: [RESOLVED] checking if "line" has gaps

  1. #1
    Collision Noob
    Join Date
    Dec 2009
    Location
    Some unhappy flat
    Posts
    11

    resolved [RESOLVED] checking if "line" has gaps

    How could one check - is some geometrical figure consistent or it has gaps?

    I guess i could somehow fill the shape, and check if color 'leaks' out.

    BUT

    I need the logic itself. for example if I build a square of beer cans(display objects), and one can is missing - how could I discover, by actionscript means, that my 'beer can castle' is not complete?

  2. #2
    Senior Member Pazil's Avatar
    Join Date
    Sep 2006
    Location
    Ontario, Canada
    Posts
    913
    You can BitmapData.draw() any of the DisplayObjects you're using to construct the shape into a BitmapData, and then still use the floodFill() method to see if there are any leeks. Seems like the simplest solution...

    Otherwise you'd need to work on line detection or something...I'm not sure, I'd have to think about it for a while.
    WIP-ZOMBIES

    I love vegetarians! More meat for the rest of us!

  3. #3
    Senior Member
    Join Date
    Oct 2009
    Posts
    117
    Quote Originally Posted by DespeRat View Post
    for example if I build a square of beer cans(display objects), and one can is missing - how could I discover, by actionscript means, that my 'beer can castle' is not complete?
    You would track this information in an array. Update the array when a beer can has been added or removed.

  4. #4
    Member
    Join Date
    Apr 2003
    Location
    Singapore
    Posts
    74
    You can determine the proximity of each beer can from each other, by measuring the distance between the centers of each can, see if it exceeds the gap space you've set.
    My DeviantART gallery of drawings and games.

  5. #5
    Collision Noob
    Join Date
    Dec 2009
    Location
    Some unhappy flat
    Posts
    11
    I've come to this:
    on square grid -
    For each can --> check sides, if there's a 'neighbor', group them. When more than 4 cans are grouped - fill spaces between them. Or when more than 8 cans like this
    ooo
    o o
    ooo

    we fill the center square

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center