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

Update path.class.js #1415

Merged
merged 2 commits into from
Jun 21, 2014
Merged

Update path.class.js #1415

merged 2 commits into from
Jun 21, 2014

Conversation

asturur
Copy link
Member

@asturur asturur commented Jun 21, 2014

Modified path positioning, fixes svg 170, debian logo, change some errors in different errors.

Modified path positioning, fixes svg 170, debian logo, change some errors in different errors.
while investigating why some arcs fails, reduced the number of calls to math.sin and math.cos, not by that much.
@kangax
Copy link
Member

kangax commented Jun 21, 2014

Can you paste SVG for debian logo?

@asturur
Copy link
Member Author

asturur commented Jun 21, 2014

as requested:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" version="1.0" width="744.09448" height="478.70078" id="svg2309">
  <defs id="defs2311"/>
  <g transform="translate(-74.240724,-302.07438)" id="layer1">
    <g transform="matrix(7.2724992,0,0,7.2724992,91.957259,319.71505)" id="g2296">
      <path d="M 85.234,15.346 L 85.234,15.346 C 83.162,15.271 81.537,13.524 81.603,11.447 C 81.636,10.443 82.066,9.515 82.796,8.829 C 83.526,8.146 84.485,7.789 85.489,7.827 C 87.563,7.899 89.19,9.641 89.122,11.72 C 89.089,12.723 88.667,13.648 87.934,14.337 C 87.199,15.022 86.242,15.377 85.234,15.346 L 85.234,15.346 z M 86.105,11.938 C 87.029,11.938 87.777,11.439 87.777,10.824 C 87.777,10.21 87.029,9.712 86.105,9.712 C 85.185,9.712 84.437,10.21 84.437,10.824 C 84.437,11.438 85.185,11.938 86.105,11.938" style="fill:#6eb927" id="path19"/>
      <path d="M 42.369,37.436 L 42.503,37.423 L 42.527,37.262 C 42.491,37.137 42.411,37.024 42.283,35.456 C 42.176,34.069 41.959,30.268 43.873,28.381 C 44.614,27.646 45.75,26.99 46.642,26.78 C 50.309,25.884 54.609,26.504 58.672,31.204 C 60.774,33.634 61.801,34.741 62.317,35.238 L 62.495,35.4 L 62.708,35.557 C 62.878,35.651 69.696,38.789 69.696,38.789 L 69.835,38.755 L 69.837,38.609 C 69.794,38.558 65.517,33.032 66.275,28.481 C 66.877,24.856 69.763,25.182 73.752,25.634 C 75.055,25.783 76.541,25.955 78.074,25.988 C 82.361,26.014 86.98,25.227 89.828,23.982 C 91.668,23.179 92.842,22.648 93.578,21.978 C 93.844,21.759 93.98,21.401 94.123,21.02 L 94.223,20.764 C 94.342,20.456 94.516,19.8 94.592,19.444 C 94.627,19.285 94.643,19.116 94.533,19.03 L 94.137,19.103 C 92.891,19.854 89.766,21.279 86.842,21.336 C 83.217,21.411 75.916,17.69 75.153,17.297 L 75.081,17.21 C 74.899,16.774 73.806,14.183 73.571,13.635 C 78.829,17.097 83.186,19.011 86.524,19.309 C 90.241,19.639 93.135,17.613 94.376,16.746 C 94.618,16.584 94.802,16.451 94.876,16.422 L 94.956,16.292 C 94.751,14.988 92.81,8.672 91.343,7.152 C 90.937,6.738 90.611,6.332 89.954,5.948 C 84.643,2.852 72.038,0.984 71.446,0.898 L 71.346,0.926 L 71.309,1.016 C 71.309,1.016 71.258,3.63 71.254,3.92 C 69.962,3.491 60.603,0.468 51.83,0.164 C 44.391,-0.099 33.558,-1.059 19.2,7.766 L 18.775,8.032 C 12.021,12.247 7.359,17.44 4.921,23.478 C 4.157,25.376 3.127,29.664 4.143,33.696 C 4.585,35.459 5.405,37.228 6.508,38.816 C 9.001,42.398 13.184,44.775 17.694,45.177 C 24.055,45.744 28.877,42.887 30.589,37.536 C 31.768,33.844 30.589,28.425 26.073,25.661 C 22.399,23.412 18.447,23.926 16.156,25.439 C 14.165,26.758 13.038,28.805 13.058,31.056 C 13.104,35.046 16.544,37.167 19.015,37.172 C 19.735,37.172 20.455,37.049 21.268,36.783 C 21.556,36.694 21.832,36.586 22.13,36.401 L 22.224,36.343 L 22.286,36.305 L 22.262,36.317 C 22.826,35.936 23.168,35.311 23.168,34.64 C 23.168,34.458 23.141,34.271 23.089,34.084 C 22.799,33.076 21.801,32.465 20.766,32.651 L 20.626,32.683 L 20.436,32.744 L 20.161,32.836 C 19.592,32.979 19.165,32.988 19.075,32.992 C 18.783,32.971 17.361,32.547 17.361,30.988 L 17.361,30.97 C 17.364,30.399 17.593,29.996 17.72,29.777 C 18.159,29.084 19.372,28.401 21.013,28.547 C 23.16,28.731 24.708,29.832 25.733,31.911 C 26.687,33.845 26.438,36.22 25.091,37.964 C 23.756,39.692 21.379,40.423 18.213,40.08 C 15.022,39.729 12.326,37.892 10.815,35.033 C 9.337,32.241 9.255,28.928 10.606,26.384 C 13.837,20.289 19.935,20.353 23.28,20.927 C 28.232,21.786 33.861,26.355 35.861,31.627 C 36.182,32.467 36.346,33.134 36.485,33.739 L 36.702,34.652 L 42.294,37.383 L 42.369,37.436 L 42.369,37.436 z M 81.667,7.681 L 81.667,7.681 C 80.612,8.662 80.011,9.999 79.96,11.439 C 79.862,14.409 82.192,16.909 85.159,17.021 C 86.608,17.069 87.977,16.56 89.03,15.574 C 90.083,14.593 90.684,13.258 90.739,11.821 C 90.839,8.85 88.509,6.344 85.534,6.236 C 84.095,6.188 82.72,6.698 81.667,7.681" style="fill:#6eb927;fill-rule:evenodd" id="path21"/>
      <path d="M 97.296,44.674 L 97.232,44.674 C 97.154,44.674 97.093,44.61 97.093,44.533 L 97.093,43.551 L 96.876,43.878 C 96.851,43.914 96.806,43.931 96.765,43.931 L 96.738,43.931 C 96.695,43.931 96.652,43.914 96.629,43.878 L 96.408,43.551 L 96.408,44.533 C 96.408,44.609 96.34,44.674 96.263,44.674 L 96.199,44.674 C 96.121,44.674 96.062,44.61 96.062,44.533 L 96.062,43.356 L 95.402,43.356 L 95.402,44.533 C 95.402,44.609 95.332,44.674 95.254,44.674 L 95.192,44.674 C 95.116,44.674 95.053,44.61 95.053,44.533 L 95.053,43.356 L 94.555,43.356 C 94.477,43.356 94.418,43.306 94.418,43.229 L 94.418,43.156 C 94.418,43.073 94.48,43.027 94.555,43.027 L 96.285,43.027 C 96.357,43.027 96.398,43.055 96.422,43.092 L 96.752,43.589 L 97.082,43.092 C 97.109,43.055 97.148,43.027 97.223,43.027 L 97.444,43.027 L 97.444,44.533 C 97.443,44.609 97.373,44.674 97.296,44.674 z " style="fill:#0d5148" id="path27"/>
      <path d="M 40.78,42.62 C 38.413,42.62 37.106,44.624 37.106,46.008 L 37.106,47.786 C 37.106,49.825 38.773,51.088 40.321,51.088 L 45.744,51.088 C 46.426,51.088 46.567,51.536 46.567,51.911 L 46.567,53.059 C 46.567,53.183 46.546,54.285 45.744,54.285 L 38.343,54.285 C 37.61,54.285 37.078,54.794 37.078,55.492 L 37.078,55.811 C 37.078,56.507 37.609,57.017 38.343,57.017 L 46.147,57.017 C 48.187,57.017 49.504,55.598 49.504,53.402 L 49.504,51.482 C 49.504,49.419 48.018,48.496 46.546,48.496 L 41.21,48.496 C 40.403,48.496 40.04,47.896 40.04,47.47 L 40.04,46.411 C 40.04,45.741 40.487,45.357 41.267,45.357 L 47.175,45.357 C 47.9,45.357 48.443,44.836 48.443,44.147 L 48.443,43.83 C 48.443,43.142 47.888,42.62 47.149,42.62 L 40.78,42.62 z " style="fill:#0d5148" id="path29"/>
      <path d="M 62.96,42.62 C 62.261,42.62 61.694,43.189 61.694,43.889 L 61.694,52.974 C 61.694,53.698 61.102,54.286 60.382,54.286 L 56.261,54.286 C 55.536,54.286 54.949,53.698 54.949,52.974 L 54.949,43.889 C 54.949,43.19 54.383,42.62 53.681,42.62 L 53.279,42.62 C 52.572,42.62 52.013,43.178 52.013,43.889 L 52.013,53.318 C 52.013,55.51 53.74,57.105 56.117,57.105 L 60.523,57.105 C 62.902,57.105 64.628,55.51 64.628,53.318 L 64.628,43.889 C 64.628,43.178 64.071,42.62 63.362,42.62 L 62.96,42.62 z " style="fill:#0d5148" id="path31"/>
      <path d="M 70.855,42.62 C 68.488,42.62 67.179,44.623 67.179,46.008 L 67.179,47.786 C 67.179,49.825 68.849,51.088 70.394,51.088 L 75.818,51.088 C 76.5,51.088 76.644,51.536 76.644,51.911 L 76.644,53.059 C 76.644,53.183 76.619,54.285 75.818,54.285 L 68.42,54.285 C 67.686,54.285 67.152,54.794 67.152,55.492 L 67.152,55.811 C 67.152,56.507 67.685,57.017 68.42,57.017 L 76.219,57.017 C 78.26,57.017 79.578,55.598 79.578,53.402 L 79.578,51.482 C 79.578,49.419 78.096,48.496 76.621,48.496 L 71.285,48.496 C 70.478,48.496 70.115,47.896 70.115,47.47 L 70.115,46.411 C 70.115,45.741 70.562,45.357 71.34,45.357 L 77.252,45.357 C 77.975,45.357 78.52,44.836 78.52,44.147 L 78.52,43.83 C 78.52,43.142 77.963,42.62 77.221,42.62 L 70.855,42.62 z " style="fill:#0d5148" id="path33"/>
      <path d="M 83.324,42.62 C 82.621,42.62 82.088,43.141 82.088,43.83 L 82.088,55.811 C 82.088,56.499 82.609,57.017 83.299,57.017 L 92.846,57.017 C 93.58,57.017 94.112,56.507 94.112,55.811 L 94.112,55.492 C 94.112,54.794 93.581,54.285 92.846,54.285 C 92.846,54.285 85.377,54.285 85.024,54.285 C 85.024,53.973 85.024,51.542 85.024,51.232 C 85.376,51.232 90.754,51.232 90.754,51.232 C 91.486,51.232 92.022,50.721 92.022,50.021 L 92.022,49.707 C 92.022,49.006 91.487,48.496 90.754,48.496 C 90.754,48.496 85.375,48.496 85.024,48.496 C 85.024,48.183 85.024,45.67 85.024,45.357 C 85.376,45.357 92.448,45.357 92.448,45.357 C 93.18,45.357 93.714,44.847 93.714,44.147 L 93.714,43.83 C 93.714,43.13 93.181,42.62 92.448,42.62 L 83.324,42.62 z " style="fill:#0d5148" id="path35"/>
      <path d="M 2.166,48.318 C 0.972,48.318 0,49.251 0,50.396 L 0,54.915 C 0,56.08 0.939,57.029 2.094,57.029 L 5.018,57.029 C 6.172,57.029 7.113,56.08 7.113,54.915 L 7.113,50.396 C 7.113,49.25 6.141,48.318 4.946,48.318 L 2.166,48.318 z M 1.536,54.735 L 1.536,50.611 C 1.536,50.126 1.932,49.73 2.418,49.73 L 4.694,49.73 C 5.17,49.73 5.575,50.134 5.575,50.611 L 5.575,54.735 C 5.575,55.22 5.179,55.617 4.694,55.617 L 2.398,55.617 C 1.915,55.617 1.536,55.229 1.536,54.735 z " style="fill:#6eb927" id="path39"/>
      <path d="M 13.73,48.265 C 12.884,48.265 12.251,48.57 11.74,48.815 C 11.43,48.962 11.163,49.09 10.951,49.09 C 10.858,49.09 10.778,49.049 10.736,48.98 L 10.542,48.608 C 10.493,48.51 10.298,48.319 10.055,48.319 L 9.768,48.319 C 9.493,48.319 9.269,48.567 9.269,48.875 L 9.269,60.33 C 9.269,60.69 9.551,60.973 9.912,60.973 L 10.164,60.973 C 10.518,60.973 10.807,60.684 10.807,60.33 L 10.807,56.528 C 10.807,56.415 10.882,56.294 10.953,56.294 C 11.166,56.294 11.434,56.415 11.744,56.559 C 12.254,56.792 12.888,57.082 13.732,57.082 L 14,57.082 C 15.491,57.082 16.418,56.231 16.418,54.86 L 16.418,50.486 C 16.418,49.137 15.47,48.264 14,48.264 L 13.73,48.264 L 13.73,48.265 z M 10.806,54.646 L 10.806,50.702 C 10.806,50.157 11.232,49.731 11.777,49.731 L 13.91,49.731 C 14.454,49.731 14.88,50.157 14.88,50.702 L 14.88,54.646 C 14.88,55.181 14.446,55.618 13.91,55.618 L 11.777,55.618 C 11.241,55.617 10.806,55.181 10.806,54.646 z " style="fill:#6eb927" id="path41"/>
      <path d="M 20.741,48.318 C 19.546,48.318 18.573,49.251 18.573,50.396 L 18.573,54.879 C 18.573,56.043 19.516,57.028 20.632,57.028 L 23.646,57.028 C 24.018,57.028 24.29,56.771 24.29,56.42 L 24.29,56.223 C 24.29,55.87 24.019,55.617 23.646,55.617 L 21.172,55.617 C 20.479,55.617 20.111,55.275 20.111,54.628 C 20.111,54.628 20.111,53.498 20.111,53.317 C 20.312,53.317 24.578,53.317 24.578,53.317 C 25.294,53.317 25.724,52.876 25.724,52.135 L 25.724,50.396 C 25.724,49.25 24.75,48.318 23.556,48.318 L 20.741,48.318 z M 20.111,50.594 C 20.111,50.111 20.489,49.731 20.973,49.731 L 23.322,49.731 C 23.807,49.731 24.183,50.111 24.183,50.594 C 24.183,50.594 24.183,51.813 24.183,51.993 C 23.99,51.993 20.306,51.993 20.111,51.993 C 20.111,51.812 20.111,50.594 20.111,50.594 z " style="fill:#6eb927" id="path43"/>
      <path d="M 31.93,48.265 C 31.089,48.265 30.453,48.567 29.945,48.81 C 29.628,48.96 29.352,49.09 29.133,49.09 C 29.032,49.09 28.994,49.078 28.92,48.947 L 28.741,48.624 C 28.64,48.423 28.47,48.318 28.236,48.318 L 27.984,48.318 C 27.685,48.318 27.467,48.551 27.467,48.874 L 27.467,56.385 C 27.467,56.746 27.75,57.03 28.11,57.03 L 28.361,57.03 C 28.716,57.03 29.005,56.74 29.005,56.385 L 29.005,50.701 C 29.005,50.166 29.441,49.73 29.976,49.73 L 32.11,49.73 C 32.645,49.73 33.08,50.166 33.08,50.701 L 33.08,56.385 C 33.08,56.746 33.363,57.03 33.723,57.03 L 33.975,57.03 C 34.33,57.03 34.619,56.74 34.619,56.385 L 34.619,50.487 C 34.619,49.138 33.67,48.265 32.2,48.265 L 31.93,48.265 L 31.93,48.265 z " style="fill:#6eb927" id="path45"/>
    </g>
  </g>
