Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After free drawing and rotate the canvas,the drawing don't set to the right position. #276

Closed
cocoroise opened this issue Nov 20, 2019 · 17 comments

Comments

@cocoroise
Copy link

Version

lastest master

Development Environment

Google Chrome Canary

Current Behavior

  1. select draw mode,draw a random line on the canvas.
  2. use rotate tool
  3. the freedrawing line don't show on the right place,but others position of shape is correct.

Expected Behavior

I want the freedrawing line stay on the right place after rotate.And wonder why only freedrawing mode will cause the problem.Is any different between freedrawing and other line or shape?

@cocoroise
Copy link
Author

i add a zoom and pan tool,code put on graphics.js

_onMouseWheel(fEvent) {
        const delta = fEvent.e.deltaY / 1000;
        let zoom = this._canvas.getZoom();
        zoom = zoom + delta;
        if (zoom > 5) {
            zoom = 5;
        }
        if (zoom < 1) {
            zoom = 1;
        }
        this._canvas.setZoom(zoom);
        this._canvas.calcViewportBoundaries();
        fEvent.e.preventDefault();
        fEvent.e.stopPropagation();
    }

test

@jinwoo-kim-nhn
Copy link
Contributor

All the features were considered along with the zoom feature and not implemented.

There is no specific support plan for the zoom function yet, but we will consider it for further improvement.

Adding it looks nice and positive. This is open source, so you can contribute directly.

thanks

@cocoroise
Copy link
Author

All the features were considered along with the zoom feature and not implemented.

There is no specific support plan for the zoom function yet, but we will consider it for further improvement.

Adding it looks nice and positive. This is open source, so you can contribute directly.

thanks

ok,but now i got some problems in free drawing.when I finish my project maybe i will contribute soon.

@cocoroise
Copy link
Author

hey,I found the problem lies in a parameter..
In the _onPathCreated() method in graphics.js,
when set

SELECTION_STYLE.originX = 'left';
 SELECTION_STYLE.originY = 'top';

will cause rotate problem like above.
if set

SELECTION_STYLE.originX = 'center';
 SELECTION_STYLE.originY = 'center';

will cause freedrawing misplaced after painting.
bbbbbbut i dont know how to fix it yet.😥

@jinwoo-kim-nhn
Copy link
Contributor

jinwoo-kim-nhn commented Nov 22, 2019

@cocoroise Yes. The problem occurred after upgrading the dependent fabric version to 3.x.x. We know it and plan to fix it, but still too busy to fix it. Please wait a minute.

Thanks for the hints to fix the bug.

@cocoroise
Copy link
Author

cocoroise commented Nov 22, 2019

@cocoroise Yes. The problem occurred after upgrading the dependent fabric version to 3.x.x. We know it and plan to fix it, but still too busy to fix it. Please wait a minute.

Thanks for the hints to fix the bug.

I found a hack way to fix it, but i dont know whether it will cause other problems.
IN /components/rotation.js ---> _rotateForEachObject()

 canvas.forEachObject((obj, index) => {
            let objCenter = obj.getCenterPoint();

          // if the obj is freedrawing 
          if (obj.type === 'path') {
                // got the right positon 
                objCenter = obj.getPointByOrigin('left', 'top');
            }

            const radian = fabric.util.degreesToRadians(angleDiff);
            const newObjCenter = fabric.util.rotatePoint(objCenter, oldImageCenter, radian);
            obj.set({
                left: newObjCenter.x - centerDiff.x,
                top: newObjCenter.y - centerDiff.y,
                angle: (obj.angle + angleDiff) % 360
            });
            obj.setCoords();
        });

If you got other better way to fix it ,please tell me ,thanks😛.

@jinwoo-kim-nhn
Copy link
Contributor

jinwoo-kim-nhn commented Nov 22, 2019

Thank you so much for your help. This is a critical bug and will be fixed as soon as possible.

In my opinion this problem is known as a problem of free curve function which is not related to rotation function. -> #228

But don't worry. I will test it seriously and fix it. soon...

@cocoroise
Copy link
Author

Thank you so much for your help. This is a critical bug and will be fixed as soon as possible.

Thank you so much for your help. This is a critical bug and will be fixed as soon as possible.

In my opinion this problem is known as a problem of free curve function which is not related to rotation function. -> #228

But don't worry. I will test it seriously and fix it. soon...

thanks❤

@uttam9300
Copy link

After zooming crop is also not working properly.

@cocoroise
Copy link
Author

After zooming crop is also not working properly.

yes , before crop you should setZoom(1) .

@uttam9300
Copy link

After zooming crop is also not working properly.

yes , before crop you should setZoom(1) .

How can i disable mousewheel when i click on crop button, please help.

@PabloRoldanCRM
Copy link

Miss @cocoroise hi, I'm using the example. how to do that on example03-mobile ? any help? thanks. there is not the graphics.js just (tui-image-editor.js,service-mobile.js). thanks.

@cocoroise
Copy link
Author

Miss @cocoroise hi, I'm using the example. how to do that on example03-mobile ? any help? thanks. there is not the graphics.js just (tui-image-editor.js,service-mobile.js). thanks.

hi ,maybe you can check to master ,and go to src/js/graphics.js, after change the gra.js ,run npm run bundle,generate the tui-image-editor.js yourself.

@cocoroise
Copy link
Author

After zooming crop is also not working properly.

yes , before crop you should setZoom(1) .

How can i disable mousewheel when i click on crop button, please help.

sorry ,i had try,but false...
i add this code in components/cropper.js but didnt work😥

 _onFabricMouseWheel(fEvent) {
        fEvent.e.stopPropagation();
        fEvent.e.preventDefault();
    }

@mamayadi
Copy link

@cocoroise can you share the full code?
Thanks

@cocoroise
Copy link
Author

@cocoroise can you share the full code?
Thanks

i make some change ,this is my code😊

@mamayadi
Copy link

mamayadi commented Jan 20, 2020

@cocoroise can you share the full code?
Thanks

i make some change ,this is my code😊

@cocoroise Thank you so much 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants