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

Adjust scale changing values #322

Closed
vjpixel opened this issue May 19, 2020 · 9 comments
Closed

Adjust scale changing values #322

vjpixel opened this issue May 19, 2020 · 9 comments
Labels
bug Something isn't working

Comments

@vjpixel
Copy link
Member

vjpixel commented May 19, 2020

When I change the Adjust Scale value of an Artwork it's changing to another value.

I just saved 0.95:
Screenshot from 2020-05-19 15-28-37

Just after saving, I opened and the value changed to 0.7737809375:
Screenshot from 2020-05-19 15-29-27

@vjpixel vjpixel added the bug Something isn't working label May 19, 2020
@vjpixel
Copy link
Member Author

vjpixel commented May 19, 2020

I just tried to see if it's related to the Horizontal position that I changed, but it seems unrelated.

My input:
Screenshot from 2020-05-19 15-49-21

After I save and open again, that's what I see:
Screenshot from 2020-05-19 15-51-13

@vjpixel
Copy link
Member Author

vjpixel commented May 19, 2020

I just saved as 1.5. When I open, it says:
Screenshot from 2020-05-19 16-05-51

@vjpixel
Copy link
Member Author

vjpixel commented May 19, 2020

Now it's working again (saving 1 result in 1):
Screenshot from 2020-05-19 16-13-54

@victoralvesgomide
Copy link
Contributor

It took hours for me and @shayanealcantara to understand where the problem was. We explored all the files with the word 'scale' in them. In the end, it was a simple mistake in the 'xproportion' and 'yproportion' methods of the Object class. Isn't the world of programming wonderful? xD

Anyway, we left comments explaining related methods in the code, and we will use this issue to explain (what we understand from) the operation of scales in Jandig.

@victoralvesgomide
Copy link
Contributor

When the user uploads an Object, the aspect ratio of that Object is calculated and stored as a string in the format "[width ratio] [height ratio]", so that the largest value between them appears as 1, and the another appears as a fraction of it. It may seem confusing, but try to see it as a scale in format 1:[something].

Let's use Patrick's GIF as an example. It is 500 pixels wide and 300 pixels high. Therefore, its proportion is calculated by dividing 300 (lowest value) by 500 (highest value). The result is a 1:0.6 scale (stored as "1 0.6").

Patrick 13

@victoralvesgomide
Copy link
Contributor

When the user inputs a value in the "Scale" form (either when uploading or editing the Object), that value is multiplied by both the width and height ratios. Returning to the example, if the user enters the value 2, the new scale is "2 1.2".

The 'xscale' and 'yscale' methods simply obtain these height and width ratios from the scale attribute. The 'xproportion' and 'yproportion' methods obtain these values and reduce them back to scale 1:[something], so that when the user enters a new value in the "Scale" field, the multiplication is done by the original proportion and not by the modified proportion.

@vjpixel
Copy link
Member Author

vjpixel commented Nov 9, 2020

O.o

Thank you very much!!!

@victoralvesgomide
Copy link
Contributor

@vjpixel We're glad you liked it! The issue was resolved and the code was merged, so you may close it already ^^

@vjpixel
Copy link
Member Author

vjpixel commented Dec 7, 2020

Done!

@vjpixel vjpixel closed this as completed Dec 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants