UNPKG

sketch-json-parse

Version:

sketch-json解析

30 lines (29 loc) 1.02 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.parseProperty = void 0; const utils_1 = require("../common/utils"); /** * 基础属性解析 * @param layer */ const parseProperty = (layer) => { var _a; const { frame, name, style, points, _class, symbolName = '', sharedLayerStyleName = '', sharedTextStyleName = '' } = layer; return { name, position: { x: frame.x, y: frame.y, }, size: { width: frame.width, height: frame.height, }, opacity: (0, utils_1.precisionControl)((_a = style.contextSettings) === null || _a === void 0 ? void 0 : _a.opacity, 0.01), radius: _class === 'rectangle' && points.length === 4 ? points.map(({ cornerRadius }) => +cornerRadius) : [0, 0, 0, 0], // 类型为rectangle且有4个point才会有圆角值 symbolName, sharedLayerStyleName, sharedTextStyleName, }; }; exports.parseProperty = parseProperty;