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

Clean origins #2257

Merged
merged 2 commits into from Jun 9, 2015
Merged

Clean origins #2257

merged 2 commits into from Jun 9, 2015

Conversation

asturur
Copy link
Member

@asturur asturur commented Jun 3, 2015

Cleaning of object origins code.
easier to add functions to switch from topleft, topcenter, bottomright and so on.
Necessary but not sufficietn to fix the pointer of rotated itext that is not top left (#2234)

@asturur
Copy link
Member Author

asturur commented Jun 3, 2015

wait one test missing.

@asturur
Copy link
Member Author

asturur commented Jun 3, 2015

Merged similar code, avoid rotating point if the angle is 0. General code reduction.
I noticed that those functions does not have tests, so we should add some.

var degreesToRadians = fabric.util.degreesToRadians;
var degreesToRadians = fabric.util.degreesToRadians,
originXOffset = {
left: -0.5,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are the only things that look confusing to me. Why -0.5, 0 and 0.5?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because we are always working with half width and half height to translate
the points.

i writing tests for all those functions to be sure they give same result as
old one.
Il 06/giu/2015 05:07, "Juriy Zaytsev" notifications@github.com ha
scritto:

In src/mixins/object_origin.mixin.js
#2257 (comment):

@@ -1,40 +1,55 @@
(function() {

  • var degreesToRadians = fabric.util.degreesToRadians;
  • var degreesToRadians = fabric.util.degreesToRadians,
  •  originXOffset = {
    
  •    left: -0.5,
    

These are the only things that look confusing to me. Why -0.5, 0 and 0.5?


Reply to this email directly or view it on GitHub
https://github.com/kangax/fabric.js/pull/2257/files#r31863927.

@asturur
Copy link
Member Author

asturur commented Jun 7, 2015

@kangax they give same results in tests but are shorter, also they do not rotate point if there is no angle.

@kangax
Copy link
Member

kangax commented Jun 7, 2015

@asturur you mean shorter in code? So you think this is OK to merge?

@asturur
Copy link
Member Author

asturur commented Jun 8, 2015

i think yes.
i separated from test to permit a painless revert.

if you think code looks better and is worth ro skip rotation on angle 0, merge it.

kangax added a commit that referenced this pull request Jun 9, 2015
@kangax kangax merged commit 2d38f9e into fabricjs:master Jun 9, 2015
@asturur
Copy link
Member Author

asturur commented Jun 10, 2015

Note: i forgot 1 small optimization ( double calculation of sin and cos ) and to change this.getWidth() with this.getTransformedDimensions().

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling b22ae4f on asturur:clean-origins into ** on kangax:master**.

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

Successfully merging this pull request may close these issues.

None yet

3 participants