PDA

View Full Version : How do I erase an area?


danielgrad
06-09-2007, 08:39 PM
I'm trying to show something like a "fog-of-war" (i.e. visible area of a map), and I do this by first drawing a black rectangle with 0.3 alpha (the fog), then I want to remove areas (visible areas of the map) from this rectangle... But I can't seem to find a way to do that. If I try to draw with 0 alpha, I get nothing (figures)... the new polygons don't replace the old graphics, they just blend together (so 0 alpha produces nothing new)...
Is there a way to do this? Or a better way to achieve what I want ("fog-of-war")?

sasxa
06-09-2007, 09:34 PM
you could make a bunch of small circles to cover map, than hitTest with empty rectangle and hide them in a loop, tho' I'm not sure how's that gonna effect performance - lot's of overlaping transparent circles might be CPU killer (: I suggest to experiment by increasing radius and reducing number of tham on stage... If you use different transparency and overlap you should get some nice effects also...

danielgrad
06-09-2007, 10:32 PM
you could make a bunch of small circles to cover map, than hitTest with empty rectangle and hide them in a loop, tho' I'm not sure how's that gonna effect performance - lot's of overlaping transparent circles might be CPU killer (: I suggest to experiment by increasing radius and reducing number of tham on stage... If you use different transparency and overlap you should get some nice effects also...

First of all, overlapping transparent circles would combine opacity in the intersecting areas, and I need something clean. Second, circles will not do the job because I need to clear areas by certain polygonal shapes.
What I'm building is a simulation of a robot exploring an unknown map. I need to show the areas that are already explored (according to sensor data), and these areas are not circles in case there are obstacles nearby. I also need a method that would not overload the CPU because it will be busy enough with the robot AI.

sasxa
06-09-2007, 11:20 PM
ok, i get your point... here's another idea, fill your map with that polygonal shapes you've mentioned. make their size as small as minimum step of robot's field of view. For example, if robot sees triangle witch side is 200m, fill your map with triangles of 20px, add transparency and turn them off when they're explored... if robots' sensors are more sophiscicated use poligonal shapes instead of triangle (:

danielgrad
06-10-2007, 01:58 AM
ok, i get your point... here's another idea, fill your map with that polygonal shapes you've mentioned. make their size as small as minimum step of robot's field of view. For example, if robot sees triangle witch side is 200m, fill your map with triangles of 20px, add transparency and turn them off when they're explored... if robots' sensors are more sophiscicated use poligonal shapes instead of triangle (:

The robot generally sees circles, in case of an open field of view... but if there are obstacles nearby that circle is cut down (robot can't see through obstacles) to some random polygon. That polygon's shape is different depending on robot location.

sasxa
06-10-2007, 02:16 AM
my general idea is to make a grid and turn on/off areas that you want. don't think about it as real geometric shapes, but close enough approximation. if you have, for example, 10x10 pixels shape and fill 5000x5000 area with it, than scale that area to 1%, you'll basicly get 50x50 area with 500x500 density. you can use that to simulate your opstacles on map... just like pixels on an image- if you zoom in enough you'll see squares filled with color, not the actual shape they represent...

danielgrad
06-10-2007, 07:39 PM
my general idea is to make a grid and turn on/off areas that you want. don't think about it as real geometric shapes, but close enough approximation. if you have, for example, 10x10 pixels shape and fill 5000x5000 area with it, than scale that area to 1%, you'll basicly get 50x50 area with 500x500 density. you can use that to simulate your opstacles on map... just like pixels on an image- if you zoom in enough you'll see squares filled with color, not the actual shape they represent...

Obstacles are already simulated by polygonal shapes... I don't want a grid map, I want a continuous map. I have just finished my study on grid maps and the next step would be continuous maps (with polygonal approximation of obstacles).

Rehab Director
08-04-2007, 04:49 PM
I've read so many about that issue,there's 2 ways so far
1- if u don't have a pic BG then u will make erase as same as freeline drawing with color of BG
Mouse.addListener
on mouseDown
linestyle
moveTo (_xmouse,_ymouse)
////////
on mouse move
lineTo (_xmouse,_ymouse)


2-if you have a Background you cann't use that way
and I found a file uploaded here in this site it does what we need by bitmapData,easy and wonderfull
except the BG is a text not picture
here's a link
http://hiddenfrominsanity.com/projec...bGlobal_v6.fla

icktoofay
08-05-2007, 12:58 AM
There's actually a pretty good way to go about this. First of all, draw your 0.3 alpha black rectangle over the map. Then, clone your map above the black rectangle. Finally, put a mask on your cloned map. In that mask, draw where your robot has explored. Good luck!