1
0
Fork 0

tada: First commit

This commit is contained in:
Joost De Cock 2018-07-21 15:34:46 +02:00
parent e02c8badfe
commit cefae51c06
9 changed files with 6497 additions and 3 deletions

View file

@ -0,0 +1,13 @@
# editorconfig.org
root = true
[*]
indent_size = 2
indent_style = space
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false

62
packages/plugin-cutonfold/.gitignore vendored Normal file
View file

@ -0,0 +1,62 @@
dist
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
# next.js build output
.next

View file

@ -0,0 +1,4 @@
src
.editorconfig
.babelrc
webpack.config.js

View file

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2018 freesewing / plugins
Copyright (c) 2018 Joost De Cock
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View file

@ -1,2 +1,51 @@
# macro-cutonfold
A freesewing macro to add cut-on-fold indicators to your patterns
<p align="center">
<a title="Go to freesewing.org" href="https://freesewing.org/"><img src="https://freesewing.org/img/logo/black.svg" align="center" width="150px" alt="Freesewing logo"/></a>
</p>
<h4 align="center"><em>&nbsp;<a title="Go to freesewing.org" href="https://freesewing.org/">freesewing</a></em>
<br><sup>a library for made-to-measure sewing patterns</sup>
</h4>
# freesewing / plugins / macro-cutonfold
This is a macro for [freesewing](https://github.com/freesewing/freesewing)
to add cut-on-fold indicators on your patterns.
## Install
```sh
npm install @freesewing-plugins/macro-cutonfold --save
```
## Loading the plugin
Plugins are loaded by the `withpPlugin` method of an instantiated freesewing pattern:
```js
import F from 'freesewing';
import cutonfold from '@freesewing-plugins/macro-cutonfold';
var pattern = new F.pattern()
.withPlugin(cutonfold);
```
## Using the plugin
This plugin provides the `cutonfold` macro which you can call with the `macro` method on an instantiated pattern part:
```js
part.macro('cutonfold', {
from: points.cbNeck
, to: points.cbHips
});
```
### Parameters
- `to`: A point object at the start of the cut-on-fold indicator
- `from`: A point object at the end of the cut-on-fold indicator
As all freesewing macros, bundle these parameters into a single object.
## Example
FIXME: include example

6258
packages/plugin-cutonfold/package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,43 @@
{
"name": "@freesewing-plugins/macro-cutonfold",
"version": "0.1.0",
"author": "Joost De Cock <joost@decock.org> (https://github.com/joostdecock)",
"license": "MIT",
"description": "A freesewing macro to add cut-on-fold indicators on your patterns",
"keywords": [
"freesewing",
"macro",
"sewing",
"patterns",
"cut on fold"
],
"homepage": "https://github.com/freesewing-plugins/macro-cutonfold#readme",
"repository": "github:freesewing-plugins/macro-cutonfold",
"bugs": {
"url": "https://github.com/joostdecock/macro-cof/issues"
},
"main": "dist/node/index.js",
"unpkg": "dist/browser/bundle.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"clean": "rimraf dist",
"nodebuild": "babel src -d dist/node",
"browserbuild": "npx webpack-cli --config webpack.config.js",
"build": "npm run clean && npm run nodebuild && npm run browserbuild"
},
"devDependencies": {
"@babel/core": "7.0.0-beta.53",
"@babel/preset-env": "7.0.0-beta.53",
"rimraf": "^2.6.2",
"babel-cli": "6.26.0",
"babel-loader": "8.0.0-beta.4",
"webpack": "4.16.0",
"webpack-cli": "3.0.8"
},
"files": [
"dist/*",
"README.md",
"package-lock.json",
"package.json"
]
}

View file

@ -0,0 +1,27 @@
module.exports = {
hooks: {
preRenderSvg: function(next) {
// Without this, our custom attribute won't be valid
this.attributes.add("xmlns:freesewing", "http://freesewing.org/namespaces/freesewing");
// VERSION is injected by webpack from package.json
this.attributes.add("freesewing:plugin-macro-cof", VERSION);
next();
}
}
, macros: {
cof: function(next, so) {
let points = this.points;
points.cofStart = so.from.shiftTowards(so.to, 30);
points.cofEnd = so.to.shiftTowards(so.from, 30);
points.cofVia1 = so.from.shiftTowards(so.to, 50).rotate(90,points.cofStart);
points.cofVia2 = so.to.shiftTowards(so.from, 50).rotate(-90,points.cofEnd);
this.paths.cof = new this.path()
.move(points.cofStart)
.line(points.cofVia1)
.line(points.cofVia2)
.line(points.cofEnd)
.attr('class', 'cut-on-fold');
next();
}
}
}

View file

@ -0,0 +1,38 @@
const path = require('path');
var webpack = require('webpack');
module.exports = {
mode: 'production',
target: 'web',
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'dist/browser'),
filename: 'bundle.js',
libraryTarget: 'var',
library: 'freesewing_macro_cutonfold'
},
plugins: [
new webpack.DefinePlugin({
VERSION: JSON.stringify(require("./package.json").version)
})
],
module: {
rules:[
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
},
{
test: /\.txt$/,
exclude: /node_modules/,
use: 'raw-loader'
},
]
}
};