html5 - Apply transformation matrix around the center of an element -


i using raphael make manipulations in svg. in order save svg image use canvg render svg in canvas. transformations of images inside svg rendered in canvas not right. canvg uses native transform() method of html5 apply transformations using below code in line 571 of canvg.

ctx.transform(this.m[0], this.m[1], this.m[2], this.m[3], this.m[4], this.m[5]); 

but results in transformations rotations , scaling done around origin of image. in raphael transformations applied around center of image.

so possible apply transformations happens around center of image?

you can make own function makes transformations happen around center of image given image's center points.

the theory around making things transform center follows :

  1. translate image <-x,-y,-z>, (x,y,z) image's center.
  2. do transformation want do
  3. translate image <x,y,z>. (you're returning original position now)

Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -