diff --git a/markdown/dev/reference/api/pattern/en.md b/markdown/dev/reference/api/pattern/en.md index 1482e10e751..45ae63563a0 100644 --- a/markdown/dev/reference/api/pattern/en.md +++ b/markdown/dev/reference/api/pattern/en.md @@ -76,6 +76,7 @@ It just so happens that in most cases, there will be only one settings object in - `Pattern.parts`: Holds the parts used in the pattern - `Pattern.plugins`: Holds the plugins used in the pattern - `Pattern.settings`: Holds the settings used for the pattern +- `Pattern.stacks`: Holds the stacks used in the pattern - `Pattern.store`: Holds the pattern-wide Store - `Pattern.setStores`: Holds an array of stores, one for each set of settings. diff --git a/markdown/dev/reference/api/stack/addPart/en.md b/markdown/dev/reference/api/stack/addPart/en.md new file mode 100644 index 00000000000..9629511c4da --- /dev/null +++ b/markdown/dev/reference/api/stack/addPart/en.md @@ -0,0 +1,14 @@ +--- +title: Stack.addPart() +--- + +The `Stack.addPart()` method adds a part to the stack and returns the +original stack. + +## Stack.addPart() signature + +```js +Stack stack.addPart(Part part) +``` + +This method is chainable as it returns the Stack object diff --git a/markdown/dev/reference/api/stack/asProps/en.md b/markdown/dev/reference/api/stack/asProps/en.md new file mode 100644 index 00000000000..7208bd5e566 --- /dev/null +++ b/markdown/dev/reference/api/stack/asProps/en.md @@ -0,0 +1,12 @@ +--- +title: Stack.asProps() +--- + +The `Stack.asProps()` method returns a stack object suitable for renderprops. + + +## Stack.asProps() signature + +```js +Object stack.asProps() +``` diff --git a/markdown/dev/reference/api/stack/attr/en.md b/markdown/dev/reference/api/stack/attr/en.md new file mode 100644 index 00000000000..17cf2e31888 --- /dev/null +++ b/markdown/dev/reference/api/stack/attr/en.md @@ -0,0 +1,23 @@ +--- +title: Stack.attr() +--- + +The `Stack.attr()` method adds an attribute to the stack +and returns the original stack. +Setting the third parameter to `true` will replace the value of the +attribute instead of adding it. + +## Stack.attr() signature + +```js +Stack stack.attr( + string name, + mixed value, + bool overwrite = false +``` + +If the third parameter is set to `true` it will call +`this.attributes.set()` instead, +thereby overwriting the value of the attribute. + +This method is chainable as it returns the Stack object diff --git a/markdown/dev/reference/api/stack/en.md b/markdown/dev/reference/api/stack/en.md new file mode 100644 index 00000000000..d824c087105 --- /dev/null +++ b/markdown/dev/reference/api/stack/en.md @@ -0,0 +1,52 @@ +--- +title: Stack +--- + +A Stack object represents a layer within a pattern, holding one or +more parts.. + + + +See [Stacks](/guides/patterns/stacks) +for information about how stacks are used in a pattern + + + +## Signature + +```js +Stack new Stack(String name) +``` + +The stack constructor takes a single argument, a String containing the name +of the stack. + +## Properties + +Stack objects come with the following properties: + +- `attributes` : An [Attributes](/reference/api/attributes) instance holding the point's attributes +- `parts` : A set of parts in the stack +- `name` : The name of the stack +- `topleft` : A [Point](/reference/api/point) that is the top left of the stack's bounding box +- `bottomRight` : A [Point](/reference/api/point) that is the bottom right of the stack's bounding box +- `width` : The width of the stack in mm +- `height` : The height of the stack in mm +- `anchor` : A [Point](/reference/api/point) that is used as the anchor to align parts in the stack + + +## Example + + +```js +import { Stack } from '@freesewing/core' + +const myStack = new Stack('mystack') +``` + + +## Methods + +A Stack object exposes the following methods: + + diff --git a/markdown/dev/reference/api/stack/generateTransform/en.md b/markdown/dev/reference/api/stack/generateTransform/en.md new file mode 100644 index 00000000000..e1eeb6f2a2d --- /dev/null +++ b/markdown/dev/reference/api/stack/generateTransform/en.md @@ -0,0 +1,26 @@ +--- +title: Stack.generateTransform() +--- + +The `Stack.generateTransform()` method generates transforms for the stack, +sets them as attributes, and returns the original stack. + + +## Stack.generateTransform() signature + +```js +Stack stack.generateTransforms(Object transforms) +``` + +The `Stack.generateTransforms()` method takes a single argument, +an object with the following properties containing the transforms +to apply: + +| Property | Type |Description | +|----------|------|------------| +| `move` | Object | `move.x` and `move.y` are coordinates to which the stack should be translated +| `rotate` | Number | The number of degrees to rate the stack around its center | +| `flipX` | Boolean | Whether to flip the stack along the X axis | +| `flipY` | Boolean | Whether to flip the stack along the Y axis | + +This method is chainable as it returns the Stack object diff --git a/markdown/dev/reference/api/stack/getAnchor/en.md b/markdown/dev/reference/api/stack/getAnchor/en.md new file mode 100644 index 00000000000..4bcc943381a --- /dev/null +++ b/markdown/dev/reference/api/stack/getAnchor/en.md @@ -0,0 +1,13 @@ +--- +title: Stack.getAnchor() +--- + +The `Stack.getAnchor()` method returns the Point which is the anchor +to align parts in the stack. + + +## Stack.getAnchor() signature + +```js +Point stack.getAnchor() +``` diff --git a/markdown/dev/reference/api/stack/getPartList/en.md b/markdown/dev/reference/api/stack/getPartList/en.md new file mode 100644 index 00000000000..396aa2e81b1 --- /dev/null +++ b/markdown/dev/reference/api/stack/getPartList/en.md @@ -0,0 +1,12 @@ +--- +title: Stack.getPartList() +--- + +The `Stack.getPartList()` method returns an Array containing the parts +in this stack. + +## Stack.getPartList() signature + +```js +Part[] stack.getPartList() +``` diff --git a/markdown/dev/reference/api/stack/getPartNames/en.md b/markdown/dev/reference/api/stack/getPartNames/en.md new file mode 100644 index 00000000000..270e153b529 --- /dev/null +++ b/markdown/dev/reference/api/stack/getPartNames/en.md @@ -0,0 +1,12 @@ +--- +title: Stack.getPartNames() +--- + +The `Stack.getPartNames()` method returns an Array containing the names +of the parts in the stack. + +## Stack.getPartNames() signature + +```js +String[] stack.getPartNames() +``` diff --git a/markdown/dev/reference/api/stack/home/en.md b/markdown/dev/reference/api/stack/home/en.md new file mode 100644 index 00000000000..9d53f105b1f --- /dev/null +++ b/markdown/dev/reference/api/stack/home/en.md @@ -0,0 +1,17 @@ +--- +title: Stack.home() +--- + +The `Stack.home()` method calculates the stack's bounding box, sets it, +and returns the original stack. + +## Stack.home() signature + +```js +Stack stack.home() +``` +This method is chainable as it returns the Stack object + +## Notes + +The bounding box is calculated taking into consideration the `margin` setting.