Create a new design based on an existing design

See this example in our source code

The example below is from Aaron, which is based on Brian.

Brian has a part called base that is hidden by default. We will use this part as a dependency, and also hide it.

This is what it looks like in the Aaron config file:

  dependencies: {
    front: 'base',
    back: 'front'
  inject: {
    front: 'base',
    back: 'front'
  hide: ['base'],

And here is the code:

import freesewing from '@freesewing/core'
import Brian from '@freesewing/brian'
import plugins from '@freesewing/plugin-bundle'
import config from '../config'
// Parts
import draftBack from './back'
import draftFront from './front'

// Create design
const Pattern = new freesewing.Design(config, plugins)

// Attach draft methods to prototype
Pattern.prototype.draftBase = function(part) {
  // Getting the base part from Brian
  return new Brian(this.settings).draftBase(part)
Pattern.prototype.draftFront = part => draftFront(part)
Pattern.prototype.draftBack = part => draftBack(part)

export default Pattern

If you have a lot of parts to inherit, you can create a loop like in this example from Carlita:

// Attach draft methods from Carlton to prototype
for (let m of [
]) {
  Pattern.prototype[m] = function(part) {
    return new Carlton(this.settings)[m](part)