Skip to content
This repository
Browse code

Fixed negative scaling (hat tip to http://github.com/mal)

added license.txt
  • Loading branch information...
commit 869cb4347a0f57d39a2bea12a840bfc91227b5d8 1 parent d34b4b3
Dmitry Baranovskiy authored

Showing 3 changed files with 51 additions and 23 deletions. Show diff stats Hide diff stats

  1. +21 0 license.txt
  2. +3 3 raphael-min.js
  3. +27 20 raphael.js
21 license.txt
... ... @@ -0,0 +1,21 @@
  1 +The MIT License
  2 +
  3 +Copyright (c) 2008-2010 Dmitry Baranovskiy
  4 +
  5 +Permission is hereby granted, free of charge, to any person obtaining a copy
  6 +of this software and associated documentation files (the "Software"), to deal
  7 +in the Software without restriction, including without limitation the rights
  8 +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9 +copies of the Software, and to permit persons to whom the Software is
  10 +furnished to do so, subject to the following conditions:
  11 +
  12 +The above copyright notice and this permission notice shall be included in
  13 +all copies or substantial portions of the Software.
  14 +
  15 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21 +THE SOFTWARE.
6 raphael-min.js
3 additions, 3 deletions not shown
47 raphael.js
@@ -2829,23 +2829,28 @@
2829 2829 var bb = this.getBBox(),
2830 2830 rcx = bb.x + bb.width / 2,
2831 2831 rcy = bb.y + bb.height / 2,
2832   - kx = x / this._.sx,
2833   - ky = y / this._.sy;
  2832 + kx = abs(x / this._.sx),
  2833 + ky = abs(y / this._.sy);
2834 2834 cx = (+cx || cx == 0) ? cx : rcx;
2835 2835 cy = (+cy || cy == 0) ? cy : rcy;
2836   - var dirx = ~~(x / abs(x)),
  2836 + var posx = this._.sx > 0,
  2837 + posy = this._.sy > 0,
  2838 + dirx = ~~(x / abs(x)),
2837 2839 diry = ~~(y / abs(y)),
  2840 + dkx = kx * dirx,
  2841 + dky = ky * diry,
2838 2842 s = this.node.style,
2839   - ncx = cx + (rcx - cx) * kx,
2840   - ncy = cy + (rcy - cy) * ky;
  2843 + ncx = cx + abs(rcx - cx) * dkx * (rcx > cx == posx ? 1 : -1),
  2844 + ncy = cy + abs(rcy - cy) * dky * (rcy > cy == posy ? 1 : -1),
  2845 + fr = (x * dirx > y * diry ? ky : kx);
2841 2846 switch (this.type) {
2842 2847 case "rect":
2843 2848 case "image":
2844   - var neww = a.width * dirx * kx,
2845   - newh = a.height * diry * ky;
  2849 + var neww = a.width * kx,
  2850 + newh = a.height * ky;
2846 2851 this.attr({
2847 2852 height: newh,
2848   - r: a.r * mmin(dirx * kx, diry * ky),
  2853 + r: a.r * fr,
2849 2854 width: neww,
2850 2855 x: ncx - neww / 2,
2851 2856 y: ncy - newh / 2
@@ -2854,9 +2859,9 @@
2854 2859 case "circle":
2855 2860 case "ellipse":
2856 2861 this.attr({
2857   - rx: a.rx * dirx * kx,
2858   - ry: a.ry * diry * ky,
2859   - r: a.r * mmin(dirx * kx, diry * ky),
  2862 + rx: a.rx * kx,
  2863 + ry: a.ry * ky,
  2864 + r: a.r * fr,
2860 2865 cx: ncx,
2861 2866 cy: ncy
2862 2867 });
@@ -2869,7 +2874,9 @@
2869 2874 break;
2870 2875 case "path":
2871 2876 var path = pathToRelative(a.path),
2872   - skip = true;
  2877 + skip = true,
  2878 + fx = posx ? dkx : kx,
  2879 + fy = posy ? dky : ky;
2873 2880 for (var i = 0, ii = path[length]; i < ii; i++) {
2874 2881 var p = path[i],
2875 2882 P0 = upperCase.call(p[0]);
@@ -2879,22 +2886,22 @@
2879 2886 skip = false;
2880 2887 }
2881 2888 if (P0 == "A") {
2882   - p[path[i][length] - 2] *= kx;
2883   - p[path[i][length] - 1] *= ky;
2884   - p[1] *= dirx * kx;
2885   - p[2] *= diry * ky;
2886   - p[5] = +!(dirx + diry ? !+p[5] : +p[5]);
  2889 + p[path[i][length] - 2] *= fx;
  2890 + p[path[i][length] - 1] *= fy;
  2891 + p[1] *= kx;
  2892 + p[2] *= ky;
  2893 + p[5] = +(dirx + diry ? !+p[4] : !!+p[4]);
2887 2894 } else if (P0 == "H") {
2888 2895 for (var j = 1, jj = p[length]; j < jj; j++) {
2889   - p[j] *= kx;
  2896 + p[j] *= fx;
2890 2897 }
2891 2898 } else if (P0 == "V") {
2892 2899 for (j = 1, jj = p[length]; j < jj; j++) {
2893   - p[j] *= ky;
  2900 + p[j] *= fy;
2894 2901 }
2895 2902 } else {
2896 2903 for (j = 1, jj = p[length]; j < jj; j++) {
2897   - p[j] *= (j % 2) ? kx : ky;
  2904 + p[j] *= (j % 2) ? fx : fy;
2898 2905 }
2899 2906 }
2900 2907 }

0 comments on commit 869cb43

Please sign in to comment.
Something went wrong with that request. Please try again.