diff --git a/config/software/plugins.json b/config/software/plugins.json index 803bd151a45..634b7ab5b6b 100644 --- a/config/software/plugins.json +++ b/config/software/plugins.json @@ -1,10 +1,8 @@ { "plugin-annotations": "A FreeSewing plugin that provides pattern annotations", - "plugin-banner": "A FreeSewing plugin to repeat text on a path", "plugin-bundle": "An umbrella package of 8 essential FreeSewing build-time plugins", "plugin-bust": "A FreeSewing plugin that helps with bust-adjusting menswear patterns", "plugin-cutlist": "A FreeSewing plugin to store data regarding a pattern's cutlist", - "plugin-dimension": "A FreeSewing plugin to add dimensions to your (paperless) pattern", "plugin-flip": "A FreeSewing plugin to flip parts horizontally", "plugin-gore": "A FreeSewing plugin to generate gores for a semi-sphere or dome", "plugin-i18n": "A FreeSewing plugin for pattern translation", diff --git a/plugins/plugin-annotations/src/banner.mjs b/plugins/plugin-annotations/src/banner.mjs new file mode 100644 index 00000000000..48ca655a468 --- /dev/null +++ b/plugins/plugin-annotations/src/banner.mjs @@ -0,0 +1,19 @@ +// Export macros +export const bannerMacros = { + banner: function (so) { + // Mix defaults with settings object + so = { + text: '', + dy: -1, + spaces: 12, + repeat: 10, + className: '', + ...so, + } + so.path.attr('data-text-dy', so.dy).attr('data-text-class', `${so.className} center`) + const spacer = ' '.repeat(so.spaces) + let banner = spacer + for (let i = 0; i < so.repeat; i++) banner += so.text + ' '.repeat(so.spaces) + so.path.attr('data-text', banner) + }, +} diff --git a/plugins/plugin-annotations/src/bannerbox.mjs b/plugins/plugin-annotations/src/bannerbox.mjs new file mode 100644 index 00000000000..b1c530586c9 --- /dev/null +++ b/plugins/plugin-annotations/src/bannerbox.mjs @@ -0,0 +1,35 @@ +// Export macros +export const bannerboxMacros = { + bannerbox: function (so, { points, Point, paths, Path, getId, macro }) { + // Spread so settings into defaults + so = { + topLeft: new Point(0, 0), + bottomRight: new Point(100, 100), + title: 'No title for this bannerbox', + margin: 15, + className: 'text-xs fill-note', + dy: 4, + spaces: 12, + repeat: 10, + ...so, + } + const offset = Math.sqrt(2 * Math.pow(so.margin, 2)) + + const id = getId() + paths[id] = new Path() + .move(so.topLeft.shift(135, offset)) + .line(new Point(so.bottomRight.x, so.topLeft.y).shift(45, offset)) + .line(so.bottomRight.shift(315, offset)) + .line(new Point(so.topLeft.x, so.bottomRight.y).shift(225, offset)) + .line(so.topLeft.shift(135, offset)) + .close() + + macro('banner', { + path: paths[id], + text: so.title, + className: 'text-xs fill-note', + repeat: 99, + dy: 4, + }) + }, +} diff --git a/plugins/plugin-annotations/src/dimensions.mjs b/plugins/plugin-annotations/src/dimensions.mjs new file mode 100644 index 00000000000..52e777fc371 --- /dev/null +++ b/plugins/plugin-annotations/src/dimensions.mjs @@ -0,0 +1,157 @@ +const markers = ` + + + + + + +` +const prefix = '__paperless' + +function drawDimension(from, to, so, { Path, units }) { + const dimension = new Path() + .move(from) + .line(to) + .attr('class', 'mark') + .attr('data-text', so.text || units(from.dist(to))) + .attr('data-text-class', 'fill-mark center') + if (!so.noStartMarker) dimension.attributes.set('marker-start', 'url(#dimensionFrom)') + if (!so.noEndMarker) dimension.attributes.set('marker-end', 'url(#dimensionTo)') + + return dimension +} + +function drawLeader({ paths, Path }, from, to, id) { + paths[id] = new Path().move(from).line(to).attr('class', 'mark dotted') +} + +function hleader(so, type, props, id) { + const { Point } = props + let point + if (typeof so.y === 'undefined' || so[type].y === so.y) { + point = so[type] + } else { + point = new Point(so[type].x, so.y) + drawLeader(props, so[type], point, id) + } + + return point +} + +function vleader(so, type, props, id) { + const { Point } = props + let point + if (typeof so.x === 'undefined' || so[type].x === so.x) { + point = so[type] + } else { + point = new Point(so.x, so[type].y) + drawLeader(props, so[type], point, id) + } + + return point +} + +function lleader(so, type, props, id) { + let point, rot, other + if (type === 'from') { + rot = 1 + other = 'to' + } else { + rot = -1 + other = 'from' + } + if (typeof so.d === 'undefined') { + point = so[type] + } else { + point = so[type].shiftTowards(so[other], so.d).rotate(90 * rot, so[type]) + drawLeader(props, so[type], point, id) + } + + return point +} + +// Export hooks and macros +export const dimensionsHooks = { + preRender: [ + function (svg) { + if (svg.defs.indexOf(markers) === -1) svg.defs += markers + }, + ], +} +export const dimensionsMacros = { + // horizontal + hd: function (so, props) { + const { getId, paths } = props + const id = so.id || getId(prefix) + paths[id] = drawDimension( + hleader(so, 'from', props, id + '_ls'), + hleader(so, 'to', props, id + '_le'), + so, + props + ) + }, + // vertical + vd: function (so, props) { + const { getId, paths } = props + const id = so.id || getId(prefix) + paths[id] = drawDimension( + vleader(so, 'from', props, id + '_ls'), + vleader(so, 'to', props, id + '_le'), + so, + props + ) + }, + // linear + ld: function (so, props) { + const { getId, paths } = props + const id = so.id || getId(prefix) + paths[id] = drawDimension( + lleader(so, 'from', props, id + '_ls'), + lleader(so, 'to', props, id + '_le'), + so, + props + ) + }, + // path + pd: function (so, props) { + const { getId, paths, scale, units } = props + const id = so.id || getId(prefix) + if (typeof so.d === 'undefined') so.d = 10 * scale + const dimension = so.path + .offset(so.d) + .attr('class', 'mark') + .attr('data-text', so.text || units(so.path.length())) + .attr('data-text-class', 'fill-mark center') + if (!so.noStartMarker) dimension.attributes.set('marker-start', 'url(#dimensionFrom)') + if (!so.noEndMarker) dimension.attributes.set('marker-end', 'url(#dimensionTo)') + paths[id] = dimension + drawLeader(props, so.path.start(), dimension.start(), id + '_ls') + drawLeader(props, so.path.end(), dimension.end(), id + '_le') + }, + // Remove dimension + rmd: function (so, props) { + const { paths } = props + if (paths[so.id]) delete this.paths[so.id] + if (paths[`${so.id}_ls`]) delete paths[`${so.id}_ls`] + if (paths[`${so.id}_le`]) delete paths[`${so.id}_le`] + if (Array.isArray(so.ids)) { + for (const id of so.ids) { + if (paths[id]) delete paths[id] + if (paths[`${id}_ls`]) delete paths[`${id}_ls`] + if (paths[`${id}_le`]) delete paths[`${id}_le`] + } + } + }, + // Remove all dimensions (with standard prefix) + rmad: function (params, props) { + const toRemove = { + points: props.point, + paths: props.paths, + } + for (let type in toRemove) { + for (let id in props[type]) { + if (id.slice(0, prefix.length) === prefix) delete props[type][id] + } + } + }, +} diff --git a/plugins/plugin-annotations/src/index.mjs b/plugins/plugin-annotations/src/index.mjs index ca351920745..d326dc80ff2 100644 --- a/plugins/plugin-annotations/src/index.mjs +++ b/plugins/plugin-annotations/src/index.mjs @@ -4,11 +4,14 @@ import { buttonsHooks } from './buttons.mjs' import { logoHooks } from './logo.mjs' import { notchesHooks } from './notches.mjs' // Macros only +import { bannerMacros } from './banner.mjs' +import { bannerboxMacros } from './bannerbox.mjs' import { bartackMacros } from './bartack.mjs' import { crossboxMacros } from './crossbox.mjs' import { scaleboxMacros } from './scalebox.mjs' // Hooks and Macros import { cutonfoldMacros, cutonfoldHooks } from './cutonfold.mjs' +import { dimensionsMacros, dimensionsHooks } from './dimensions.mjs' import { grainlineMacros, grainlineHooks } from './grainline.mjs' import { pleatMacros, pleatHooks } from './pleat.mjs' import { sewtogetherMacros, sewtogetherHooks } from './sewtogether.mjs' @@ -22,16 +25,20 @@ export const plugin = { ...logoHooks.preRender, ...notchesHooks.preRender, ...cutonfoldHooks.preRender, + ...dimensionsHooks.preRender, ...grainlineHooks.preRender, ...pleatHooks.preRender, ...sewtogetherHooks.preRender, ], }, macros: { + ...bannerMacros, + ...bannerboxMacros, ...bartackMacros, ...crossboxMacros, ...scaleboxMacros, ...cutonfoldMacros, + ...dimensionsMacros, ...grainlineMacros, ...pleatMacros, ...sewtogetherMacros, diff --git a/plugins/plugin-banner/CHANGELOG.md b/plugins/plugin-banner/CHANGELOG.md deleted file mode 100644 index d6230083a40..00000000000 --- a/plugins/plugin-banner/CHANGELOG.md +++ /dev/null @@ -1,34 +0,0 @@ -# Change log for: @freesewing/plugin-banner - - -## 2.21.0 (2022-06-27) - -### Changed - - - Migrated from Rollup to Esbuild for all builds - -## 2.20.0 (2022-01-24) - -### Changed - - - Changed the default options - - Now part of `@freesewing/plugin-bundle` - -## 2.19.6 (2021-12-29) - -### Added - - - Added (esm) unit tests - -## 2.0.0 (2019-08-25) - -### Added - - - Initial release - - -This is the **initial release**, and the start of this change log. - -> Prior to version 2, FreeSewing was not a JavaScript project. -> As such, that history is out of scope for this change log. - diff --git a/plugins/plugin-banner/README.md b/plugins/plugin-banner/README.md deleted file mode 100644 index 0960ccf2655..00000000000 --- a/plugins/plugin-banner/README.md +++ /dev/null @@ -1,295 +0,0 @@ -![FreeSewing](https://static.freesewing.org/banner.png) -

@freesewing/plugin-banner on NPM - License: MIT - Code quality on DeepScan - Open issues tagged pkg:plugin-banner - All Contributors -

Follow @freesewing_org on Twitter - Chat with us on Discord - Become a FreeSewing Patron - Follow @freesewing_org on Twitter -

- -# @freesewing/plugin-banner - -A FreeSewing plugin to repeat text on a path - - - - -> #### Note: Version 3 is a work in progress -> -> We are working on a new major version (v3) but it is not ready for prime-time. -> For production use, please refer to our v2 packages (the `latest` on NPM) -> or [the `v2` branch in our monorepo](https://github.com/freesewing/freesewing/tree/v2). -> -> We the `main` branch and `next` packages on NPM holds v3 code. But it's alpha for now. - -## What am I looking at? πŸ€” - -This repository is our *monorepo* holding all our NPM designs, plugins, other NPM packages, and (web)sites. - -This folder holds: @freesewing/plugin-banner - -If you're not entirely sure what to do or how to start, type this command: - -``` -npm run tips -``` - -> If you don't want to set up a dev environment, you can run it in your browser: -> -> [![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/freesewing/freesewing) -> -> We recommend that you fork our repository and then -> put `gitpod.io/# to start up a browser-based dev environment of your own. - -## About FreeSewing πŸ’€ - -Where the world of makers and developers collide, that's where you'll find FreeSewing. - -If you're a maker, checkout [freesewing.org](https://freesewing.org/) where you can generate -our sewing patterns adapted to your measurements. - -If you're a developer, our documentation is on [freesewing.dev](https://freesewing.dev/). -Our [core library](https://freesewing.dev/reference/api/) is a *batteries-included* toolbox -for parametric design of sewing patterns. But we also provide a range -of [plugins](https://freesewing.dev/reference/plugins/) that further extend the -functionality of the platform. - -If you have NodeJS installed, you can try it right now by running: - -```bash -npx create-freesewing-pattern -``` - -Or, consult our getting started guides -for [Linux](https://freesewing.dev/tutorials/getting-started-linux/), -[MacOS](https://freesewing.dev/tutorials/getting-started-mac/), -or [Windows](https://freesewing.dev/tutorials/getting-started-windows/). - -We also have a [pattern design tutorial](https://freesewing.dev/tutorials/pattern-design/) that -walks you through your first parametric design, -and [a friendly community](https://freesewing.org/community/where/) with -people who can help you when you get stuck. - -## Support FreeSewing: Become a patron πŸ₯° - -FreeSewing is an open source project run by a community, -and financially supported by our patrons. - -If you feel what we do is worthwhile, and you can spend a few coind without -hardship, then you should [join us and become a patron](https://freesewing.org/community/join). - -## Links πŸ‘©β€πŸ’» - - - πŸ’» Makers website: [freesewing.org](https://freesewing.org) - - πŸ’» Developers website: [freesewing.dev](https://freesewing.dev) - - πŸ’¬ Chat: On Discord via [discord.freesewing.org](https://discord.freesewing.org/) - - βœ… Todo list/Kanban board: On Github via [todo.freesewing.org](https://todo.freesewing.org/) - - 🐦 Twitter: [@freesewing_org](https://twitter.com/freesewing_org) - - πŸ“· Instagram: [@freesewing_org](https://instagram.com/freesewing_org) - -## License: MIT πŸ€“ - -Β© [Joost De Cock](https://github.com/joostdecock). -See [the license file](https://github.com/freesewing/freesewing/blob/develop/LICENSE) for details. - -## Where to get help 🀯 - -Our [chatrooms on Discord](https://chat.freesewing.org/) are the best place to ask questions, -share your feedback, or just hang out. - -If you want to report a problem, please [create an issue](https://github.com/freesewing/freesewing/issues/new). - - - -## Contributors ✨ - -Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)): - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Adam Tomkins
Adam Tomkins

πŸ“–
Alexandre Ignjatovic
Alexandre Ignjatovic

πŸ’»
AlfaLyr
AlfaLyr

πŸ’» πŸ”Œ 🎨
Andrew James
Andrew James

πŸ“–
Anneke
Anneke

πŸ“– 🌍
Annie Kao
Annie Kao

πŸ“–
Anternative
Anternative

πŸ“–
Anthony
Anthony

πŸ’¬
Ari Grayzel-student
Ari Grayzel-student

πŸ’»
Bart
Bart

πŸ“–
BenJamesBen
BenJamesBen

πŸ’» πŸ“– πŸ›
Cameron Dubas
Cameron Dubas

πŸ“–
Carsten Biebricher
Carsten Biebricher

πŸ“–
Cathy Zoller
Cathy Zoller

πŸ“–
Chantal Lapointe
Chantal Lapointe

🌍
Damien PIQUET
Damien PIQUET

πŸ’»
Darigov Research
Darigov Research

πŸ“– πŸ€”
Elena FdR
Elena FdR

πŸ“– πŸ“
Emmanuel Nyachoke
Emmanuel Nyachoke

πŸ’» πŸ“–
Enoch Riese
Enoch Riese

πŸ’»
EvEkSwed
EvEkSwed

🌍
Fantastik-Maman
Fantastik-Maman

🌍
Forrest O.
Forrest O.

πŸ“–
FrΓ©dΓ©ric
FrΓ©dΓ©ric

🌍
Glenn Matthews
Glenn Matthews

πŸ“–
Greg Sadetsky
Greg Sadetsky

πŸ“–
Igor Couto
Igor Couto

πŸ›
Ikko Ashimine
Ikko Ashimine

πŸ“–
Irapeke
Irapeke

🌍
Jacek Sawoszczuk
Jacek Sawoszczuk

πŸ“–
Jason Williams
Jason Williams

πŸ“–
Jeremy Jackson
Jeremy Jackson

πŸ’»
Jeroen Hoek
Jeroen Hoek

πŸ“–
Joe Schofield
Joe Schofield

πŸ“–
Joebidido
Joebidido

🌍
Joost De Cock
Joost De Cock

🚧
Josh Essman
Josh Essman

πŸ“–
Kake
Kake

πŸ“–
Kapunahele Wong
Kapunahele Wong

πŸ“–
Karen
Karen

πŸ“– πŸ“‹
Katie McGinley
Katie McGinley

πŸ“–
Kieran Klaassen
Kieran Klaassen

πŸ’»
Kittycatou
Kittycatou

🌍
Kris
Kris

πŸ“–
Kristin Ruben
Kristin Ruben

πŸ’»
Loudepeuter
Loudepeuter

🌍
Lucian
Lucian

πŸ“‹
MA-TATAS
MA-TATAS

πŸ“–
Marcus
Marcus

🌍
Martin Tribo
Martin Tribo

πŸ“–
Nadege Michel
Nadege Michel

⚠️ πŸ“–
Natalia
Natalia

πŸ’» 🎨 πŸ“
Nathan Yergler
Nathan Yergler

πŸ“–
Nick Dower
Nick Dower

πŸ“– πŸ’» πŸ›
Nikhil Chelliah
Nikhil Chelliah

πŸ“–
OysteinHoiby
OysteinHoiby

πŸ’»
Patrick Forringer
Patrick Forringer

πŸ”Œ
Paul
Paul

πŸ“– πŸ“ 🌍
Phillip Thelen
Phillip Thelen

πŸ’»
Pixieish
Pixieish

πŸ“–
Prof. dr. Sorcha NΓ­ Dhubhghaill
Prof. dr. Sorcha NΓ­ Dhubhghaill

πŸ“–
Quentin FELIX
Quentin FELIX

πŸ’» 🎨
Rik Hekker
Rik Hekker

πŸ›
Sam Livingston-Gray
Sam Livingston-Gray

πŸ“–
Sanne
Sanne

πŸ’» πŸ“–
Sara Latorre
Sara Latorre

🌍
SeaZeeZee
SeaZeeZee

πŸ“– πŸ’»
SimonbJohnson
SimonbJohnson

πŸ›
SirCharlotte
SirCharlotte

🌍
Slylele
Slylele

πŸ“– 🌍
Soazillon
Soazillon

🌍
SoneaTheBest
SoneaTheBest

🌍
Stefan Sydow
Stefan Sydow

🌍 πŸ“– πŸ’»
TrΓ­ona
TrΓ­ona

πŸ“–
Unmutual
Unmutual

πŸ“–
Wouter van Wageningen
Wouter van Wageningen

πŸ’» 🎨 πŸ”§
amysews
amysews

πŸ“–
anna-puk
anna-puk

πŸ’»
beautifulsummermoon
beautifulsummermoon

🌍
berce
berce

πŸ“–
biou
biou

πŸ’»
bobgeorgethe3rd
bobgeorgethe3rd

πŸ’» πŸ“– 🎨
brmlyklr
brmlyklr

πŸ“–
chri5b
chri5b

πŸ’» ⚠️
dingcycle
dingcycle

🌍
drowned-in-books
drowned-in-books

πŸ’¬
econo202
econo202

πŸ“–
ericamattos
ericamattos

🌍
fightingrabbit
fightingrabbit

πŸ’»
gaylyndie
gaylyndie

πŸ“–
grimlokason
grimlokason

πŸ’»
hellgy
hellgy

🎨
jackseye
jackseye

πŸ“–
marckiesel
marckiesel

🌍
mesil
mesil

πŸ›
starfetch
starfetch

πŸ’» πŸ“– 🌍 🎨
timorl
timorl

πŸ’»
ttimearl
ttimearl

πŸ–‹
tuesgloomsday
tuesgloomsday

πŸ“–
valadaptive
valadaptive

πŸ’»
viocky
viocky

🌍
woolishboy
woolishboy

πŸ’»
yc
yc

🌍
- - - - - - -This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! - diff --git a/plugins/plugin-banner/build.mjs b/plugins/plugin-banner/build.mjs deleted file mode 100644 index 99ace216bc8..00000000000 --- a/plugins/plugin-banner/build.mjs +++ /dev/null @@ -1,35 +0,0 @@ -/* This script will build the package with esbuild */ -import esbuild from 'esbuild' -import pkg from './package.json' assert { type: 'json' } - -// Create banner based on package info -const banner = `/** - * ${pkg.name} | v${pkg.version} - * ${pkg.description} - * (c) ${new Date().getFullYear()} ${pkg.author} - * @license ${pkg.license} - */` - -// Shared esbuild options -const options = { - banner: { js: banner }, - bundle: true, - entryPoints: ['src/index.mjs'], - format: 'esm', - outfile: 'dist/index.mjs', - external: ['@freesewing'], - metafile: process.env.VERBOSE ? true : false, - minify: process.env.NO_MINIFY ? false : true, - sourcemap: true, -} - -// Let esbuild generate the build -const build = async () => { - const result = await esbuild.build(options).catch(() => process.exit(1)) - - if (process.env.VERBOSE) { - const info = await esbuild.analyzeMetafile(result.metafile) - console.log(info) - } -} -build() diff --git a/plugins/plugin-banner/data.mjs b/plugins/plugin-banner/data.mjs deleted file mode 100644 index 9c2dfeeca30..00000000000 --- a/plugins/plugin-banner/data.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// This file is auto-generated | All changes you make will be overwritten. -export const name = '@freesewing/plugin-banner' -export const version = '3.0.0-alpha.4' -export const data = { name, version } diff --git a/plugins/plugin-banner/package.json b/plugins/plugin-banner/package.json deleted file mode 100644 index 7cebca75d59..00000000000 --- a/plugins/plugin-banner/package.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "name": "@freesewing/plugin-banner", - "version": "3.0.0-alpha.4", - "description": "A FreeSewing plugin to repeat text on a path", - "author": "Joost De Cock (https://github.com/joostdecock)", - "homepage": "https://freesewing.org/", - "repository": "github:freesewing/freesewing", - "license": "MIT", - "bugs": { - "url": "https://github.com/freesewing/freesewing/issues" - }, - "funding": { - "type": "individual", - "url": "https://freesewing.org/patrons/join" - }, - "keywords": [ - "freesewing", - "plugin", - "sewing pattern", - "sewing", - "design", - "parametric design", - "made to measure", - "diy", - "fashion" - ], - "type": "module", - "module": "dist/index.mjs", - "exports": { - ".": "./dist/index.mjs" - }, - "scripts": { - "build": "node build.mjs", - "clean": "rimraf dist", - "mbuild": "NO_MINIFY=1 node build.mjs", - "symlink": "mkdir -p ./node_modules/@freesewing && cd ./node_modules/@freesewing && ln -s -f ../../../* . && cd -", - "test": "npx mocha tests/*.test.mjs", - "vbuild": "VERBOSE=1 node build.mjs", - "lab": "cd ../../sites/lab && yarn start", - "tips": "node ../../scripts/help.mjs", - "lint": "npx eslint 'src/**' 'tests/*.mjs'", - "prettier": "npx prettier --write 'src/*.mjs' 'tests/*.mjs'", - "testci": "npx mocha tests/*.test.mjs --reporter ../../tests/reporters/terse.js", - "cibuild_step1": "node build.mjs", - "wbuild": "node build.mjs", - "wcibuild_step1": "node build.mjs" - }, - "peerDependencies": { - "@freesewing/core": "3.0.0-alpha.4" - }, - "dependencies": {}, - "devDependencies": { - "mocha": "10.0.0", - "chai": "4.2.0" - }, - "files": [ - "dist/*", - "README.md" - ], - "publishConfig": { - "access": "public", - "tag": "next" - }, - "engines": { - "node": ">=16.0.0", - "npm": ">=8" - } -} diff --git a/plugins/plugin-banner/src/index.mjs b/plugins/plugin-banner/src/index.mjs deleted file mode 100644 index 666a95b7451..00000000000 --- a/plugins/plugin-banner/src/index.mjs +++ /dev/null @@ -1,26 +0,0 @@ -import { version, name } from '../data.mjs' - -export const plugin = { - name, - version, - macros: { - banner: function (so) { - const defaults = { - text: '', - dy: -1, - spaces: 12, - repeat: 10, - } - so = { ...defaults, ...so } - so.path.attr('data-text-dy', so.dy).attr('data-text-class', 'center') - const spacer = ' '.repeat(so.spaces) - let banner = spacer - for (let i = 0; i < so.repeat; i++) banner += so.text + ' '.repeat(so.spaces) - so.path.attr('data-text', banner) - }, - }, -} - -// More specifically named exports -export const bannerPlugin = plugin -export const pluginBanner = plugin diff --git a/plugins/plugin-banner/tests/plugin.test.mjs b/plugins/plugin-banner/tests/plugin.test.mjs deleted file mode 100644 index 93aa514db0e..00000000000 --- a/plugins/plugin-banner/tests/plugin.test.mjs +++ /dev/null @@ -1,87 +0,0 @@ -import chai from 'chai' -import { Design } from '@freesewing/core' -import { bannerPlugin } from '../src/index.mjs' - -const expect = chai.expect - -describe('Banner Plugin Tests', () => { - it('Should add repeating text to a path', () => { - const part = { - name: 'test', - draft: ({ Point, points, Path, paths, macro, part }) => { - points.from = new Point(30, 30) - points.to = new Point(30, 100) - paths.example = new Path().move(points.from).line(points.to) - - macro('banner', { - text: 'foo', - path: paths.example, - }) - - return part - }, - plugins: [bannerPlugin], - } - const design = new Design({ parts: [part] }) - const pattern = new design() - pattern.draft() - const c = pattern.parts[0].test.paths.example - expect(c.attributes.get('data-text')).to.equal( - '            foo            foo            foo            foo            foo            foo            foo            foo            foo            foo            ' - ) - expect(c.attributes.get('data-text-class')).to.equal('center') - expect(c.attributes.get('data-text-dy')).to.equal('-1') - }) - - it('Number of spaces should be configurable', () => { - const part = { - name: 'test', - draft: ({ Point, points, Path, paths, macro, part }) => { - points.from = new Point(30, 30) - points.to = new Point(30, 100) - paths.example2 = new Path().move(points.from).line(points.to) - - macro('banner', { - text: 'foo', - path: paths.example2, - spaces: 2, - repeat: 2, - }) - - return part - }, - plugins: [bannerPlugin], - } - const design = new Design({ parts: [part] }) - const pattern = new design() - pattern.draft() - const c = pattern.parts[0].test.paths.example2 - expect(c.attributes.get('data-text')).to.equal('  foo  foo  ') - }) - - it('Number of repetitions should be configurable', () => { - const part = { - name: 'test', - draft: ({ Point, points, Path, paths, macro, part }) => { - points.from = new Point(30, 30) - points.to = new Point(30, 100) - paths.example3 = new Path().move(points.from).line(points.to) - - macro('banner', { - text: 'foo', - path: paths.example3, - spaces: 1, - repeat: 4, - }) - - return part - }, - plugins: [bannerPlugin], - } - const design = new Design({ parts: [part] }) - const pattern = new design() - pattern.draft() - const c = pattern.parts[0].test.paths.example3 - expect(c.attributes.get('data-text')).to.equal(' foo foo foo foo ') - }) -}) diff --git a/plugins/plugin-banner/tests/shared.test.mjs b/plugins/plugin-banner/tests/shared.test.mjs deleted file mode 100644 index 7bf4f668398..00000000000 --- a/plugins/plugin-banner/tests/shared.test.mjs +++ /dev/null @@ -1,6 +0,0 @@ -// This file is auto-generated | Any changes you make will be overwritten. -import { plugin } from '../src/index.mjs' -import { sharedPluginTests } from '../../../tests/plugins/shared.mjs' - -// Run shared tests -sharedPluginTests(plugin) diff --git a/plugins/plugin-dimension/.travis.yml b/plugins/plugin-dimension/.travis.yml deleted file mode 100644 index 121b29f66a4..00000000000 --- a/plugins/plugin-dimension/.travis.yml +++ /dev/null @@ -1,9 +0,0 @@ -language: node_js -node_js: - - "node" -install: - - npm install - - npm run build -script: - - npm run test - - npm run coverage diff --git a/plugins/plugin-dimension/CHANGELOG.md b/plugins/plugin-dimension/CHANGELOG.md deleted file mode 100644 index efdd90cd0fc..00000000000 --- a/plugins/plugin-dimension/CHANGELOG.md +++ /dev/null @@ -1,58 +0,0 @@ -# Change log for: @freesewing/plugin-dimension - - -## 2.21.0 (2022-06-27) - -### Changed - - - Migrated from Rollup to Esbuild for all builds - -## 2.20.0 (2022-01-24) - -### Fixed - - - Support hiding start/end markers on path dimensions (pd macro) - -## 2.19.6 (2021-12-29) - -### Added - - - Added (esm) unit tests - -## 2.15.0 (2021-04-15) - -### Added - - - Added the `rmad` macro - -## 2.9.0 (2020-10-02) - -### Added - - - Added support for passing in the ID used to add paths to the part - - Added the `rmd` macro that removes dimensions - -## 2.4.4 (2020-03-15) - -### Changed - - - Don't escape inch symbol in text. Instead let Svg.escapeText() handle it at render time - -## 2.1.5 (2019-11-19) - -### Fixed - - - Fixed issue where inch marks where breaking SVG because of unescaped double quotes - -## 2.0.0 (2019-08-25) - -### Added - - - Initial release - - -This is the **initial release**, and the start of this change log. - -> Prior to version 2, FreeSewing was not a JavaScript project. -> As such, that history is out of scope for this change log. - diff --git a/plugins/plugin-dimension/README.md b/plugins/plugin-dimension/README.md deleted file mode 100644 index 2d8b4ab236e..00000000000 --- a/plugins/plugin-dimension/README.md +++ /dev/null @@ -1,295 +0,0 @@ -![FreeSewing](https://static.freesewing.org/banner.png) -

@freesewing/plugin-dimension on NPM - License: MIT - Code quality on DeepScan - Open issues tagged pkg:plugin-dimension - All Contributors -

Follow @freesewing_org on Twitter - Chat with us on Discord - Become a FreeSewing Patron - Follow @freesewing_org on Twitter -

- -# @freesewing/plugin-dimension - -A FreeSewing plugin to add dimensions to your (paperless) pattern - - - - -> #### Note: Version 3 is a work in progress -> -> We are working on a new major version (v3) but it is not ready for prime-time. -> For production use, please refer to our v2 packages (the `latest` on NPM) -> or [the `v2` branch in our monorepo](https://github.com/freesewing/freesewing/tree/v2). -> -> We the `main` branch and `next` packages on NPM holds v3 code. But it's alpha for now. - -## What am I looking at? πŸ€” - -This repository is our *monorepo* holding all our NPM designs, plugins, other NPM packages, and (web)sites. - -This folder holds: @freesewing/plugin-dimension - -If you're not entirely sure what to do or how to start, type this command: - -``` -npm run tips -``` - -> If you don't want to set up a dev environment, you can run it in your browser: -> -> [![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/freesewing/freesewing) -> -> We recommend that you fork our repository and then -> put `gitpod.io/# to start up a browser-based dev environment of your own. - -## About FreeSewing πŸ’€ - -Where the world of makers and developers collide, that's where you'll find FreeSewing. - -If you're a maker, checkout [freesewing.org](https://freesewing.org/) where you can generate -our sewing patterns adapted to your measurements. - -If you're a developer, our documentation is on [freesewing.dev](https://freesewing.dev/). -Our [core library](https://freesewing.dev/reference/api/) is a *batteries-included* toolbox -for parametric design of sewing patterns. But we also provide a range -of [plugins](https://freesewing.dev/reference/plugins/) that further extend the -functionality of the platform. - -If you have NodeJS installed, you can try it right now by running: - -```bash -npx create-freesewing-pattern -``` - -Or, consult our getting started guides -for [Linux](https://freesewing.dev/tutorials/getting-started-linux/), -[MacOS](https://freesewing.dev/tutorials/getting-started-mac/), -or [Windows](https://freesewing.dev/tutorials/getting-started-windows/). - -We also have a [pattern design tutorial](https://freesewing.dev/tutorials/pattern-design/) that -walks you through your first parametric design, -and [a friendly community](https://freesewing.org/community/where/) with -people who can help you when you get stuck. - -## Support FreeSewing: Become a patron πŸ₯° - -FreeSewing is an open source project run by a community, -and financially supported by our patrons. - -If you feel what we do is worthwhile, and you can spend a few coind without -hardship, then you should [join us and become a patron](https://freesewing.org/community/join). - -## Links πŸ‘©β€πŸ’» - - - πŸ’» Makers website: [freesewing.org](https://freesewing.org) - - πŸ’» Developers website: [freesewing.dev](https://freesewing.dev) - - πŸ’¬ Chat: On Discord via [discord.freesewing.org](https://discord.freesewing.org/) - - βœ… Todo list/Kanban board: On Github via [todo.freesewing.org](https://todo.freesewing.org/) - - 🐦 Twitter: [@freesewing_org](https://twitter.com/freesewing_org) - - πŸ“· Instagram: [@freesewing_org](https://instagram.com/freesewing_org) - -## License: MIT πŸ€“ - -Β© [Joost De Cock](https://github.com/joostdecock). -See [the license file](https://github.com/freesewing/freesewing/blob/develop/LICENSE) for details. - -## Where to get help 🀯 - -Our [chatrooms on Discord](https://chat.freesewing.org/) are the best place to ask questions, -share your feedback, or just hang out. - -If you want to report a problem, please [create an issue](https://github.com/freesewing/freesewing/issues/new). - - - -## Contributors ✨ - -Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)): - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Adam Tomkins
Adam Tomkins

πŸ“–
Alexandre Ignjatovic
Alexandre Ignjatovic

πŸ’»
AlfaLyr
AlfaLyr

πŸ’» πŸ”Œ 🎨
Andrew James
Andrew James

πŸ“–
Anneke
Anneke

πŸ“– 🌍
Annie Kao
Annie Kao

πŸ“–
Anternative
Anternative

πŸ“–
Anthony
Anthony

πŸ’¬
Ari Grayzel-student
Ari Grayzel-student

πŸ’»
Bart
Bart

πŸ“–
BenJamesBen
BenJamesBen

πŸ’» πŸ“– πŸ›
Cameron Dubas
Cameron Dubas

πŸ“–
Carsten Biebricher
Carsten Biebricher

πŸ“–
Cathy Zoller
Cathy Zoller

πŸ“–
Chantal Lapointe
Chantal Lapointe

🌍
Damien PIQUET
Damien PIQUET

πŸ’»
Darigov Research
Darigov Research

πŸ“– πŸ€”
Elena FdR
Elena FdR

πŸ“– πŸ“
Emmanuel Nyachoke
Emmanuel Nyachoke

πŸ’» πŸ“–
Enoch Riese
Enoch Riese

πŸ’»
EvEkSwed
EvEkSwed

🌍
Fantastik-Maman
Fantastik-Maman

🌍
Forrest O.
Forrest O.

πŸ“–
FrΓ©dΓ©ric
FrΓ©dΓ©ric

🌍
Glenn Matthews
Glenn Matthews

πŸ“–
Greg Sadetsky
Greg Sadetsky

πŸ“–
Igor Couto
Igor Couto

πŸ›
Ikko Ashimine
Ikko Ashimine

πŸ“–
Irapeke
Irapeke

🌍
Jacek Sawoszczuk
Jacek Sawoszczuk

πŸ“–
Jason Williams
Jason Williams

πŸ“–
Jeremy Jackson
Jeremy Jackson

πŸ’»
Jeroen Hoek
Jeroen Hoek

πŸ“–
Joe Schofield
Joe Schofield

πŸ“–
Joebidido
Joebidido

🌍
Joost De Cock
Joost De Cock

🚧
Josh Essman
Josh Essman

πŸ“–
Kake
Kake

πŸ“–
Kapunahele Wong
Kapunahele Wong

πŸ“–
Karen
Karen

πŸ“– πŸ“‹
Katie McGinley
Katie McGinley

πŸ“–
Kieran Klaassen
Kieran Klaassen

πŸ’»
Kittycatou
Kittycatou

🌍
Kris
Kris

πŸ“–
Kristin Ruben
Kristin Ruben

πŸ’»
Loudepeuter
Loudepeuter

🌍
Lucian
Lucian

πŸ“‹
MA-TATAS
MA-TATAS

πŸ“–
Marcus
Marcus

🌍
Martin Tribo
Martin Tribo

πŸ“–
Nadege Michel
Nadege Michel

⚠️ πŸ“–
Natalia
Natalia

πŸ’» 🎨 πŸ“
Nathan Yergler
Nathan Yergler

πŸ“–
Nick Dower
Nick Dower

πŸ“– πŸ’» πŸ›
Nikhil Chelliah
Nikhil Chelliah

πŸ“–
OysteinHoiby
OysteinHoiby

πŸ’»
Patrick Forringer
Patrick Forringer

πŸ”Œ
Paul
Paul

πŸ“– πŸ“ 🌍
Phillip Thelen
Phillip Thelen

πŸ’»
Pixieish
Pixieish

πŸ“–
Prof. dr. Sorcha NΓ­ Dhubhghaill
Prof. dr. Sorcha NΓ­ Dhubhghaill

πŸ“–
Quentin FELIX
Quentin FELIX

πŸ’» 🎨
Rik Hekker
Rik Hekker

πŸ›
Sam Livingston-Gray
Sam Livingston-Gray

πŸ“–
Sanne
Sanne

πŸ’» πŸ“–
Sara Latorre
Sara Latorre

🌍
SeaZeeZee
SeaZeeZee

πŸ“– πŸ’»
SimonbJohnson
SimonbJohnson

πŸ›
SirCharlotte
SirCharlotte

🌍
Slylele
Slylele

πŸ“– 🌍
Soazillon
Soazillon

🌍
SoneaTheBest
SoneaTheBest

🌍
Stefan Sydow
Stefan Sydow

🌍 πŸ“– πŸ’»
TrΓ­ona
TrΓ­ona

πŸ“–
Unmutual
Unmutual

πŸ“–
Wouter van Wageningen
Wouter van Wageningen

πŸ’» 🎨 πŸ”§
amysews
amysews

πŸ“–
anna-puk
anna-puk

πŸ’»
beautifulsummermoon
beautifulsummermoon

🌍
berce
berce

πŸ“–
biou
biou

πŸ’»
bobgeorgethe3rd
bobgeorgethe3rd

πŸ’» πŸ“– 🎨
brmlyklr
brmlyklr

πŸ“–
chri5b
chri5b

πŸ’» ⚠️
dingcycle
dingcycle

🌍
drowned-in-books
drowned-in-books

πŸ’¬
econo202
econo202

πŸ“–
ericamattos
ericamattos

🌍
fightingrabbit
fightingrabbit

πŸ’»
gaylyndie
gaylyndie

πŸ“–
grimlokason
grimlokason

πŸ’»
hellgy
hellgy

🎨
jackseye
jackseye

πŸ“–
marckiesel
marckiesel

🌍
mesil
mesil

πŸ›
starfetch
starfetch

πŸ’» πŸ“– 🌍 🎨
timorl
timorl

πŸ’»
ttimearl
ttimearl

πŸ–‹
tuesgloomsday
tuesgloomsday

πŸ“–
valadaptive
valadaptive

πŸ’»
viocky
viocky

🌍
woolishboy
woolishboy

πŸ’»
yc
yc

🌍
- - - - - - -This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! - diff --git a/plugins/plugin-dimension/build.mjs b/plugins/plugin-dimension/build.mjs deleted file mode 100644 index 99ace216bc8..00000000000 --- a/plugins/plugin-dimension/build.mjs +++ /dev/null @@ -1,35 +0,0 @@ -/* This script will build the package with esbuild */ -import esbuild from 'esbuild' -import pkg from './package.json' assert { type: 'json' } - -// Create banner based on package info -const banner = `/** - * ${pkg.name} | v${pkg.version} - * ${pkg.description} - * (c) ${new Date().getFullYear()} ${pkg.author} - * @license ${pkg.license} - */` - -// Shared esbuild options -const options = { - banner: { js: banner }, - bundle: true, - entryPoints: ['src/index.mjs'], - format: 'esm', - outfile: 'dist/index.mjs', - external: ['@freesewing'], - metafile: process.env.VERBOSE ? true : false, - minify: process.env.NO_MINIFY ? false : true, - sourcemap: true, -} - -// Let esbuild generate the build -const build = async () => { - const result = await esbuild.build(options).catch(() => process.exit(1)) - - if (process.env.VERBOSE) { - const info = await esbuild.analyzeMetafile(result.metafile) - console.log(info) - } -} -build() diff --git a/plugins/plugin-dimension/data.mjs b/plugins/plugin-dimension/data.mjs deleted file mode 100644 index 2157d95674c..00000000000 --- a/plugins/plugin-dimension/data.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// This file is auto-generated | All changes you make will be overwritten. -export const name = '@freesewing/plugin-dimension' -export const version = '3.0.0-alpha.4' -export const data = { name, version } diff --git a/plugins/plugin-dimension/img/example.png b/plugins/plugin-dimension/img/example.png deleted file mode 100644 index ef8b3f06825..00000000000 Binary files a/plugins/plugin-dimension/img/example.png and /dev/null differ diff --git a/plugins/plugin-dimension/package.json b/plugins/plugin-dimension/package.json deleted file mode 100644 index 33e67448239..00000000000 --- a/plugins/plugin-dimension/package.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "name": "@freesewing/plugin-dimension", - "version": "3.0.0-alpha.4", - "description": "A FreeSewing plugin to add dimensions to your (paperless) pattern", - "author": "Joost De Cock (https://github.com/joostdecock)", - "homepage": "https://freesewing.org/", - "repository": "github:freesewing/freesewing", - "license": "MIT", - "bugs": { - "url": "https://github.com/freesewing/freesewing/issues" - }, - "funding": { - "type": "individual", - "url": "https://freesewing.org/patrons/join" - }, - "keywords": [ - "freesewing", - "plugin", - "sewing pattern", - "sewing", - "design", - "parametric design", - "made to measure", - "diy", - "fashion" - ], - "type": "module", - "module": "dist/index.mjs", - "exports": { - ".": "./dist/index.mjs" - }, - "scripts": { - "build": "node build.mjs", - "clean": "rimraf dist", - "mbuild": "NO_MINIFY=1 node build.mjs", - "symlink": "mkdir -p ./node_modules/@freesewing && cd ./node_modules/@freesewing && ln -s -f ../../../* . && cd -", - "test": "npx mocha tests/*.test.mjs", - "vbuild": "VERBOSE=1 node build.mjs", - "lab": "cd ../../sites/lab && yarn start", - "tips": "node ../../scripts/help.mjs", - "lint": "npx eslint 'src/**' 'tests/*.mjs'", - "prettier": "npx prettier --write 'src/*.mjs' 'tests/*.mjs'", - "testci": "npx mocha tests/*.test.mjs --reporter ../../tests/reporters/terse.js", - "cibuild_step1": "node build.mjs", - "wbuild": "node build.mjs", - "wcibuild_step1": "node build.mjs" - }, - "peerDependencies": { - "@freesewing/core": "3.0.0-alpha.4" - }, - "dependencies": {}, - "devDependencies": { - "mocha": "10.0.0", - "chai": "4.2.0" - }, - "files": [ - "dist/*", - "README.md" - ], - "publishConfig": { - "access": "public", - "tag": "next" - }, - "engines": { - "node": ">=16.0.0", - "npm": ">=8" - } -} diff --git a/plugins/plugin-dimension/src/index.mjs b/plugins/plugin-dimension/src/index.mjs deleted file mode 100644 index bedb50b8961..00000000000 --- a/plugins/plugin-dimension/src/index.mjs +++ /dev/null @@ -1,164 +0,0 @@ -import { name, version } from '../data.mjs' - -const markers = ` - - - - - - -` -const prefix = '__paperless' - -function drawDimension(from, to, so, { Path, units }) { - const dimension = new Path() - .move(from) - .line(to) - .attr('class', 'mark') - .attr('data-text', so.text || units(from.dist(to))) - .attr('data-text-class', 'fill-mark center') - if (!so.noStartMarker) dimension.attributes.set('marker-start', 'url(#dimensionFrom)') - if (!so.noEndMarker) dimension.attributes.set('marker-end', 'url(#dimensionTo)') - - return dimension -} - -function drawLeader({ paths, Path }, from, to, id) { - paths[id] = new Path().move(from).line(to).attr('class', 'mark dotted') -} - -function hleader(so, type, props, id) { - const { Point } = props - let point - if (typeof so.y === 'undefined' || so[type].y === so.y) { - point = so[type] - } else { - point = new Point(so[type].x, so.y) - drawLeader(props, so[type], point, id) - } - - return point -} - -function vleader(so, type, props, id) { - const { Point } = props - let point - if (typeof so.x === 'undefined' || so[type].x === so.x) { - point = so[type] - } else { - point = new Point(so.x, so[type].y) - drawLeader(props, so[type], point, id) - } - - return point -} - -function lleader(so, type, props, id) { - let point, rot, other - if (type === 'from') { - rot = 1 - other = 'to' - } else { - rot = -1 - other = 'from' - } - if (typeof so.d === 'undefined') { - point = so[type] - } else { - point = so[type].shiftTowards(so[other], so.d).rotate(90 * rot, so[type]) - drawLeader(props, so[type], point, id) - } - - return point -} - -export const plugin = { - name, - version, - hooks: { - preRender: (svg) => { - if (svg.defs.indexOf(markers) === -1) svg.defs += markers - }, - }, - macros: { - // horizontal - hd: function (so, props) { - const { getId, paths } = props - const id = so.id || getId(prefix) - paths[id] = drawDimension( - hleader(so, 'from', props, id + '_ls'), - hleader(so, 'to', props, id + '_le'), - so, - props - ) - }, - // vertical - vd: function (so, props) { - const { getId, paths } = props - const id = so.id || getId(prefix) - paths[id] = drawDimension( - vleader(so, 'from', props, id + '_ls'), - vleader(so, 'to', props, id + '_le'), - so, - props - ) - }, - // linear - ld: function (so, props) { - const { getId, paths } = props - const id = so.id || getId(prefix) - paths[id] = drawDimension( - lleader(so, 'from', props, id + '_ls'), - lleader(so, 'to', props, id + '_le'), - so, - props - ) - }, - // path - pd: function (so, props) { - const { getId, paths, scale, units } = props - const id = so.id || getId(prefix) - if (typeof so.d === 'undefined') so.d = 10 * scale - const dimension = so.path - .offset(so.d) - .attr('class', 'mark') - .attr('data-text', so.text || units(so.path.length())) - .attr('data-text-class', 'fill-mark center') - if (!so.noStartMarker) dimension.attributes.set('marker-start', 'url(#dimensionFrom)') - if (!so.noEndMarker) dimension.attributes.set('marker-end', 'url(#dimensionTo)') - paths[id] = dimension - drawLeader(props, so.path.start(), dimension.start(), id + '_ls') - drawLeader(props, so.path.end(), dimension.end(), id + '_le') - }, - // Remove dimension - rmd: function (so, props) { - const { paths } = props - if (paths[so.id]) delete this.paths[so.id] - if (paths[`${so.id}_ls`]) delete paths[`${so.id}_ls`] - if (paths[`${so.id}_le`]) delete paths[`${so.id}_le`] - if (Array.isArray(so.ids)) { - for (const id of so.ids) { - if (paths[id]) delete paths[id] - if (paths[`${id}_ls`]) delete paths[`${id}_ls`] - if (paths[`${id}_le`]) delete paths[`${id}_le`] - } - } - }, - // Remove all dimensions (with standard prefix) - rmad: function (params, props) { - const toRemove = { - points: props.point, - paths: props.paths, - } - for (let type in toRemove) { - for (let id in props[type]) { - if (id.slice(0, prefix.length) === prefix) delete props[type][id] - } - } - }, - }, -} - -// More specifically named exports -export const dimensionPlugin = plugin -export const pluginDimension = plugin diff --git a/plugins/plugin-dimension/src/lib/markers.js b/plugins/plugin-dimension/src/lib/markers.js deleted file mode 100644 index d04ddc42dd9..00000000000 --- a/plugins/plugin-dimension/src/lib/markers.js +++ /dev/null @@ -1,9 +0,0 @@ -// FIXME identical arrow paths for dimensions, cutonfold, and grainline -export default ` - - - - - - -`; diff --git a/plugins/plugin-dimension/tests/plugin.test.mjs b/plugins/plugin-dimension/tests/plugin.test.mjs deleted file mode 100644 index 3a43f2e256c..00000000000 --- a/plugins/plugin-dimension/tests/plugin.test.mjs +++ /dev/null @@ -1,240 +0,0 @@ -import chai from 'chai' -import { Design, round } from '@freesewing/core' -import { plugin } from '../src/index.mjs' - -const expect = chai.expect - -describe('Dimension Plugin Tests', () => { - describe('Measures horizontal dimensions', function () { - const part = { - name: 'test', - draft: ({ Point, points, macro, part }) => { - points.from = new Point(10, 20) - points.to = new Point(200, 20) - macro('hd', { - from: points.from, - to: points.to, - y: 35, - }) - - return part - }, - plugins: [plugin], - } - const Test = new Design({ parts: [part] }) - const pattern = new Test() - pattern.draft() - - it('should draw a line and add text to indicate its length', () => { - const c = pattern.parts[0].test.paths['__paperless1'] - expect(c.attributes.get('class')).to.equal('mark') - expect(c.attributes.get('marker-start')).to.equal('url(#dimensionFrom)') - expect(c.attributes.get('marker-end')).to.equal('url(#dimensionTo)') - expect(c.attributes.get('data-text')).to.equal('19cm') - expect(c.attributes.get('data-text-class')).to.equal('fill-mark center') - expect(c.ops[0].type).to.equal('move') - expect(c.ops[1].type).to.equal('line') - expect(c.ops[0].to.x).to.equal(10) - expect(c.ops[0].to.y).to.equal(35) - expect(c.ops[1].to.x).to.equal(200) - expect(c.ops[1].to.y).to.equal(35) - }) - - it('should draw the start marker', () => { - const c = pattern.parts[0].test.paths['__paperless1_ls'] - expect(c.attributes.get('class')).to.equal('mark dotted') - expect(c.ops[0].type).to.equal('move') - expect(c.ops[1].type).to.equal('line') - expect(c.ops[0].to.x).to.equal(10) - expect(c.ops[0].to.y).to.equal(20) - expect(c.ops[1].to.x).to.equal(10) - expect(c.ops[1].to.y).to.equal(35) - }) - - it('should draw the end marker', () => { - const c = pattern.parts[0].test.paths['__paperless1_le'] - expect(c.attributes.get('class')).to.equal('mark dotted') - expect(c.ops[0].type).to.equal('move') - expect(c.ops[1].type).to.equal('line') - expect(c.ops[0].to.x).to.equal(200) - expect(c.ops[0].to.y).to.equal(20) - expect(c.ops[1].to.x).to.equal(200) - expect(c.ops[1].to.y).to.equal(35) - }) - }) - - describe('Measures vertical dimensions', () => { - const part = { - name: 'test', - draft: ({ Point, points, macro, part }) => { - points.from = new Point(10, 20) - points.to = new Point(10, 200) - macro('vd', { - from: points.from, - to: points.to, - x: 25, - }) - - return part - }, - plugins: [plugin], - } - const Test = new Design({ parts: [part] }) - const pattern = new Test() - pattern.draft() - - it('Should draw a line and add text to indicate its length', () => { - const c = pattern.parts[0].test.paths['__paperless1'] - expect(c.attributes.get('class')).to.equal('mark') - expect(c.attributes.get('marker-start')).to.equal('url(#dimensionFrom)') - expect(c.attributes.get('marker-end')).to.equal('url(#dimensionTo)') - expect(c.attributes.get('data-text')).to.equal('18cm') - expect(c.attributes.get('data-text-class')).to.equal('fill-mark center') - expect(c.ops[0].type).to.equal('move') - expect(c.ops[1].type).to.equal('line') - expect(c.ops[0].to.x).to.equal(25) - expect(c.ops[0].to.y).to.equal(20) - expect(c.ops[1].to.x).to.equal(25) - expect(c.ops[1].to.y).to.equal(200) - }) - - it('Should draw the start marker', () => { - const c = pattern.parts[0].test.paths['__paperless1_ls'] - expect(c.attributes.get('class')).to.equal('mark dotted') - expect(c.ops[0].type).to.equal('move') - expect(c.ops[1].type).to.equal('line') - expect(c.ops[0].to.x).to.equal(10) - expect(c.ops[0].to.y).to.equal(20) - expect(c.ops[1].to.x).to.equal(25) - expect(c.ops[1].to.y).to.equal(20) - }) - - it('Should draw the end marker', () => { - const c = pattern.parts[0].test.paths['__paperless1_le'] - expect(c.attributes.get('class')).to.equal('mark dotted') - expect(c.ops[0].type).to.equal('move') - expect(c.ops[1].type).to.equal('line') - expect(c.ops[0].to.x).to.equal(10) - expect(c.ops[0].to.y).to.equal(200) - expect(c.ops[1].to.x).to.equal(25) - expect(c.ops[1].to.y).to.equal(200) - }) - }) - - describe('Measures the length of straight lines', () => { - const part = { - name: 'test', - draft: ({ Point, points, macro, part }) => { - points.from = new Point(10, 10) - points.to = new Point(100, 100) - macro('ld', { - from: points.from, - to: points.to, - d: 15, - }) - - return part - }, - plugins: [plugin], - } - const Test = new Design({ parts: [part] }) - const pattern = new Test() - pattern.draft() - - it('Should draw a line and add text to indicate its length', () => { - const c = pattern.parts[0].test.paths['__paperless1'] - expect(c.attributes.get('class')).to.equal('mark') - expect(c.attributes.get('marker-start')).to.equal('url(#dimensionFrom)') - expect(c.attributes.get('marker-end')).to.equal('url(#dimensionTo)') - expect(c.attributes.get('data-text')).to.equal('12.73cm') - expect(c.attributes.get('data-text-class')).to.equal('fill-mark center') - expect(c.ops[0].type).to.equal('move') - expect(c.ops[1].type).to.equal('line') - expect(round(c.ops[0].to.x)).to.equal(20.61) - expect(round(c.ops[0].to.y)).to.equal(-0.61) - expect(round(c.ops[1].to.x)).to.equal(110.61) - expect(round(c.ops[1].to.y)).to.equal(89.39) - }) - - it('Should draw the start marker', () => { - const c = pattern.parts[0].test.paths['__paperless1_ls'] - expect(c.attributes.get('class')).to.equal('mark dotted') - expect(c.ops[0].type).to.equal('move') - expect(c.ops[1].type).to.equal('line') - expect(round(c.ops[0].to.x)).to.equal(10) - expect(round(c.ops[0].to.y)).to.equal(10) - expect(round(c.ops[1].to.x)).to.equal(20.61) - expect(round(c.ops[1].to.y)).to.equal(-0.61) - }) - - it('Should draw the end marker', () => { - const c = pattern.parts[0].test.paths['__paperless1_le'] - expect(c.attributes.get('class')).to.equal('mark dotted') - expect(c.ops[0].type).to.equal('move') - expect(c.ops[1].type).to.equal('line') - expect(round(c.ops[0].to.x)).to.equal(100) - expect(round(c.ops[0].to.y)).to.equal(100) - expect(round(c.ops[1].to.x)).to.equal(110.61) - expect(round(c.ops[1].to.y)).to.equal(89.39) - }) - }) - - describe('Measures curved lines', () => { - const part = { - name: 'test', - draft: ({ Point, points, macro, Path, part }) => { - points.from = new Point(10, 10) - points.cp1 = new Point(100, 10) - points.cp2 = new Point(10, 100) - points.to = new Point(100, 100) - macro('pd', { - path: new Path().move(points.from).curve(points.cp1, points.cp2, points.to), - d: 15, - }) - - return part - }, - plugins: [plugin], - } - const Test = new Design({ parts: [part] }) - const pattern = new Test() - pattern.draft() - - it('Should draw a line and add text to indicate the length', () => { - const c = pattern.parts[0].test.paths['__paperless1'] - expect(c.attributes.get('class')).to.equal('mark') - expect(c.attributes.get('marker-start')).to.equal('url(#dimensionFrom)') - expect(c.attributes.get('marker-end')).to.equal('url(#dimensionTo)') - expect(c.attributes.get('data-text')).to.equal('15.09cm') - expect(c.attributes.get('data-text-class')).to.equal('fill-mark center') - expect(c.ops[0].type).to.equal('move') - expect(c.ops[1].type).to.equal('curve') - expect(round(c.ops[0].to.x)).to.equal(10) - expect(round(c.ops[0].to.y)).to.equal(25) - expect(round(c.ops[1].to.x)).to.equal(37.15) - expect(round(c.ops[1].to.y)).to.equal(32.79) - }) - - it('Should draw the start marker', () => { - const c = pattern.parts[0].test.paths['__paperless1_ls'] - expect(c.attributes.get('class')).to.equal('mark dotted') - expect(c.ops[0].type).to.equal('move') - expect(c.ops[1].type).to.equal('line') - expect(c.ops[0].to.x).to.equal(10) - expect(c.ops[0].to.y).to.equal(10) - expect(c.ops[1].to.x).to.equal(10) - expect(c.ops[1].to.y).to.equal(25) - }) - - it('Should draw the end marker', () => { - const c = pattern.parts[0].test.paths['__paperless1_le'] - expect(c.attributes.get('class')).to.equal('mark dotted') - expect(c.ops[0].type).to.equal('move') - expect(c.ops[1].type).to.equal('line') - expect(c.ops[0].to.x).to.equal(100) - expect(c.ops[0].to.y).to.equal(100) - expect(c.ops[1].to.x).to.equal(100) - expect(c.ops[1].to.y).to.equal(115) - }) - }) -}) diff --git a/plugins/plugin-dimension/tests/shared.test.mjs b/plugins/plugin-dimension/tests/shared.test.mjs deleted file mode 100644 index 7bf4f668398..00000000000 --- a/plugins/plugin-dimension/tests/shared.test.mjs +++ /dev/null @@ -1,6 +0,0 @@ -// This file is auto-generated | Any changes you make will be overwritten. -import { plugin } from '../src/index.mjs' -import { sharedPluginTests } from '../../../tests/plugins/shared.mjs' - -// Run shared tests -sharedPluginTests(plugin)