javascript - draw a polygon with fabric.js framework -
I am trying to attract a polygon by using this code:
Canvas.on ('mouse: move', function (option) {if (lines [0]! == empty & amp; objects. Type == "roof") {set startpoint (option); lines [ Line-clock-1] .set ({X2: x, y2: y}); canvas.reader ();}}); This works perfectly in jsfiddle but using the same code on my page, the lines are not drawn to the polygon where I can "paint really" the top left "Birth" in the corner, but when I click to create a polygon it pulls it correctly.
Can anyone help me?
The problem is with the mouse down event, you are setting the organics and the origin in the right corner of the corner. Takes it. I have given below the updated code.
Function Massoudown (event) {setStartingPoint (event); Var number = [x, y, x, y]; Var line = new clothes. Line (number, {left: x, top: y, strokeview: 1, selectable: false, stroke: '# 40648E'}); Lines.push (line); Canvas.add (lines [lineCounter]); Var rect = new fabric.Rect ({left: x-2.5, top: y-2.5, width: 5, height: 5, fill: '#fff', stroke: '# 000', stroke width: 2, selectable: wrong }); Canvas.add (rect); LineCounter ++; }} Function mousemove (event) {canvas.defaultCursor = "crosshair"; If (line [0]! == tap) {setStartingPoint (event); If (lines [line-end-1]! = Null) {lines [line-end-1] .set ({"x2": x, "y2": y}); } Canvas.reader all (); }}
Comments
Post a Comment