Mercurial > hg > digilib
comparison client/digitallibrary/jquery/dlGeometry.js @ 668:9f8056d6c289 jquery
transformation with mirror works now too!
author | robcast |
---|---|
date | Tue, 25 Jan 2011 22:04:27 +0100 |
parents | 0d3d9517e448 |
children | a653d96166e9 |
comparison
equal
deleted
inserted
replaced
666:1e9d7d92135c | 668:9f8056d6c289 |
---|---|
302 }; | 302 }; |
303 // add class methods to instance | 303 // add class methods to instance |
304 that.getRotation = transform.getRotation; | 304 that.getRotation = transform.getRotation; |
305 that.getRotationAround = transform.getRotationAround; | 305 that.getRotationAround = transform.getRotationAround; |
306 that.getTranslation = transform.getTranslation; | 306 that.getTranslation = transform.getTranslation; |
307 that.getMirror = transform.getMirror; | |
307 that.getScale = transform.getScale; | 308 that.getScale = transform.getScale; |
308 | 309 |
309 return that; | 310 return that; |
310 }; | 311 }; |
311 | 312 |
324 return transform(traf); | 325 return transform(traf); |
325 } | 326 } |
326 return transform(); | 327 return transform(); |
327 }; | 328 }; |
328 | 329 |
330 transform.getRotationAround = function (angle, pos) { | |
331 // returns a Transform that is a rotation by angle degrees around pos | |
332 var traf = transform.getTranslation({x : -pos.x, y : -pos.y}); | |
333 traf.concat(transform.getRotation(angle)); | |
334 traf.concat(transform.getTranslation(pos)); | |
335 return traf; | |
336 }; | |
337 | |
329 transform.getTranslation = function (pos) { | 338 transform.getTranslation = function (pos) { |
330 // returns a Transform that is a translation by [pos.x, pos,y] | 339 // returns a Transform that is a translation by [pos.x, pos,y] |
331 var traf = { | 340 var traf = { |
332 m02 : pos.x, | 341 m02 : pos.x, |
333 m12 : pos.y | 342 m12 : pos.y |
334 }; | 343 }; |
335 return transform(traf); | 344 return transform(traf); |
336 }; | 345 }; |
337 | 346 |
338 transform.getRotationAround = function (angle, pos) { | 347 transform.getMirror = function (type) { |
339 // returns a Transform that is a rotation by angle degrees around pos | 348 // returns a Transform that is a mirror about the axis type |
340 var traf = transform.getTranslation({x : -pos.x, y : -pos.y}); | 349 if (type === 'x') { |
341 traf.concat(transform.getRotation(angle)); | 350 var traf = { |
342 traf.concat(transform.getTranslation(pos)); | 351 m00 : 1, |
343 return traf; | 352 m11 : -1 |
344 }; | 353 }; |
345 | 354 } else { |
355 var traf = { | |
356 m00 : -1, | |
357 m11 : 1 | |
358 }; | |
359 } | |
360 return transform(traf); | |
361 }; | |
362 | |
346 transform.getScale = function (size) { | 363 transform.getScale = function (size) { |
347 // returns a Transform that is a scale by [size.width, size.height] | 364 // returns a Transform that is a scale by [size.width, size.height] |
348 var traf = { | 365 var traf = { |
349 m00 : size.width, | 366 m00 : size.width, |
350 m11 : size.height | 367 m11 : size.height |