2021-04-23 19:08:34 -04:00

38 lines
1.8 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var IPropertyDescriptor_1 = require("../IPropertyDescriptor");
var tokenizer_1 = require("../syntax/tokenizer");
exports.transform = {
name: 'transform',
initialValue: 'none',
prefix: true,
type: IPropertyDescriptor_1.PropertyDescriptorParsingType.VALUE,
parse: function (token) {
if (token.type === tokenizer_1.TokenType.IDENT_TOKEN && token.value === 'none') {
return null;
}
if (token.type === tokenizer_1.TokenType.FUNCTION) {
var transformFunction = SUPPORTED_TRANSFORM_FUNCTIONS[token.name];
if (typeof transformFunction === 'undefined') {
throw new Error("Attempting to parse an unsupported transform function \"" + token.name + "\"");
}
return transformFunction(token.values);
}
return null;
}
};
var matrix = function (args) {
var values = args.filter(function (arg) { return arg.type === tokenizer_1.TokenType.NUMBER_TOKEN; }).map(function (arg) { return arg.number; });
return values.length === 6 ? values : null;
};
// doesn't support 3D transforms at the moment
var matrix3d = function (args) {
var values = args.filter(function (arg) { return arg.type === tokenizer_1.TokenType.NUMBER_TOKEN; }).map(function (arg) { return arg.number; });
var a1 = values[0], b1 = values[1], _a = values[2], _b = values[3], a2 = values[4], b2 = values[5], _c = values[6], _d = values[7], _e = values[8], _f = values[9], _g = values[10], _h = values[11], a4 = values[12], b4 = values[13], _j = values[14], _k = values[15];
return values.length === 16 ? [a1, b1, a2, b2, a4, b4] : null;
};
var SUPPORTED_TRANSFORM_FUNCTIONS = {
matrix: matrix,
matrix3d: matrix3d
};
//# sourceMappingURL=transform.js.map