How to use the @antv/matrix-util.mat3.transform function in @antv/matrix-util

To help you get started, we’ve selected a few @antv/matrix-util examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github antvis / G2 / packages / g2 / src / animate / util.ts View on Github external
export function getScaledMatrix(shape, v, direct) {
  let scaledMatrix;

  shape.apply(v);
  const x = v[0];
  const y = v[1];

  if (direct === 'x') {
    shape.transform([
      [ 't', -x, -y ],
      [ 's', 0.01, 1 ],
      [ 't', x, y ],
    ]);
    const matrix = shape.getMatrix();
    scaledMatrix = mat3.transform(matrix, [
      [ 't', -x, -y ],
      [ 's', 100, 1 ],
      [ 't', x, y ],
    ]);
  } else if (direct === 'y') {
    shape.transform([
      [ 't', -x, -y ],
      [ 's', 1, 0.01 ],
      [ 't', x, y ],
    ]);
    const matrix = shape.getMatrix();
    scaledMatrix = mat3.transform(matrix, [
      [ 't', -x, -y ],
      [ 's', 1, 100 ],
      [ 't', x, y ],
    ]);
github antvis / G2 / packages / g2 / src / animate / util.ts View on Github external
[ 't', x, y ],
    ]);
    const matrix = shape.getMatrix();
    scaledMatrix = mat3.transform(matrix, [
      [ 't', -x, -y ],
      [ 's', 100, 1 ],
      [ 't', x, y ],
    ]);
  } else if (direct === 'y') {
    shape.transform([
      [ 't', -x, -y ],
      [ 's', 1, 0.01 ],
      [ 't', x, y ],
    ]);
    const matrix = shape.getMatrix();
    scaledMatrix = mat3.transform(matrix, [
      [ 't', -x, -y ],
      [ 's', 1, 100 ],
      [ 't', x, y ],
    ]);
  } else if (direct === 'xy') {
    shape.transform([
      [ 't', -x, -y ],
      [ 's', 0.01, 0.01 ],
      [ 't', x, y ],
    ]);
    const matrix = shape.getMatrix();
    scaledMatrix = mat3.transform(matrix, [
      [ 't', -x, -y ],
      [ 's', 100, 100 ],
      [ 't', x, y ],
    ]);