When I use the API to draw a circle near th poles, the area of the circle extends to an infinite distance in the gray area above the map. Is there a way to prevent the circle from extending into the gray area?
No, this is a property of the Mercator projection that is used to represent the Earth in 2D http://en.wikipedia.org/wiki/Mercator_projection.
Related
I have a number of square regions in my game screen which, when actors move across these regions, I want the background image to show through from behind.
So, is it possible to draw to a SpriteBatch such that a region is subtracted/deleted from the texture (effectively "punching a hole" in it)?
I can't think how else to achieve this... Scissors seem incredibly impractical for my purpose, as I want to clip the areas INSIDE a number of squares. This is the inverse of Scissors - which clip areas OUTSIDE the scissors' bounds. The thought of calculating dozens of Scissor regions to fill the inverse areas between an assortment of square regions seems too impractical to be the solution... especially if the regions are moving.
Any help or suggestions appreciated!
UPDATE: Image attached.
I want the background to always be visible in the areas marked with the dotted lines. The dotted areas will move, so I'd rather not create more sprites from the background to lay on top, but rather have parts of the actors intersecting the dotted squares not be drawn. (Or any method that will achieve the same effect.)
I think the best hack is to not try and be so precise about clipping your actors, but to just re-draw the background on top the actors (and to clip that).
Specifically:
draw the whole background
draw your actors/sprites
draw the background with one cliprect for one part that "shows through"
draw the background with another cliprect for the other part that "shows through"
draw the dotted boxes around your cliprect areas
Great image, by the way. Easily worth 1000 words. :)
How to add border on an irregular polygon in flash with perspective?
I have a Movieclip which let the user draw a surface and then apply a bitmap to fill in. I want the clip should be applied as a floor tile and then apply a custom border to the sprite which also has the same perspective as the floor?
Thanks in advance.
Is it possible to apply transformations to an image to transform it in a trapezium?
The image initial state is a rectangulum.
The way my scene is build, I have a polygon that allows dragging on the edges, and an image with the same size and position.
I would like the image to have the same shape of the polygon aways, so it would became a trapezium when one polygon axis is dragged. Is this possible?
I assume you're talking about something like an isosceles trapezoid rather than a simple rectangle.
The answer is No, but Yes...
No, not possible with 2D transforms--canvas.getContext("2d"). That's because 2d transforms use a 3x3 matrix that only makes parallel transforms. Since a trapezoid is non-parallel, you cannot possibly transform an image (rectangle) into a trapezoid.
But, Yes...you can use webGL (canvas 3D transforms) to do non-parallel transforms and therefore you can use canvas 3D to convert an image into a trapezoid.
It is possible to get inscribed rectangle for transparent hole inside BitmapData object?
I mean green rectangle, not red. Here's a sketch:
I have a certain region given by the coordinates of the lefttop corner and bottom right corner. However, the region formed is not square since the radius of the circle decreases as the latitude increases. In my case, there is a difference of 3-4 km when I calculate the distance using top two coordinates and the bottom two coordinates So, how can I get a square region. I can't suppose that the the region bounded by the lefttop corner coordinate and bottomright coordinate is square. I want a region where the top two corners have a distance of x miles and the bottom two corners have a distance of x miles. Suggestions?
If you aren't into super-accuracy (ie the words WGS84 and oblate spheroid mean nothing to you) then it's simply a matter of calculating the km/degree of longitude at the upper latitude and then shifting the longitude of the two corners out a little, one east and one west.
Roughly:
Latitude: 1 deg = 110.54 km
Longitude: 1 deg = 111.320*cos(latitude) km
http://en.wikipedia.org/wiki/Latitude
Being precise, you cannot have square region on sphere surface. If you correct the distance of top 2 coordinates, then the "right" angles will not be 90 degrees and who knows if the vertical sides would be straight lines!
Google maps projection naturally gives you square in [lat, lon] 2D space, which is correct for most purposes - I also use this geographical "rectangle" grid of 11x11km squares on small spatial scales (400x200km) with no problems. If you neglect the small difference, your life will be much much easier. If you don't, I really cannot assure you the problem of exact rectangle on sphere surface even has any solution!