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

Get rotate angle of image layer #102

Closed
meygh opened this issue Jul 14, 2018 · 10 comments · Fixed by #480 or #502
Closed

Get rotate angle of image layer #102

meygh opened this issue Jul 14, 2018 · 10 comments · Fixed by #480 or #502

Comments

@meygh
Copy link

meygh commented Jul 14, 2018

We are preparing to participate in Google Code-in, and have reserved this issue for participants in GCI - but we'd love to have your help with another one! Please check out https://code.publiclab.org to see more

Hello

How do I can get / set rotation degree for an image layer.
Something like: image.getRotate() / image.setRotate(45)
I can't find anything, please help me.

Thanks

@jywarren
Copy link
Member

Hi, there is this property:

this._rotation = this.options.rotation;

But part of the problem is that the image may be distorted, so it's not clear what the rotation actually is. Would you average the offset of positions of all four corners?

@grvsachdeva
Copy link
Member

Hi @meygh, the issue has been updated by @jywarren. Please close the issue if the answer resolves your problem or if it's not required anymore. Thanks!

@rexagod
Copy link
Member

rexagod commented Apr 11, 2019

@meygh Simple algebra here, I guess. First off, find the pivot by the intersection of both the diagonals formed by the corners (exposed). Actually, we have a method called getCenter() that returns the pivot for the current overlay, so maybe use that. Once you have that, calculate the mid-point of any side (again, using the adjacent corners) then after rotation find the angle difference from the slopes of the initial and rotated lines. Let me know and I'll be happy to come up with a function that implements this.

@rexagod
Copy link
Member

rexagod commented Dec 1, 2019

Uploaded to GCI Dashboard.

@SidharthBansal
Copy link
Member

Published

sashadev-sky pushed a commit that referenced this issue Dec 22, 2019
* ADD: getAngle() method

Resolves #102

* IMPROVE: getAngle() method

The old implementation of getAngle() method would show the incorrect angle
when we flip the image by dragging the 2 top corners below the bottom 2
corners.

This change resolves it.
@sashadev-sky sashadev-sky reopened this Dec 22, 2019
@pythongiant
Copy link

Why was this opened again @sashadev-sky

jywarren pushed a commit that referenced this issue Jan 2, 2020
The method accepts an angle in degrees and sets element's rotation to be
that angle.

Resolves #102
@sashadev-sky
Copy link
Member

@SidharthBansal @VladimirMikulic was this one definitely published on the dashboard and not just "Set degrees of rotation..." I can't find it! Just wanted to double check

@SidharthBansal
Copy link
Member

@VladimirMikulic can check and get it approved from me asap. :-)

@VladimirMikulic
Copy link
Contributor

VladimirMikulic commented Jan 13, 2020

@sashadev-sky this one was published on GCI dashboard and I claimed points for it.
In the description, it said to write getAngle, not getRotate and the other one was setAngle instead of setRotate.

@SidharthBansal thanks you've approved them already :)

@sashadev-sky
Copy link
Member

ok perfect

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

Successfully merging a pull request may close this issue.

8 participants