I am trying out Leaflet and I have added an image overlay according to an example I have found.
Very simple really
imageBounds = [[40.712216, -74.22655], [40.773941, -74.12544]];
var x = L.imageOverlay(imageUrl, imageBounds, {'zIndex':0}).addTo(mymap);
Now I would like to achieve the following, preferably without any plugins. I have looked into the plugins available and realised that none of them are really fit for what I need to do. I could be wrong but I thought I would try to do this without a plugin.
I have so far tried to scale and rotate the imageOverlay with css. By setting the following for example:
transform: rotate(45deg) !important;
The problem is that it does not seem to handle the origin and the image rotates around some other axis. Also when adding this the image starts to move as I zoom in and out the map.
So to summarise what I want to achieve:
Set the position of the image overlay using lag, lng for its center position.
Set a rotation for the image in degrees or radians
Set the scale of the image
Would this be doable without a plugin or is there a plugin that I shoud use for this?
EDIT 2019-02-28:
I am now close to a solution, but I have some kind of small problem that the rotation of the image is not 100% correct. Please check the fiddle.
https://jsfiddle.net/7aq3k5se/
Found the issue. I made a mistake calculating the aspect ratio. This was not needed and it was what created the issues
Related
Currently in my SceneKit scene for a game in iOS using Swift the render distance is very limited, there is a noticeable cutoff in the terrain
of the players perspective, i cant find a "max render distance" setting anywhere and the only option ive seen so far is to just cover it with fog, im clearly missing something as ive seen plenty of games with larger render distances but after searching across google, documentation and stack overflow i cant seem to get an answer, can anyone help?
Camera Far Clipping Plane
To adjust a max distance between the camera and a visible surface, use zFar instance property. If a 3D object's surface is farther from the camera than this distance, the surface is clipped and does not appear. The default value in SceneKit is 100.0 meters.
arscnView.pointOfView?.camera?.zFar = 500.0
Im a dingdong and figured out what i was missing.
What i was looking for was a setting in the camera that your scene is using as the point of view, theres a setting called 'Z clipping" which clips out anything closer then the "near" value or further then the "far" value, and by default far is set to 100 units. just adjust that setting either in code or within XCODE and set it to a higher value to view the entire scene.
I am having trouble creating a battle royal zone in unity. I want it to be translucent and cover the map with a masked circle in the middle. However, I dont know if there is any way to control the radius of this mask which is something I need to do regularly. Does anyone know how to achive these results?
It should look like the the map view from Fortnite BR.(https://assets.rockpapershotgun.com/images/2019/01/fortnite-small-storm-690x388.jpg/RPSS/resize/690x-1/format/jpg/)
There are a few ways to achieve this effect.
The first and easiest is using the built in Mask, if you are using UI to render the minimap. You can also create a custom UI mesh, as described here for example.
The last option is a (custom) shader. You can download the built-in shaders here and copy over the UI one. Then you have to add your own logic to the fragment shader, something that looks for the Length of the distance of the current UV coordinates and the circle, and if thats smaller than the radius it must be inside. In that case, either clip or set the alpha to 0.
I want to have a playing area with a square dimension, and a sidebar GUI that can be resized according to the resolution. I drew a picture that might help explain
I tried following a tutorial here but the actual dimensions in the build I run seem to be different from what I configure it to in my editor. Also, how do I get the coordinates of the middle of the square (to instantiate something)? Any help? Thanks!
In the tutorial you linked it says:
When running your game from within Unity's editor, be sure to have the Game >window open and visible in the editor when you run the game. There's >currently a bug in Unity 3.0 (and possibly in earlier versions as well) where >the window resolution reported to the script does not match the actual >resolution of the window inside the editor if the window isn't visible at the >time the play button is pressed, leading to a viewport with the wrong size.
Did you took notice to this?
Also what do you mean by taking the coordinates in the center of the square? If you mean the actual screen, then you should get a point based on the square dimensions like:
Vector2 point;
Rect rect = camera.rect;
point.x = rect.x/2;
point.y = rect.y/2;
But if you want the point in 3D space where the camera is pointing, you can use the default method ViewportToWorldPoint, as shown here: http://answers.unity3d.com/questions/189731/how-would-i-find-a-point-in-front-of-my-cam.html
It should look like this:
float distanceFromViewPort = 1 //change 1 to the distance you wish the instance to appear away from the camera.
Vector3 point = camera.ViewportToWorldPoint(Vector(0.5,0.5,distanceFromCamera));
How can a bounding box be created for a UIImageView that is not a CGRect?
I would like to have objects in my view which should display images as well as detection collisions.
The issue is I would like these object to be whatever shape they are rather than fitting them into a CGRect and detecting collisions on areas which are inside the box but are nit the actual image.
How does one achieve this?
This is a non-trivial problem. But the basics are a CGRect is a rectangle and a hit test inside of a rectangle is fairly easy to understand. However, you sound like you want a more complex shape. UIImageView displays an image. It does not have any idea about what shape you want to use for your collision test. So you are going to have to tell it.
One easy thing to do is to look at the alpha/transparent values of the display image to create a shape. So to answer the question is a point hitting an image we figure out the location of point in the image and return true if the alpha is greater than 0. If you do this you can create any image with a transparent background and the code will just work.
If that will not work for you then can can also run a hit test on a point and a polygon this post covers that in detail.
How can I determine whether a 2D Point is within a Polygon?
An iPhone SDK question: I'm drawing a UIImageView on the screen. I've rotated it in 3D and provided a bit of perspective, so the image looks like it's pointing into the screen at an angle. That all works fine. Now the problem is the edges of the resulting picture don't seem to be antialiased at all. Anybody know how to make it so?
Essentially, I'm implementing my own version of CoverFlow (yeah yeah, design patent blah blah) using quartz 3d transformations to do everything. It works fine, except that each cover isn't antialiased, and Apples version is.
I've tried messing around with the edgeAntialisingMask of the CALayer, but that didn't help - the defaults are that every edge should be antialiased...
thanks!
If you rotate only one image, than one trick will resolve the problem. Try to set
layer.shadowOpacity = 0.01;
After that picture will look smoother after 3D Rotation
The Gloomcore answer give a really neat result.
however this sometime make things really LAGGY !
Adding rasterization help a little bit:
.layer.shadowOpacity = 0.01;
.layer.shouldRasterize = YES;
I know the question/answer is old, but hey i just found it.
You could try adding some transparent pixels around the edge of the image, either by putting the UIImageView in a slightly larger empty view that you apply rotation to, or by changing the source images.
I had a similar issue that was solved by only setting shouldRasterize = YES, however because I was re-using my views (and layers), the shouldRasterize = YES killed the performance.
Fortunately I found a solution by turning shouldRasterize = NO at the right time to restore performance in my app's case.
I posted a solution here: Antialiasing edges of UIView after transformation using CALayer's transform
You can try this
Method: Using layer.shouldRasterize
Create a superlayer/superview which is 1 pixel bigger in all 4 directions
Do the transform on the superlayer/superview
Enable layer.shouldRasterize on the original layer/view
Method: Drawing to a UIImage
Draw your content to a UIImage
Make sure that you have a transparent border of 1 pixel around the content
Display the image
Reference: http://darknoon.com/2012/05/18/the-transparent-border-trick/