Is there a function that returns the level of the zoom? Or how could you get the level of the zoom with onZoom?
I would like to add/hide some certain elements on SVG when the level of the zoom gets to a certain level. When zoomed enough, an element would be replaced with another element.
getZoom() gives you relative zoom (relative to initial zoom) while getSizes() return real zoom.
Here are all public API methods https://github.com/ariutta/svg-pan-zoom#public-api
Related
I'm implementing the class diagram where the users can change the class' name, attributes and methods. I'm having trouble with resizing the class rectangle width depending on name, attribute or method length. These can overflow and go outside the rectangle, and I just can't find a method to get the correct size.
I also have added an element tool to the elementView, and set its x and y to "100%". According to documentation: "Use percentage strings (e.g. '40%') to position the button relatively to the element width/height." but I guess this isn't the model's size, as I typed JSON.stringify(graph.toJSON()) and got the following.
JSON.stringify(graph.toJSON())
The size is the default value I set (260x100).
I checked the size of the attribute using DevTools:
Size of attribute
The gray button detects the width number I need (330), so I guess that the x in element tools is the elementView's width. I looked at the documentation and can't find any method like .size() or .getSize() for the elementView. I need to resize the rectangle to the size of Max(name length, attribute length, method length) + some aditional space to not look cramped up. I have seen some solutions like "Use [number of letters] * [some constant]" but that is no good as typing 5 "W"s doesn't take the same space as typing 5 "i"s.
So how do I get the width of the whole element (in my case 330 from text length + the three pixels from the left border of the rectangle to the first text letter)?
Okay, so after searching through several Google Groups chats I found some pieces of code that helped me.
For getting the width I needed, I used elementView.getBBox().width.
Where I didn't have the element view right at hand, I at least had the model ID, and so I used paper.findViewByModel(modelId) to get the element view.
Is there any way by which I can zoom in or zoom out in Azure Maps and get data of all the polygons and data pins in the current window?
After the map has finished moving you can call map.layers.getRenderedShapes function to get all rendered shapes in the current view. You can find documentation on this function here: https://learn.microsoft.com/en-us/javascript/api/azure-maps-control/atlas.layermanager?view=azure-iot-typescript-latest#getrenderedshapes-position---point---boundingbox--array-string---layer---expression-
If you zoom the map in close enough into an area in the following sample, it loads a list of all locations that are in view, into a side panel using this function: https://azuremapscodesamples.azurewebsites.net/index.html?sample=Simple%20Store%20Locator This sample is covered in detail in this tutorial: https://learn.microsoft.com/en-us/azure/azure-maps/tutorial-create-store-locator
I've implemented shadow mapping to generate shadows on a terrain.
I render the scene (or the objects that cast shadows) from the light's perspective and then generate a depth map to be sampled during the second render pass (as all the tutorials on the web explain).
It seemed to work fine but then I noticed that objects on a hill cast more than one shadow:
I think that's the correct behaviour since I don't render the terrain during depth map generation (the small quad on top right shows the depth buffer during the first render pass), so more terrain fragments look like they're behind the object from the light's point of view.
No tutorial on shadow mapping seems to mention this issue though.
Am I missing something or this shadow generation technique is very basic and issues like this one are likely to occur?
EDIT
here's my rendering code:
// in my Render() method:
mShadowRenderer.SetLight(*mLights[0]);
mShadowRenderer.Render();
RenderSkyBox();
RenderEntities();
RenderGeometryTerrain(mTerrains[0],
mShadowRenderer.GetLightViewProjectionMatrix());
shadowRenderer is a class that is in charge of rendering to an off-screen buffer and to return a depth map as a shader resource view. The depth map is added to the terrain when I call the render method so it can be sampled in the terrai pixel shader to generate shadows.
Also, the terrain needs to be rendered to the shadow map/dep map
I have a read-only diagram to visualize some data. My end users would like to "filter" the data such that only a subset of the data may be shown at one time. I realize that I can redraw the whole diagram each time I apply a filter omitting the elements that are not to be shown but I am wondering if there is a way that I can simply "hide" some existing elements dynamically and then subsequently re-show them.
To try and make crystal clear, if this were a web page instead of a diagram, I would draw the analogy of applying the CSS of display: none to elements of my choosing.
You can actually do the same with a JointJS diagram elements/links. For example:
myElement.attr('./display', 'none')
hides the whole SVG group element in which the element is rendered. Note the '.' is a special selector that points to the whole group. If you want to hide only a certain SVG subelement, you can do it similarly, e.g. for the joint.shapes.basic.Rect element, you'd do:
myRect.attr('rect/display', 'none')
This hides only the rectangle (the SVG <rect> element referenced by the tag name rect in the attrs object - that we modify via the attr() method.
I am attempting to rotate an MKMapView using MapKit.
I can display a map and rotate it, however not very efficiently. I create an MKMapView larger than the view and rotate it using CGAffineTransformMakeRotation, so the the grey areas behind the view are not visible. Although I have clip subviews checked in Interface Builder, I still have the feeling this is not the correct implementation.
This method does allow me to rotate any annotations displayed as MKPinAnnotationView conforms to the CGAffineTransformMakeRotation function, but I come into problems when trying to add an overlay to the map.
I can place an overlay on using the boundingMapRect property in the class declaration but the image remains unrotated on the display. Is there a way to achieve this? Or alternatively should I be rotating the MKMapView and annotations in a different method?
Thanks in advance for any advice or information.
Are you rotating the map so that it is facing the same way the user is? (i.e. not just North = Up). If so you don't need to do any transformation stuff at all, just set the MKUserTrackingMode to MKUserTrackingModeFollowWithHeading