Support global transformation and italics

This commit is contained in:
Belleve Invis 2015-07-19 20:30:20 +08:00
parent 0126d044e6
commit 4ba6733f37
8 changed files with 1043 additions and 632 deletions

19
support/transform.js Normal file
View file

@ -0,0 +1,19 @@
exports.transformPoint = function(tfm, pt){
return {
x : pt.x * tfm.xx + pt.y * tfm.yx + tfm.x,
y : pt.x * tfm.xy + pt.y * tfm.yy + tfm.y,
onCurve: pt.onCurve,
cubic: pt.cubic
}
}
exports.untransform = function(tfm, pt){
var xx = pt.x - tfm.x
var yy = pt.y - tfm.y
var denom = tfm.xx * tfm.yy - tfm.xy * tfm.yx
return {
x : (xx * tfm.yy - yy * tfm.yx) / denom,
y : (yy * tfm.xx - xx * tfm.xy) / denom,
onCurve: pt.onCurve,
cubic: pt.cubic
}
}