GUI -- SvgUtil- added scale, skewX and rotate functions.
Change-Id: If7c3af6bba81905b3bbb887edcf9bf5acbb927e1
Showing
2 changed files
with
29 additions
and
2 deletions
| ... | @@ -258,6 +258,18 @@ | ... | @@ -258,6 +258,18 @@ |
| 258 | return 'translate(' + x + ',' + y + ')'; | 258 | return 'translate(' + x + ',' + y + ')'; |
| 259 | } | 259 | } |
| 260 | 260 | ||
| 261 | + function scale(x, y) { | ||
| 262 | + return 'scale(' + x + ',' + y + ')'; | ||
| 263 | + } | ||
| 264 | + | ||
| 265 | + function skewX(x) { | ||
| 266 | + return 'skewX(' + x + ')'; | ||
| 267 | + } | ||
| 268 | + | ||
| 269 | + function rotate(deg) { | ||
| 270 | + return 'rotate(' + deg + ')'; | ||
| 271 | + } | ||
| 272 | + | ||
| 261 | function stripPx(s) { | 273 | function stripPx(s) { |
| 262 | return s.replace(/px$/,''); | 274 | return s.replace(/px$/,''); |
| 263 | } | 275 | } |
| ... | @@ -279,6 +291,9 @@ | ... | @@ -279,6 +291,9 @@ |
| 279 | loadGlowDefs: loadGlowDefs, | 291 | loadGlowDefs: loadGlowDefs, |
| 280 | cat7: cat7, | 292 | cat7: cat7, |
| 281 | translate: translate, | 293 | translate: translate, |
| 294 | + scale: scale, | ||
| 295 | + skewX: skewX, | ||
| 296 | + rotate: rotate, | ||
| 282 | stripPx: stripPx, | 297 | stripPx: stripPx, |
| 283 | safeId: safeId, | 298 | safeId: safeId, |
| 284 | visible: function (el, x) { | 299 | visible: function (el, x) { | ... | ... |
| ... | @@ -41,7 +41,7 @@ describe('factory: fw/svg/svgUtil.js', function() { | ... | @@ -41,7 +41,7 @@ describe('factory: fw/svg/svgUtil.js', function() { |
| 41 | it('should define api functions', function () { | 41 | it('should define api functions', function () { |
| 42 | expect(fs.areFunctions(sus, [ | 42 | expect(fs.areFunctions(sus, [ |
| 43 | 'createDragBehavior', 'loadGlowDefs', 'cat7', | 43 | 'createDragBehavior', 'loadGlowDefs', 'cat7', |
| 44 | - 'translate', | 44 | + 'translate', 'scale', 'skewX', 'rotate', |
| 45 | 'stripPx', 'safeId', 'visible' | 45 | 'stripPx', 'safeId', 'visible' |
| 46 | ])).toBeTruthy(); | 46 | ])).toBeTruthy(); |
| 47 | }); | 47 | }); |
| ... | @@ -94,7 +94,7 @@ describe('factory: fw/svg/svgUtil.js', function() { | ... | @@ -94,7 +94,7 @@ describe('factory: fw/svg/svgUtil.js', function() { |
| 94 | expect(sus.cat7().getColor('zoo', false, 'light')).toEqual('#8A2979'); | 94 | expect(sus.cat7().getColor('zoo', false, 'light')).toEqual('#8A2979'); |
| 95 | }); | 95 | }); |
| 96 | 96 | ||
| 97 | - // === translate() | 97 | + // === translate(), scale(), skewX(), rotate() |
| 98 | 98 | ||
| 99 | it('should translate from two args', function () { | 99 | it('should translate from two args', function () { |
| 100 | expect(sus.translate(1,2)).toEqual('translate(1,2)'); | 100 | expect(sus.translate(1,2)).toEqual('translate(1,2)'); |
| ... | @@ -104,6 +104,18 @@ describe('factory: fw/svg/svgUtil.js', function() { | ... | @@ -104,6 +104,18 @@ describe('factory: fw/svg/svgUtil.js', function() { |
| 104 | expect(sus.translate([3,4])).toEqual('translate(3,4)'); | 104 | expect(sus.translate([3,4])).toEqual('translate(3,4)'); |
| 105 | }); | 105 | }); |
| 106 | 106 | ||
| 107 | + it('should scale', function () { | ||
| 108 | + expect(sus.scale(1.5,2.5)).toEqual('scale(1.5,2.5)'); | ||
| 109 | + }); | ||
| 110 | + | ||
| 111 | + it('should skewX', function () { | ||
| 112 | + expect(sus.skewX(3.14)).toEqual('skewX(3.14)'); | ||
| 113 | + }); | ||
| 114 | + | ||
| 115 | + it('should rotate', function () { | ||
| 116 | + expect(sus.rotate(45)).toEqual('rotate(45)'); | ||
| 117 | + }); | ||
| 118 | + | ||
| 107 | 119 | ||
| 108 | // === stripPx() | 120 | // === stripPx() |
| 109 | 121 | ... | ... |
-
Please register or login to post a comment