-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Rodrigo de Almeida Pereira
committed
Nov 19, 2019
1 parent
06321d4
commit 327ed59
Showing
2 changed files
with
46 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,32 @@ | ||
import { isUndefined } from './utils' | ||
import { translate } from './translate' | ||
import { transform } from './transform' | ||
|
||
/** | ||
* Calculate a scaling matrix | ||
* @param sx {number} Scaling on axis x | ||
* @param [sy = sx] {number} Scaling on axis y (default sx) | ||
* @returns {Matrix} Affine Matrix | ||
*/ | ||
export function scale (sx, sy = undefined) { | ||
export function scale (sx, sy = undefined, cx = undefined, cy = undefined) { | ||
if (isUndefined(sy)) sy = sx | ||
return { | ||
|
||
const scaleMatrix = { | ||
a: sx, | ||
c: 0, | ||
e: 0, | ||
b: 0, | ||
d: sy, | ||
f: 0 | ||
} | ||
|
||
if (isUndefined(cx) || isUndefined(cy)) { | ||
return scaleMatrix | ||
} | ||
|
||
return transform([ | ||
translate(cx, cy), | ||
scaleMatrix, | ||
translate(-cx, -cy) | ||
]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters