feat(examples): Added more examples
This commit is contained in:
parent
7f555ec899
commit
1257469ade
5 changed files with 73 additions and 3 deletions
|
@ -125,6 +125,11 @@ create-freesewing-pattern:
|
|||
diana:
|
||||
peer:
|
||||
'@freesewing/brian': *freesewing
|
||||
example:
|
||||
peer:
|
||||
'@freesewing/plugin-mirror': *freesewing
|
||||
'@freesewing/plugin-bartack': *freesewing
|
||||
'@freesewing/plugin-buttons': *freesewing
|
||||
gatsby-remark-jargon:
|
||||
_:
|
||||
'remark-jargon': *freesewing
|
||||
|
|
|
@ -43,11 +43,13 @@ export default {
|
|||
'path_start',
|
||||
'path_translate',
|
||||
'path_trim',
|
||||
'plugin_bartack',
|
||||
'plugin_buttons',
|
||||
'plugin_cutonfold',
|
||||
'plugin_dimension',
|
||||
'plugin_grainline',
|
||||
'plugin_logo',
|
||||
'plugin_mirror',
|
||||
'plugin_round',
|
||||
'plugin_scalebox',
|
||||
'plugin_sprinkle',
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
import freesewing from '@freesewing/core'
|
||||
import plugins from '@freesewing/plugin-bundle'
|
||||
import pluginBundle from '@freesewing/plugin-bundle'
|
||||
import buttonsPlugin from '@freesewing/plugin-buttons'
|
||||
import mirrorPlugin from '@freesewing/plugin-mirror'
|
||||
import bartackPlugin from '@freesewing/plugin-bartack'
|
||||
import config from '../config/'
|
||||
// Path API
|
||||
import draftPath_move from './path_move'
|
||||
|
@ -28,11 +31,13 @@ import draftPath_start from './path_start'
|
|||
import draftPath_translate from './path_translate'
|
||||
import draftPath_trim from './path_trim'
|
||||
// Plugins
|
||||
import draftPlugin_cutonfold from './plugin_cutonfold'
|
||||
import draftPlugin_bartack from './plugin_bartack'
|
||||
import draftPlugin_buttons from './plugin_buttons'
|
||||
import draftPlugin_cutonfold from './plugin_cutonfold'
|
||||
import draftPlugin_dimension from './plugin_dimension'
|
||||
import draftPlugin_grainline from './plugin_grainline'
|
||||
import draftPlugin_logo from './plugin_logo'
|
||||
import draftPlugin_mirror from './plugin_mirror'
|
||||
import draftPlugin_round from './plugin_round'
|
||||
import draftPlugin_sprinkle from './plugin_sprinkle'
|
||||
import draftPlugin_scalebox from './plugin_scalebox'
|
||||
|
@ -88,7 +93,12 @@ import draftDocs_overview from './docs_overview'
|
|||
import draftDocs_coords from './docs_coords'
|
||||
|
||||
// Create design
|
||||
const Pattern = new freesewing.Design(config, plugins)
|
||||
const Pattern = new freesewing.Design(config, [
|
||||
pluginBundle,
|
||||
buttonsPlugin,
|
||||
mirrorPlugin,
|
||||
bartackPlugin
|
||||
])
|
||||
|
||||
// Attach draft methods to prototype
|
||||
let methods = {
|
||||
|
@ -117,11 +127,13 @@ let methods = {
|
|||
draftPath_start,
|
||||
draftPath_translate,
|
||||
draftPath_trim,
|
||||
draftPlugin_bartack,
|
||||
draftPlugin_buttons,
|
||||
draftPlugin_cutonfold,
|
||||
draftPlugin_dimension,
|
||||
draftPlugin_grainline,
|
||||
draftPlugin_logo,
|
||||
draftPlugin_mirror,
|
||||
draftPlugin_round,
|
||||
draftPlugin_scalebox,
|
||||
draftPlugin_sprinkle,
|
||||
|
|
25
packages/examples/src/plugin_bartack.js
Normal file
25
packages/examples/src/plugin_bartack.js
Normal file
|
@ -0,0 +1,25 @@
|
|||
import { box } from './shared'
|
||||
|
||||
export default (part) => {
|
||||
let { Point, Path, points, paths, macro } = part.shorthand()
|
||||
|
||||
points.a = new Point(15, 15)
|
||||
points.b = new Point(20, 20)
|
||||
points.c = new Point(30, 20)
|
||||
points.d = new Point(35, 15)
|
||||
points.e = new Point(20, 10)
|
||||
points.f = new Point(30, 10)
|
||||
|
||||
paths.a = new Path().move(points.a).curve(points.b, points.c, points.d).setRender(false)
|
||||
|
||||
macro('bartackAlong', {
|
||||
path: paths.a
|
||||
})
|
||||
|
||||
macro('sprinkle', {
|
||||
snippet: 'notch',
|
||||
on: ['e', 'f']
|
||||
})
|
||||
|
||||
return box(part, 60, 30)
|
||||
}
|
26
packages/examples/src/plugin_mirror.js
Normal file
26
packages/examples/src/plugin_mirror.js
Normal file
|
@ -0,0 +1,26 @@
|
|||
import { box } from './shared'
|
||||
|
||||
export default (part) => {
|
||||
let { Point, Path, points, paths, macro } = part.shorthand()
|
||||
|
||||
points.a = new Point(5, 5)
|
||||
points.b = new Point(45, 30)
|
||||
points.c = new Point(5, 30)
|
||||
points.d = new Point(45, 5)
|
||||
points.mid = new Point(25, 15)
|
||||
|
||||
paths.a = new Path().move(points.a).curve(points.b, points.c, points.d)
|
||||
|
||||
macro('mirror', {
|
||||
mirror: [points.b, points.d],
|
||||
points: [points.mid],
|
||||
paths: [paths.a]
|
||||
})
|
||||
|
||||
macro('sprinkle', {
|
||||
snippet: 'notch',
|
||||
on: ['mid', 'mirroredMid']
|
||||
})
|
||||
|
||||
return box(part, 100, 40)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue