diff --git a/models/Star/Star.js b/models/Star/Star.js new file mode 100644 index 0000000..3fb5e53 --- /dev/null +++ b/models/Star/Star.js @@ -0,0 +1,32 @@ +const uuid = require('uuid-v4'); +const Layer = require('../Layer'); +const Rect = require('../Rect'); +const Style = require('../Style'); + +class Star extends Layer { + static get Model() { + return { + ...super.Model, + _class: 'star', + numberOfPoints: 5, + radius: 0, + }; + } + + constructor(args, json) { + super(args, json); + if (!json) { + const id = args.id || uuid().toUpperCase(); + Object.assign(this, Star.Model, { + do_objectID: id, + name: args.name || id, + style: args.style ? Style.LayerStyle(args.style) : null, + frame: new Rect(args.frame), + }); + if (args.numberOfPoints) this.numberOfPoints = args.numberOfPoints; + if (args.radius) this.radius = args.radius; + } + } +} + +module.exports = Star; diff --git a/models/Star/index.d.ts b/models/Star/index.d.ts new file mode 100644 index 0000000..4450a06 --- /dev/null +++ b/models/Star/index.d.ts @@ -0,0 +1,9 @@ +import Layer from '../Layer'; + +declare class Star extends Layer { + _class: 'star'; + numberOfPoints: number; + radius: number; +} + +export = Star; diff --git a/models/Star/index.js b/models/Star/index.js new file mode 100644 index 0000000..c11ff89 --- /dev/null +++ b/models/Star/index.js @@ -0,0 +1 @@ +module.exports = require('./Star'); diff --git a/models/index.d.ts b/models/index.d.ts index a2b7474..7acbcc3 100644 --- a/models/index.d.ts +++ b/models/index.d.ts @@ -26,6 +26,7 @@ import ShapePath from './ShapePath'; import SharedStyle from './SharedStyle'; import Sketch from './Sketch'; import Slice from './Slice'; +import Star from './Star'; import StringAttribute from './StringAttribute'; import Style from './Style'; import SymbolInstance from './SymbolInstance'; @@ -66,6 +67,7 @@ export { SharedStyle, Sketch, Slice, + Star, StringAttribute, Style, SymbolInstance, diff --git a/models/index.js b/models/index.js index 4f19f23..735a43d 100644 --- a/models/index.js +++ b/models/index.js @@ -40,6 +40,7 @@ module.exports = { SharedStyle: require('./SharedStyle'), Sketch: require('./Sketch'), Slice: require('./Slice'), + Star: require('./Star'), StringAttribute: require('./StringAttribute'), Style: require('./Style'), SymbolInstance: require('./SymbolInstance'),