Fit Leaflet ImageOverlay in polygon so image doesn't overflow - leaflet

I'm using Leaflet ImageOverlay https://leafletjs.com/reference-1.6.0.html#imageoverlay to put a PNG image on top of a polygon (white line). I've already assigned transparent pixels to the pixels where there is no image. However, as you can see in the image, the PNG image goes outside of the polygon exterior line around the borders. How can I make it fit the polygon?
I think I might use z-index here but can't wonder how

Related

How to fill mapbox polygon with fadeout color?

I have a triangle polygon filled with color and low opacity. That was no problem so far.
What I'm trying to achieve looks like this (without points and lines). It is basically triangle polygon with fill color but opacity smoothly lowering from one of the triangle apexes.
Is there any way to achieve this with mapbox? Thanks!
There is no easy, built in way to do this with Mapbox GL JS.
The best way I can think of is to create a Marker (an HTML object anchored at a specific lat/lng) to draw the shape. You will have to do some maths to translate the coordinates of the triangle's vertices into screen coordinates. You will also have to update the calculations if the viewport zooms or rotates.

Can I draw with client coordinates in Leaflet?

I am aware of this question, and the answer works ok for me but I would like the drawn polygons (hexagons) not to move or scale with the map.
Is there a way to do besides overlaying an SVG on top of the map and drawing on it?

Processing tiles generated by gdal2tiles.py in leaflet

I used gdal2tiles.py to split a large image into 256x256 tiles.
I then used leaflet to visualize this large image. This image is georeferenced and appears rotated on the screen. Everything is fine.
I'd like to process the 256x256 tiles of my image before there are displayed.
It is possible to watch load event to have opportunity to process tile but the tiles we get in load event are not in my image space. There are vertically aligned tiles in map, and my image is rotated.
Is there a plugin to handle this case ?
There is one to get coordinates in image space from a point clicked on map, but knowing which image tiles are hitting a map tile requires more than an inverse transform.

How can you get the 3D space coordinates of the 4 corners of an ImageTarget in Vuforia Unity?

I am able to detect images in Vuforia images and overlay 3d objects on them. But I want to draw borders around the ImageTarget.
The problem is that I can only get the center of it such as,
productTarget.transform.position
How can I get the corners of the image ? It is simply a 2D image but Vuforia doesn't have anything to help with this.
There is no way to detect coordinates of the corners, but you can manually calculate it.
This will help you to get the height and width of the image
for example: coordinates of upper left corner will be center - (width/2) - (height/2)
I recommend you just make flat border which you want, and then just resize it on tracking image, because its scale is always the same and vuforia only moves the camera.
image
border
after tracking just child border to image
after parenting

ios game make a mask layer effect

I need a 'mask' layer that covers the whole screen, with the center part (a circle) to be transparent. Then I can move the mask layer around using touch. User are only able to see the transparent part in the middle.
I don't think a png file can help because the file need to be very large to cover the whole screen.
So is it possible to do it by coding?
i found this online, but don't know much about openGL. http://www.cocos2d-iphone.org/forum/topic/7921.
it would be great if i can use a CCMaskLayer and input with the radius. i can handle the touch event by my self.
the attached png file is expected result, the center part is transparent. i need this to cover my screen, and only show the middle part. the red part is covered.
I write a CCMaskLayer to do the exactly same thing.
https://github.com/smilingpoplar/CCMaskLayer
You may solve this task with cropped circle texture in two ways:
1) Draw sprite with circle texture in screen center and draw another 4 sprites around (on top, bottom, left and right sides) with small red texture but scaled to cover all screen.
2) (more elegant but harder to implement) Make your mask layer fullscreen but adjust texture coordinates. In details:
set wrap mode to GL_CLAMP_TO_EDGE to your circle texture
adjust texture coordinates of your layer vertices (to do this you need to subclass base CCLayer):
Here v means vertex position and t - texture coordinates. You need to set correct texture coordinates for four corner vertices of layer. For future if you will want to drag circle you will need to add some offset values to texture coordinates.