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

Rectangle Scaling #39

Open
mohammedzamakhan opened this issue Nov 12, 2018 · 14 comments
Open

Rectangle Scaling #39

mohammedzamakhan opened this issue Nov 12, 2018 · 14 comments

Comments

@mohammedzamakhan
Copy link

I want to scale rectangle to different height/width ratio, along with keeping it as a rectangle, like this image shows. Currently I do not know a way of doing this
rectangle scaling

@mohammedzamakhan
Copy link
Author

mohammedzamakhan commented Nov 12, 2018

Current behavior (check after I disable uniform scaling)
kapture 2018-11-12 at 15 06 24

@mohammedzamakhan
Copy link
Author

Shows incorrect points for scaling and rotation
screen shot 2018-11-27 at 11 54 18 am

@Mxde59
Copy link

Mxde59 commented Mar 19, 2019

Hi @mohammedzamakhan, same issue for me, any news ?

@w8r
Copy link
Owner

w8r commented Mar 19, 2019

Can you reproduce on the demo page? I can't
lpt

Uniform scaling is default behaviour, why do you need to disable it?

@w8r
Copy link
Owner

w8r commented Mar 19, 2019

Ah, ok, I think I understood what you want.

@Mxde59
Copy link

Mxde59 commented Mar 19, 2019

What a quick response :)

Example below of what i'm looking for :

  • Add a random rectangle on the map
  • Let the user the possibility to rotate / resize to fit on a particular area of the map.

Rotate-Resize-Rectangle

@w8r
Copy link
Owner

w8r commented Mar 19, 2019

I get it. I will work on it as soon as I can (probably end of this week, beginning of the next one) but any help would be appreciated, since I am quite busy

@Mxde59
Copy link

Mxde59 commented Mar 19, 2019

I think this commit is a good point to start :

6cd2b24

My research lead me to onScale method :

  _onScale: function(evt) {
    var originPoint = this._originMarker._point;
    var ratioX, ratioY;
    if (this.options.uniformScaling) {
      ratioX = originPoint.distanceTo(evt.layerPoint) / this._initialDist;
      ratioY = ratioX;
    } else {
      ratioX = (originPoint.x - evt.layerPoint.x) / this._initialDistX;
      ratioY = (originPoint.y - evt.layerPoint.y) / this._initialDistY;
    }

We know that with uniformScaling to true (default value) everything is OK.

But didn't suuceed to do the fix.

Thanks for help

@Mxde59
Copy link

Mxde59 commented Apr 2, 2019

Hi @w8r

I know that time is precious, did you succeed to spend some on it ?

Thanks.

@mookadoo
Copy link

Was this issue ever resolved?

@Mxde59
Copy link

Mxde59 commented Jul 8, 2019

Hi @w8r,
Sorry for asking again.
Didn't succeed to find a solution from my side, do you have some times to spend on it pls ?
Thanks a lot.

@Mxde59
Copy link

Mxde59 commented Oct 17, 2019

Hi @w8r, hi everyone.
Still open, if someone can help ...
Thanks a lot.

@Mxde59
Copy link

Mxde59 commented Jan 10, 2020

Hi @w8r ,
Sorry for asking again, but this feature could help me a lot.
Any help possible ?
Thanks a lot.

@joric
Copy link

joric commented Aug 29, 2024

This version (from #69, also see #71 and #10) only appears to work for rectangles. Originally from here, saved just in case.

I tried local polyfill for the actual version to rotate complex shapes but not succeded yet (it calculates rotation angle from handles, rotates the whole thing to zero angle, applies scale and rotates it back). I have to think about how handles work in this new coordinate system and 2x3 matrix. Also after mouseup it applies its old method back so it needs to be dealt with too.

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