1.3.0 • Published 1 year ago

2d-rotate v1.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Features

  • Node.JS and browser support
  • Fast, easy and lightweight (0 dependency)
  • Bi-directional rotation (clockwise, counter-clockwise)
  • Working for both square and non-square matrices
  • StandardJS

Installation

# Using Yarn
yarn add 2d-rotate

# Using NPM
npm i 2d-rotate

Usage

import { rotate2d, RotationDirection } from '2d-rotate'
// const { rotate2d, RotationDirection } = require('2d-rotate')

// Clockwise
rotate2d([
  [1, 2, 3], // [7, 4, 1],
  [4, 5, 6], // [8, 5, 2],
  [7, 8, 9]  // [9, 6, 3]
], RotationDirection.CLOCKWISE) /* Optional, clockwise by default */

// Counter-clockwise
rotate2d([
  [1, 2, 3], // [3, 6, 9],
  [4, 5, 6], // [2, 5, 8],
  [7, 8, 9]  // [1, 4, 7]
], RotationDirection.COUNTER_CLOCKWISE)