1
0
Fork 0
freesewing/packages/core/src/design.mjs

30 lines
759 B
JavaScript
Raw Normal View History

import { Pattern } from './pattern.mjs'
import { loadDesignDefaults } from './config.mjs'
/*
* The Design constructor. Returns a Pattern constructor
* So it's sort of a super-constructor
*/
export function Design(config) {
// Initialize config with defaults
config = { ...loadDesignDefaults(), ...config }
// Create the pattern constructor
const pattern = function (...sets) {
// Pass the design config
2019-08-03 15:03:33 +02:00
Pattern.call(this, config)
// Pass the pattern settings
return this.__applySettings(sets)
2019-08-03 15:03:33 +02:00
}
2019-02-16 07:28:56 +01:00
// Set up inheritance
2019-08-03 15:03:33 +02:00
pattern.prototype = Object.create(Pattern.prototype)
pattern.prototype.constructor = pattern
2019-02-16 07:28:56 +01:00
// Make config available without need to instantiate pattern
pattern.config = config
2019-08-03 15:03:33 +02:00
return pattern
2019-02-16 07:28:56 +01:00
}