I am currently trying to make a map like canvas with buttons inside using SkiaSharp and Xamarin.Forms.
but when it comes to zoom / pan i can't sync this 2 up because when
a) im using a control with zoom / pan actions and canvas + buttons as childs with inverse scale, that mostly works but the skiasharp canvas will be blurry because it's only an element transform (bitmap scaling)
b) the buttons don't stay at the desired location when using the direct skiasharp canvas transform and a seperate content container for the buttons because (bad) transform syncing
any idea on how to combine this 2 components to a map with button markers like element?
My suggestion would be to use AbsoluteLayouts to stack Xamarin.Forms buttons (or Images with GestureRecognizers) over the top of a drawn SKCanvas. Each time a button is clicked you then have to eventually call InvalidateSurface() on the SKCanvas and it will redraw with the parameters that were changed by the clicking of the button. I'm doing this a lot in an app of mine and am very happy with it, you can see it over here.
Related
I'm working on a basic design app where the user can upload images to a canvas, drag them around and resize them. The problem I have is resizing the image with a mouse drag. I'd like the user to position the mouse pointer on either corner of the bitmap image and drag either towards or away from the bitmap to resize it proportionally. I'd be grateful for any code or suggestions.
Lanny mentioned that you had this question here. ZIM, which is based on CreateJS has this functionality built in - it is called transform(). We also have an uploader built in called Loader().
Here is the code that you would use inside the ZIM template available on the code page at ZIM https://zimjs.com
const loader = new Loader().center();
loader.on("loaded", e=>{
e.bitmap.center().transform();
// or if you want multiple files
// loop(e.bitmaps, bitmap=>{
// bitmap.center().transform();
// });
loader.removeFrom();
stage.update();
});
Below is an image that has been loaded. You can try it here https://zimjs.com/explore/uploadresize.html. The transform interface will go away when the user clicks off the image and then comes back when they click on the image. There are various options for all of this that you can read about in the Docs available on the ZIM site.
All your regular CreateJS will work and you will find that ZIM is helpful in many other ways too! Aside from transform() there is drag() for normal dragging, and gesture() for pinch zoom and rotate - you would use one or the other of these not combined.
I have a floor plan (.svg format) and I want to load this svg with SkiaSharp, so that I could zoom-in and zoom out. (this guy's documentation was very helpful)
I will put a pin on svg (on SkiaSharp)
I created AbsoluteLayout and ImageButton and used AbsoluteLayout.SetLayoutBounds method. This worked.
But, this is actually not skiasharp's control, this is forms control. I have a coordinates on svg and I will use skiasharp svg's coordinates . How can I add a layer by layer control on skiasharp, or does skiasharp have a control for this?
I am trying to implement zoom in zoom out functionality in VC++ MFC framework.As I am new for this facing problem in CDC, Graphics And CscrollView concepts.
Default ZoomLevel is 100% and it's scaling by 20% up/Down (60,80,100,120,140,160).
As I have to Zoom the CRect (i.e some rectangular blocks) along with that some lines which is connected to that Rectangle.
Currently Able to zoom with scrollbar support using Cscrollview but while we zoom at some level for ex. 120% I am expanding canvas size
canvas default page size vertically and horizontally are i.e 5000.
Now while we zoom #120% (canvas size * 120) i.e 6000.
Anyhow after zooming blocks and inside image all are expands properly at all zoom level. But the main problem is Connecter With that rectangle block are
not exactly connected to center its showing some gap.
For that I am attaching one image which showing gap between Block and Connector line.
Before Zoom # default level i.e 100% which looks properly connected:
After Doing zoomin i.e #120% Lines are not connected properly to the Blocks:
As you can see Before and after Zoom rectangle and lines objects showing some gap.That is required to be fixed after doing zoomin/out.
Please let me know, What should be best practise or how to expand/zoom the canvas and its all the objects on it ?
Is there any way if we expand or zoom the view/canvas bitmap object all the object(CREct + Lines + images etc on that canvas also adjusted accordingly?
My requirement for zoomin/zoomout is similar like windows print preview dialog box is providing DefaultView Zoomin and Zoomout option at diffrent level (100,125,150,200 etc).
Or if you have any project reference code related to this please share it will be very big help for me.
I have just upgraded Unity to version 4.6 and tried to create a button by Create -> UI -> Button.
However, this button doesn't show up in #Screen tab but it does in Game tab.
Please look at the screen shoot below:
Another question is: The default width and height when creating a new button is 160 x 30. When I change the source image with my own image button, I have to change the width and height parameters in rect transform. Is there any faster way to automatically obtain new width and height based on the image which I insert?
Thank you very much!
First, double click the button in your hierarchy and see that it indeed does not show in the Scene view, excluding any kind of zoom problem. (By the way, I'm assuming you mean "Scene" and not "Screen", right?) Things in different cameras or canvases might have very different scales but appear correctly in the Game view. I don't know how used you are to Unity, so I'm sorry if this sounds obvious. :)
Next, check the dropdown labeled "Layers" on top of Unity's editor, to the right of the Play, Pause and Step buttons. See if the layer of your button (which in this case is "UI") is visible. It should have an open eye icon next to it.
Regarding your other question, after dragging your sprite to the Image component, you can press the "Set Native Size" button, which will set the size of your object to the dimensions of your Sprite. Regarding the new UI, I think this is as automatic as it gets. Note that "Set Native Size" will only appear if your Image type is set to Simple (probably what you want) or Filled in the component.
I had the same problem before and here's a possible solution.
By default, the editor camera (Scene Tab) renders the World Space,
so your Canvas component's render mode should be set to "World Space".
The problem may only occur when you're trying to (or supposedly) render your UI in Screen Space - Overlay or Screen Space - Camera in the Canvas component.
So if you want to properly edit UI objects in the scene tab/window; set the Canvas component's render mode to World Space.
We don't have this problem in Unity 4.x before because I think Unity automatically renders any render mode from the Canvas component, however, that doesn't happen in Unity 5.x. I'm guessing it's either intentional that they do that or it's a bug on Unity UI feature.
I am trying to create a small container where the user will be able to move the mouse/drag his finger in order to control the renderer DOM element, in another container. The problem is that TrackballControls.js, a controller script included with THREE.js, maps the controls to event.clientX and event.clientY, so when I drag with in the small container I created, I don't see the desired effect. I was wondering what a proper way to map the input from a small area and effect the renderer element as if the user had the entire rendering area to give input?
The reason I need to do this is because I am integrating a CSS3D view into a normal, 2D page, and the mobile experience is awful if I do not disable to touch controls on TrackballControls.js- the user will be scrolling down the page as normal, and when he hits the 3D div, the 3D controls take over and the user can no longer scroll out of that area back to the rest of the page content. So I need a little small area where the user can spin, zoom, and pan my 3D visualization but then be able to scroll on the rest of it to escape.
Thanks!