UNPKG

@cloudinary/url-gen

Version:

Cloudinary URL-Gen SDK ========================= [![Build Status](https://api.travis-ci.com/cloudinary/js-url-gen.svg?branch=master)](https://app.travis-ci.com/github/cloudinary/js-url-gen) ## About The Cloudinary URL-Gen SDK allows you to quickly and eas

56 lines (52 loc) 2.02 kB
'use strict'; var Action = require('./Action-34aa7481.cjs'); var Qualifier = require('./Qualifier-6633a22f.cjs'); const QUALIFIER_KEY = 'a'; /** * @description Rotates or flips an image or video. * * <b>Learn more:</b> {@link https://cloudinary.com/documentation/effects_and_artistic_enhancements#rotating_images|Rotating images} * {@link https://cloudinary.com/documentation/video_effects_and_enhancements#rotating_videos|Rotating videos} * @extends SDK.Action * @memberOf Actions.Rotate * @see Visit {@link Actions.Rotate|Rotate} for an example */ class RotateAction extends Action.Action { constructor(angle) { super(); this._actionModel = {}; this.addQualifier(new Qualifier.Qualifier(QUALIFIER_KEY, angle)); this._actionModel.actionType = 'rotateByAngle'; if (angle) { this._actionModel.angle = angle; } } /** * @description Rotates an asset using a defined mode. * @param {Qualifiers.RotationMode | RotationModeType | string} rotationMode * For a list of supported rotation modes see {@link Qualifiers.RotationMode| types of rotation modes} for * possible values * @return {this} */ mode(rotationMode) { return this.addValueToQualifier(QUALIFIER_KEY, rotationMode); } /** * @description Rotates an asset by the specified degrees. * @param {number} degrees rotation in degrees e.g 90, 45, 33 * @return {this} */ angle(degrees) { this._actionModel.angle = degrees; return this.addValueToQualifier(QUALIFIER_KEY, degrees); } static fromJson(actionModel) { const { angle } = actionModel; // We are using this() to allow inheriting classes to use super.fromJson.apply(this, [actionModel]) // This allows the inheriting classes to determine the class to be created const result = new this(angle); return result; } } var RotateAction$1 = RotateAction; exports.RotateAction = RotateAction$1;