I am pretty new with Fabricjs.
I want to create a project where you user can put their design on the blueprint containing a place holder inside.
The dash rectangle inside the T-shirt shaped is called place holder
The problem is that, I want to set the position and the size of the place holder to fit with the T-shirt shaped, I can change the canvas in css, but the selectable part (the purple shadow go after the mouse when I drag the it inside the place holder - sorry, I don't know how to call it) is still keep the same size and the same position.
Is there any way to change the size and the position of it, the real position of canvas?
Related
I'm working on a project that allows users to drawing something, and save it in the database.
Basically, the user draws on a canvas, the canvas is 5 time bigger than the screen size, and the canvas is still in the center of the screen (or the screen is in the center of the canvas).
In order to make it flexible for the canvas size (we want to change the size of the canvas in the future), we want to set the center of the canvas as the Origin Point, that is, (0, 0) is in the center of the canvas. So when the mouse clicks somewhere, the point I get is measured based on the center of the canvas.
Maybe you would say:
Canvas.RenderTransformOrigin = (.5,.5). But I'm not asking the rotating center, so it's not the solution.
Canvas.RenderTransform = TranslateTransform (Canvas.Width/2.0, Canvas.Height/2.0). But this just move all the objects on the canvas to the center.
You may also say that, why don't we just translate the MouseClick points with an offset Canvas.Width/2.0, Canvas.Height/2.0, and then translate them back when rendering. We could do that, but too much effort, because we have a lot of other operations to be implemented, so every time we have to translate back and forth.
It looks like you have thought of almost every possible approach to this problem, however, I will see if I can add just one more!
The Canvas properties, Left and Top, which dictate an elements position are attached properties. You could create your own attached properties, OffsetLeft, OffsetTop which allow you to position elements based on the origin you require. These would be simple to implement, when they are get / set, just handle their change event to set the respective Canvas attached properties.
I have this problem, I want to adjust the position of an image or the hole canvas inside my container which is a 'border', it is more likely a translate transform but depending on the user by moving this element around to adjust it to the suitable position, because my program needs an accurate coordinates.
Had something similar, just placed the canvas in another canvas so i could move it around more easily.
I have some problems with implementing autoscrolling in WPF (I think I could call it that way).
I have a canvas placed inside a scrollviwer. On my canvas I can dynamicly add different shapes. The position of this shapes can be changed with mouse. Everytime I add new shape on canvas or change position of shape I fire measureOverride function.Thanks to this scrollview "know" the real size of canvas and the scrollbars appear. However even if scrolbars appear, the view doesn't "follow" shape which I currently move. I mean if I reach visible part of canvas I would like canvas to srcoll.
I was trying to use this function
ScrollToHorizontalOffset()
However I have problem with proper use of that function. I was trying to use (as a parameter) canvas actualwidth but it didn't work well. I also was trying to use as a parameter current position of shape (which I move) but it works only one way. I the viewer follow the moving element if I was moving this element to right side of canvas. However if I move shape back(to the left) the view don't follow the shape.
I hope somebody will understand this :) It is hard to explain my problem.
I also was trying to use as a
parameter current position of shape
That is the correct way to implement. Waht you need is a converter, which will returns the position according to the direction you move the object.
I just want ask for your comments/suggestions on how to create a customized listview (if that's a good implementation) in WPF that displays images coming from a table from a database (more like a playlist) that rotates similar to a film (moving horizontally - on loop)
Any ideas?
If you have a list of Images, you can create an Image control for each one, put each Image control in a horizontal StackPanel, put the StackPanel inside a Canvas (of whatever size of the "film"), and animate the Left property of the Canvas to have the images roll.
Of course, if you need that the images wrap (the first one after the last one), you could forget about the StackPanel and move each Image separately.
I have a Silverlight app with a canvas with some ellipes in it. I have another canvas below it with no elements.
What I want to do is, when I click in the first cancas, I want to copy the contents of the first canvas and zoom in where I clicked my mouse and show it in the second canvas.
I want functionality like Local Connection gives you in silverlight 3 but as the canvases are in the same xaml and app it would be overkill to use Local Connection.
My solution is really simple I'm almost embarrassed.
I have set the properties of my second canvas to match my first canvas and duplicated any static elements that wont change (I plan to try pull these from one xaml file)
When I click the first canvas I add a new ellipse at the point where I clicked. In the same function I create another ellipse element and add it to my second canvas.
cnvSource.Children.Add(ellipseElement);
cnvTarget.Children.Add(ellipseElementCopy);
I can then create a zoom function on my second canvas so that the first canvas is unafected.