w8r / Leaflet.Path.Transform

Drag/rotate/resize handler for leaflet vector features.
http://w8r.github.io/Leaflet.Path.Transform
169 stars 58 forks source link

Rectangle Scaling #39

Open mohammedzamakhan opened 6 years ago

mohammedzamakhan commented 6 years ago

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 commented 6 years ago

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

mohammedzamakhan commented 5 years ago

Shows incorrect points for scaling and rotation

screen shot 2018-11-27 at 11 54 18 am
Mxde59 commented 5 years ago

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

w8r commented 5 years ago

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

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

w8r commented 5 years ago

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

Mxde59 commented 5 years ago

What a quick response :)

Example below of what i'm looking for :

Rotate-Resize-Rectangle

w8r commented 5 years ago

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 commented 5 years ago

I think this commit is a good point to start :

https://github.com/w8r/Leaflet.Path.Transform/commit/6cd2b249a5ee7e6714db8fa977ecfff974e25d4a

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 commented 5 years ago

Hi @w8r

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

Thanks.

mookadoo commented 5 years ago

Was this issue ever resolved?

Mxde59 commented 5 years ago

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 commented 5 years ago

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

Mxde59 commented 4 years ago

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

joric commented 2 months ago

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.