
This is a flat (without history) import of (some of) the content from our markdown module. We've imported this without history because the repo contains our blog posts and showcases posts content prior to porting them to strapi. Since this contains many images, it would balloon the size of this repo to import the full history. Instead, please refer to the history of the (archived) markdown repo at: https://github.com/freesewing/markdown
2.2 KiB
2.2 KiB
title | for | about |
---|---|---|
Create a new design based on an existing design | developers | Shows how to create a variation of a pre-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 [
'draftBack',
'draftTail',
'draftTopSleeve',
'draftUnderSleeve',
'draftBelt',
'draftCollarStand',
'draftCollar',
'draftCuffFacing',
'draftPocket',
'draftPocketFlap',
'draftPocketLining',
'draftChestPocketWelt',
'draftChestPocketBag',
'draftInnerPocketWelt',
'draftInnerPocketBag',
'draftInnerPocketTab'
]) {
Pattern.prototype[m] = function(part) {
return new Carlton(this.settings)[m](part)
}
}