</svg>

in current kitchensink it renders of screen and very far from its viewbox. you have to shrink and move a lot and move it to the right bottom to see the logo appear.

ehm sorry for linux fan, i misleaded opensuse with debian. sorry. This is opensuse logo.

pl = (px * px) / (rx * rx) + (py * py) / (ry * ry);

pl *= 0.25;
Copy link
Member

Choose a reason for hiding this comment

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

What is this for?

Copy link
Member Author

Choose a reason for hiding this comment

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

there were 4 multiply by 0.5 , at the end is equal to one by 0.25 if you check the original code.
px is created adding x and y both multiplyed by 0.5 , same for py. then they both get multiplied by themselves. so 0.5 get 0.25 on both. so at the end you can just multiply the sum of those by 0.25. just to reduce the number of multiply used.

kangax added a commit that referenced this pull request Jun 21, 2014
@kangax kangax merged commit 4824771 into fabricjs:master Jun 21, 2014
@kangax
Copy link
Member

kangax commented Jun 21, 2014

I reverted some of your changes because they were breaking other shapes

jmili8ut8bv5ztvwlnva0l6z8mu_71ngi6t4jhhvgvg

flt37amqezh53lguzey7qns8ozcsjwei8qequad1tqs

@asturur
Copy link
Member Author

asturur commented Jun 21, 2014

i m gonna check. if it is just position and not distorted probably is beacause of negative viewbox.

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.

2 participants