# all files / diagram-js/lib/util/ SvgTransformUtil.js

81.25% Statements 13/16
100% Branches 4/4
75% Functions 3/4
81.25% Lines 13/16

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62

    1565×
    1565×

    1565×
    1565×

    1565×
    1565×

    1565×

    17502×
    17502×

    17502×

    210×
    210×

    210×

     import {
      transform as svgTransform,
      createTransform
    } from 'tiny-svg';

    /**
     * @param {<SVGElement>} element
     * @param {Number} x
     * @param {Number} y
     * @param {Number} angle
     * @param {Number} amount
     */
    export function transform(gfx, x, y, angle, amount) {
      var translate = createTransform();
      translate.setTranslate(x, y);

      var rotate = createTransform();
      rotate.setRotate(angle, 0, 0);

      var scale = createTransform();
      scale.setScale(amount || 1, amount || 1);

      svgTransform(gfx, [ translate, rotate, scale ]);
    }

    /**
     * @param {SVGElement} element
     * @param {Number} x
     * @param {Number} y
     */
    export function translate(gfx, x, y) {
      var translate = createTransform();
      translate.setTranslate(x, y);

      svgTransform(gfx, translate);
    }

    /**
     * @param {SVGElement} element
     * @param {Number} angle
     */
    export function rotate(gfx, angle) {
      var rotate = createTransform();
      rotate.setRotate(angle, 0, 0);

      svgTransform(gfx, rotate);
    }

    /**
     * @param {SVGElement} element
     * @param {Number} amount
     */
    export function scale(gfx, amount) {
      var scale = createTransform();
      scale.setScale(amount, amount);

      svgTransform(gfx, scale);
    }