Methods
beginRecord()
Begins recording embroidery data.
While recording, p5.js drawing functions are interpreted in millimetres and converted into stitches instead of being drawn directly.
Takes no arguments. p5.embroider registers itself as a p5 addon, so it already knows the sketch instance. The pre-0.3 form beginRecord(this) still works; the argument is ignored.
- Source
function setup() {
createCanvas(400, 400);
beginRecord();
// Draw embroidery patterns here
endRecord();
}beginRecord(p5Instance)
Begins recording embroidery data.
| Name | Type | Description |
|---|---|---|
p5Instance | p5 | The p5.js sketch instance |
- Source
function setup() {
createCanvas(400, 400);
beginRecord(this);
// Draw embroidery patterns here
endRecord();
}embroideryOutline(offsetDistance, threadIndexopt, outlineTypeopt, cornerRadiusopt)
Adds an outline around the embroidery at a specified offset distance.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
offsetDistance | number | Distance in mm to offset the outline from the embroidery | ||
threadIndex | number | <optional> | Thread index to add the outline to (defaults to current stroke thread) | |
outlineType | string | <optional> | 'convex' | Type of outline ('convex', 'bounding') |
cornerRadius | number | <optional> | 0 | Corner radius in mm for bounding box outlines (only applies to 'bounding' type) |
- Source
function setup() {
createCanvas(400, 400);
beginRecord();
// Draw embroidery patterns
circle(50, 50, 20);
embroideryOutline(5); // Add 5mm outline around the embroidery
embroideryOutline(10, 1, "bounding", 5); // Add 10mm bounding box outline with 5mm rounded corners
endRecord();
}embroideryOutline(offsetDistance, threadIndexopt, outlineTypeopt, cornerRadiusopt)
Adds an outline around the embroidery at a specified offset distance.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
offsetDistance | number | Distance in mm to offset the outline from the embroidery | ||
threadIndex | number | <optional> | Thread index to add the outline to (defaults to current stroke thread) | |
outlineType | string | <optional> | 'convex' | Type of outline ('convex', 'bounding') |
cornerRadius | number | <optional> | 0 | Corner radius in mm for bounding box outlines (only applies to 'bounding' type) |
- Source
function setup() {
createCanvas(400, 400);
beginRecord(this);
// Draw embroidery patterns
circle(50, 50, 20);
embroideryOutline(5); // Add 5mm outline around the embroidery
embroideryOutline(10, 1, "bounding", 5); // Add 10mm bounding box outline with 5mm rounded corners
endRecord();
}embroideryOutlineFromPath(stitchDataArray, offsetDistance, threadIndexopt, outlineTypeopt, applyTransformopt, cornerRadiusopt) → {Array}
Creates an outline around specified stitch data at a specified offset distance.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
stitchDataArray | Array | Array of stitch data objects (each with x, y coordinates) | ||
offsetDistance | number | Distance in mm to offset the outline from the path | ||
threadIndex | number | <optional> | Thread index to add the outline to (defaults to current stroke thread) | |
outlineType | string | <optional> | 'convex' | Type of outline ('convex', 'bounding', 'scale') |
applyTransform | boolean | <optional> | true | Whether to apply current transformation to the outline |
cornerRadius | number | <optional> | 0 | Corner radius in mm for bounding box outlines (only applies to 'bounding' type) |
- Source
Array of outline points {x, y}
- Type:
- Array
function setup() {
createCanvas(400, 400);
beginRecord();
// Create some stitch data
let pathData = [{x: 50, y: 50}, {x: 100, y: 50}, {x: 100, y: 100}];
let outlinePoints = embroideryOutlineFromPath(pathData, 5); // Add 5mm outline
let roundedOutline = embroideryOutlineFromPath(pathData, 8, 0, "bounding", true, 3); // 8mm bounding box with 3mm corners
// Use the outline points for further processing
endRecord();
}embroideryOutlineFromPath(stitchDataArray, offsetDistance, threadIndexopt, outlineTypeopt, applyTransformopt, cornerRadiusopt) → {Array}
Creates an outline around specified stitch data at a specified offset distance.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
stitchDataArray | Array | Array of stitch data objects (each with x, y coordinates) | ||
offsetDistance | number | Distance in mm to offset the outline from the path | ||
threadIndex | number | <optional> | Thread index to add the outline to (defaults to current stroke thread) | |
outlineType | string | <optional> | 'convex' | Type of outline ('convex', 'bounding', 'scale') |
applyTransform | boolean | <optional> | true | Whether to apply current transformation to the outline |
cornerRadius | number | <optional> | 0 | Corner radius in mm for bounding box outlines (only applies to 'bounding' type) |
- Source
Array of outline points {x, y}
- Type:
- Array
function setup() {
createCanvas(400, 400);
beginRecord(this);
// Create some stitch data
let pathData = [{x: 50, y: 50}, {x: 100, y: 50}, {x: 100, y: 100}];
let outlinePoints = embroideryOutlineFromPath(pathData, 5); // Add 5mm outline
let roundedOutline = embroideryOutlineFromPath(pathData, 8, 0, "bounding", true, 3); // 8mm bounding box with 3mm corners
// Use the outline points for further processing
endRecord();
}endRecord()
Ends recording and prepares for export.
- Source
function setup() {
createCanvas(400, 400);
beginRecord();
// Draw embroidery patterns
endRecord();
}endRecord()
Ends recording and prepares for export.
- Source
function setup() {
createCanvas(400, 400);
beginRecord(this);
// Draw embroidery patterns
endRecord();
}exportDST(filenameopt)
Exports the recorded embroidery data as a DST file.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
filename | String | <optional> | 'embroideryPattern.dst' | Output filename |
- Source
function setup() {
createCanvas(400, 400);
beginRecord();
// Draw embroidery patterns
endRecord();
exportDST('pattern.dst');
}exportDST(filenameopt)
Exports the recorded embroidery data as a DST file.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
filename | String | <optional> | 'embroideryPattern.dst' | Output filename |
- Source
function setup() {
createCanvas(400, 400);
beginRecord(this);
// Draw embroidery patterns
endRecord();
exportDST('pattern.dst');
}exportEmbroidery(filename)
Exports the recorded embroidery data as a file. Supported formats: DST (.dst), SVG (.svg), PNG (.png), JSON (.json)
| Name | Type | Description |
|---|---|---|
filename | String | Output filename with extension (dst, svg, png, or json) |
- Source
function setup() {
createCanvas(400, 400);
beginRecord();
// Draw embroidery patterns here
circle(50, 50, 20);
line(10, 10, 90, 90);
endRecord();
exportEmbroidery('pattern.dst'); // or .svg, .png, .json
}exportEmbroidery(filename)
Exports the recorded embroidery data as a file. Supported formats: DST (.dst), SVG (.svg), PNG (.png), JSON (.json)
| Name | Type | Description |
|---|---|---|
filename | String | Output filename with extension (dst, svg, png, or json) |
- Source
function setup() {
createCanvas(400, 400);
beginRecord(this);
// Draw embroidery patterns here
circle(50, 50, 20);
line(10, 10, 90, 90);
endRecord();
exportEmbroidery('pattern.dst'); // or .svg, .png, .json
}exportGcode(filename)
Exports the recorded embroidery data as a G-code file.
| Name | Type | Description |
|---|---|---|
filename | String | Output filename |
- Source
function setup() {
createCanvas(400, 400);
beginRecord();
// Draw embroidery patterns
endRecord();
exportGcode('pattern.gcode');
}exportGcode(filename)
Exports the recorded embroidery data as a G-code file.
| Name | Type | Description |
|---|---|---|
filename | String | Output filename |
- Source
function setup() {
createCanvas(400, 400);
beginRecord(this);
// Draw embroidery patterns
endRecord();
exportGcode('pattern.gcode');
}exportJSON(filenameopt, optionsopt)
Exports the recorded embroidery data as a JSON file with detailed stitch information organized by thread ID.
| Name | Type | Attributes | Default | Description | |||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
filename | string | <optional> | 'embroidery-pattern.json' | Output filename | |||||||||||||||||||||||||
options | Object | <optional> | {} | Export options Properties
|
- Source
function setup() {
createCanvas(400, 400);
beginRecord();
// Draw embroidery patterns
circle(50, 50, 20);
line(10, 10, 90, 90);
endRecord();
exportJSON('my-pattern.json', {
precision: 3,
includeMetadata: true
});
}exportJSON(filenameopt, optionsopt)
Exports the recorded embroidery data as a JSON file with detailed stitch information organized by thread ID.
| Name | Type | Attributes | Default | Description | |||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
filename | string | <optional> | 'embroidery-pattern.json' | Output filename | |||||||||||||||||||||||||
options | Object | <optional> | {} | Export options Properties
|
- Source
function setup() {
createCanvas(400, 400);
beginRecord(this);
// Draw embroidery patterns
circle(50, 50, 20);
line(10, 10, 90, 90);
endRecord();
exportJSON('my-pattern.json', {
precision: 3,
includeMetadata: true
});
}exportOutline(threadIndex, offsetDistance, filename, outlineTypeopt) → {Promise.<boolean>}
Creates and exports an outline from a specified thread index with the given offset.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
threadIndex | number | Index of the thread to create outline from | ||
offsetDistance | number | Distance in mm to offset the outline | ||
filename | string | Output filename with extension (supports .png, .svg, .gcode, .dst) | ||
outlineType | string | <optional> | 'convex' | Type of outline ('convex', 'bounding', 'scale') |
- Source
Promise that resolves to true if export was successful
- Type:
- Promise.<boolean>
function setup() {
createCanvas(400, 400);
beginRecord();
// Draw embroidery patterns
circle(50, 50, 20);
endRecord();
// Export outline of thread 0 with 5mm offset as SVG
exportOutline(0, 5, "outline.svg");
// Export outline with bounding box type as G-code
exportOutline(0, 10, "cut-outline.gcode", "bounding");
}exportOutline(threadIndex, offsetDistance, filename, outlineTypeopt) → {Promise.<boolean>}
Creates and exports an outline from a specified thread index with the given offset.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
threadIndex | number | Index of the thread to create outline from | ||
offsetDistance | number | Distance in mm to offset the outline | ||
filename | string | Output filename with extension (supports .png, .svg, .gcode, .dst) | ||
outlineType | string | <optional> | 'convex' | Type of outline ('convex', 'bounding', 'scale') |
- Source
Promise that resolves to true if export was successful
- Type:
- Promise.<boolean>
function setup() {
createCanvas(400, 400);
beginRecord(this);
// Draw embroidery patterns
circle(50, 50, 20);
endRecord();
// Export outline of thread 0 with 5mm offset as SVG
exportOutline(0, 5, "outline.svg");
// Export outline with bounding box type as G-code
exportOutline(0, 10, "cut-outline.gcode", "bounding");
}exportPES(filenameopt)
Exports the recorded embroidery data as a PES file.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
filename | String | <optional> | 'embroideryPattern.pes' | Output filename |
- Source
function setup() {
createCanvas(400, 400);
beginRecord();
// Draw embroidery patterns
endRecord();
exportPES('pattern.pes');
}exportPES(filenameopt)
Exports the recorded embroidery data as a PES file.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
filename | String | <optional> | 'embroideryPattern.pes' | Output filename |
- Source
function setup() {
createCanvas(400, 400);
beginRecord(this);
// Draw embroidery patterns
endRecord();
exportPES('pattern.pes');
}exportPNG(filename, optionsopt)
Exports embroidery pattern as PNG for printing templates.
| Name | Type | Attributes | Default | Description | |||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
filename | string | Output filename | |||||||||||||||||||||||||||||||||||||
options | Object | <optional> | {} | Export options Properties
|
- Source
function setup() {
createCanvas(400, 400);
beginRecord();
// Draw embroidery patterns
circle(50, 50, 20);
endRecord();
exportPNG('my-pattern.png', {
paperSize: 'A4',
hoopSize: {width: 100, height: 100}
});
}exportPNG(filename, optionsopt)
Exports embroidery pattern as PNG for printing templates.
| Name | Type | Attributes | Default | Description | |||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
filename | string | Output filename | |||||||||||||||||||||||||||||||||||||
options | Object | <optional> | {} | Export options Properties
|
- Source
function setup() {
createCanvas(400, 400);
beginRecord(this);
// Draw embroidery patterns
circle(50, 50, 20);
endRecord();
exportPNG('my-pattern.png', {
paperSize: 'A4',
hoopSize: {width: 100, height: 100}
});
}exportSVG(filename, optionsopt)
Exports embroidery pattern as SVG for printing templates.
| Name | Type | Attributes | Default | Description | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
filename | string | Output filename | ||||||||||||||||||||||||||||||||||||||||||
options | Object | <optional> | {} | Export options Properties
|
- Source
function setup() {
createCanvas(400, 400);
beginRecord();
// Draw embroidery patterns at specific coordinates
translate(100, 25); // Position at 100mm, 25mm
circle(0, 0, 20);
endRecord();
// Export at original coordinates (recommended)
exportSVG('my-pattern.svg', {
paperSize: 'A4',
hoopSize: {width: 200, height: 200},
centerPattern: false // Preserves your coordinate positioning
});
}exportSVG(filename, optionsopt)
Exports embroidery pattern as SVG for printing templates.
| Name | Type | Attributes | Default | Description | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
filename | string | Output filename | ||||||||||||||||||||||||||||||||||||||||||
options | Object | <optional> | {} | Export options Properties
|
- Source
function setup() {
createCanvas(400, 400);
beginRecord(this);
// Draw embroidery patterns at specific coordinates
translate(100, 25); // Position at 100mm, 25mm
circle(0, 0, 20);
endRecord();
// Export at original coordinates (recommended)
exportSVG('my-pattern.svg', {
paperSize: 'A4',
hoopSize: {width: 200, height: 200},
centerPattern: false // Preserves your coordinate positioning
});
}exportSVGFromPath(threadIndex, filename, optionsopt) → {Promise.<boolean>}
Exports only the specified thread path as SVG without creating an outline.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
threadIndex | number | Index of the thread to export | ||
filename | string | Output filename with .svg extension | ||
options | Object | <optional> | {} | Export options |
- Deprecated
- Use exportSVG() with threads option instead
- Source
Promise that resolves to true if export was successful
- Type:
- Promise.<boolean>
function setup() {
createCanvas(400, 400);
beginRecord();
// Thread 0 - Red circle
stroke(255, 0, 0);
circle(50, 50, 20);
// Thread 1 - Blue square
stroke(0, 0, 255);
rect(30, 30, 40, 40);
endRecord();
// Old way (deprecated):
exportSVGFromPath(0, "thread0-path.svg");
// New way (recommended):
exportSVG("thread0-path.svg", { threads: [0] });
}exportSVGFromPath(threadIndex, filename, optionsopt) → {Promise.<boolean>}
Exports only the specified thread path as SVG without creating an outline.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
threadIndex | number | Index of the thread to export | ||
filename | string | Output filename with .svg extension | ||
options | Object | <optional> | {} | Export options |
- Deprecated
- Use exportSVG() with threads option instead
- Source
Promise that resolves to true if export was successful
- Type:
- Promise.<boolean>
function setup() {
createCanvas(400, 400);
beginRecord(this);
// Thread 0 - Red circle
stroke(255, 0, 0);
circle(50, 50, 20);
// Thread 1 - Blue square
stroke(0, 0, 255);
rect(30, 30, 40, 40);
endRecord();
// Old way (deprecated):
exportSVGFromPath(0, "thread0-path.svg");
// New way (recommended):
exportSVG("thread0-path.svg", { threads: [0] });
}mm2px(mm, dpi) → {Number}
Alias for mmToPixel - converts millimeters to pixels.
| Name | Type | Description |
|---|---|---|
mm | Number | Millimeters |
dpi | Number | Dots per inch (default: 96) |
- Source
Pixels
- Type:
- Number
mm2px(mm, dpi) → {Number}
Alias for mmToPixel - converts millimeters to pixels.
| Name | Type | Description |
|---|---|---|
mm | Number | Millimeters |
dpi | Number | Dots per inch (default: 96) |
- Source
Pixels
- Type:
- Number
mmToPixel(mm, dpi) → {Number}
Converts millimeters to pixels.
| Name | Type | Description |
|---|---|---|
mm | Number | Millimeters |
dpi | Number | Dots per inch (default: 96) |
- Source
Pixels
- Type:
- Number
function setup() {
let pixels = mmToPixel(10); // Convert 10mm to pixels
if(_DEBUG) console.log(pixels);
}mmToPixel(mm, dpi) → {Number}
Converts millimeters to pixels.
| Name | Type | Description |
|---|---|---|
mm | Number | Millimeters |
dpi | Number | Dots per inch (default: 96) |
- Source
Pixels
- Type:
- Number
function setup() {
let pixels = mmToPixel(10); // Convert 10mm to pixels
if(_DEBUG) console.log(pixels);
}pixelToMm(pixels, dpi) → {Number}
Converts pixels to millimeters.
| Name | Type | Description |
|---|---|---|
pixels | Number | Pixels |
dpi | Number | Dots per inch (default: 96) |
- Source
Millimeters
- Type:
- Number
function setup() {
let mm = pixelToMm(100); // Convert 100 pixels to mm
if(_DEBUG) console.log(mm);
}pixelToMm(pixels, dpi) → {Number}
Converts pixels to millimeters.
| Name | Type | Description |
|---|---|---|
pixels | Number | Pixels |
dpi | Number | Dots per inch (default: 96) |
- Source
Millimeters
- Type:
- Number
function setup() {
let mm = pixelToMm(100); // Convert 100 pixels to mm
if(_DEBUG) console.log(mm);
}px2mm(pixels, dpi) → {Number}
Alias for pixelToMm - converts pixels to millimeters.
| Name | Type | Description |
|---|---|---|
pixels | Number | Pixels |
dpi | Number | Dots per inch (default: 96) |
- Source
Millimeters
- Type:
- Number
px2mm(pixels, dpi) → {Number}
Alias for pixelToMm - converts pixels to millimeters.
| Name | Type | Description |
|---|---|---|
pixels | Number | Pixels |
dpi | Number | Dots per inch (default: 96) |
- Source
Millimeters
- Type:
- Number
setCurveDetail(detail)
Sets how many segments are used when flattening curves, splines and beziers into stitch paths. Higher values follow the curve more closely at the cost of more stitches.
p5.js 1.x exposed this through curveDetail() and bezierDetail(). In p5.js 2.0 curveDetail() throws outside WebGL mode, so p5.embroider carries its own setting for 2D sketches.
| Name | Type | Description |
|---|---|---|
detail | Number | Segments per curve segment. Minimum 1, default 20. Pass null to fall back to the renderer's own value. |
- Source
function setup() {
createCanvas(400, 400);
beginRecord();
setCurveDetail(40); // smoother curves, more stitches
}setDrawMode(mode)
Sets the draw mode for embroidery.
| Name | Type | Description |
|---|---|---|
mode | String | The draw mode to set ('stitch', 'p5', 'realistic') |
- Source
function setup() {
createCanvas(400, 400);
beginRecord();
setDrawMode('stitch'); // Show stitch points and lines
// Draw embroidery patterns
}setDrawMode(mode)
Sets the draw mode for embroidery.
| Name | Type | Description |
|---|---|---|
mode | String | The draw mode to set ('stitch', 'p5', 'realistic') |
- Source
function setup() {
createCanvas(400, 400);
beginRecord(this);
setDrawMode('stitch'); // Show stitch points and lines
// Draw embroidery patterns
}setFillMode(mode)
Sets the fill mode for embroidery fills.
| Name | Type | Description |
|---|---|---|
mode | string | The fill mode to use ('tatami', 'satin', or 'spiral') |
- Source
setFillMode(mode)
Sets the fill mode for embroidery fills.
| Name | Type | Description |
|---|---|---|
mode | string | The fill mode to use ('tatami', 'satin', or 'spiral') |
- Source
setFillSettings(settings)
Sets the fill settings for embroidery.
| Name | Type | Description | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
settings | Object | Fill settings object Properties
|
- Source
setFillSettings(settings)
Sets the fill settings for embroidery.
| Name | Type | Description |
|---|---|---|
settings | Object | The settings for the fill |
- Source
setFillSettings(settings)
Sets the fill settings for embroidery.
| Name | Type | Description | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
settings | Object | Fill settings object Properties
|
- Source
setFillSettings(settings)
Sets the fill settings for embroidery.
| Name | Type | Description |
|---|---|---|
settings | Object | The settings for the fill |
- Source
setStitch(minLength, desiredLength, noise)
Sets the stitch parameters for embroidery.
| Name | Type | Description |
|---|---|---|
minLength | Number | Minimum stitch length in millimeters |
desiredLength | Number | Desired stitch length in millimeters |
noise | Number | Amount of random variation in stitch length (0-1) |
- Source
function setup() {
createCanvas(400, 400);
beginRecord();
setStitch(1, 3, 0.2); // min 1mm, desired 3mm, 20% noise
// Draw embroidery patterns
}setStitch(minLength, desiredLength, noise)
Sets the stitch parameters for embroidery.
| Name | Type | Description |
|---|---|---|
minLength | Number | Minimum stitch length in millimeters |
desiredLength | Number | Desired stitch length in millimeters |
noise | Number | Amount of random variation in stitch length (0-1) |
- Source
function setup() {
createCanvas(400, 400);
beginRecord(this);
setStitch(1, 3, 0.2); // min 1mm, desired 3mm, 20% noise
// Draw embroidery patterns
}setStitchInterpolate(enabled)
Sets whether zigzag stitches should interpolate smoothly around corners.
| Name | Type | Description |
|---|---|---|
enabled | boolean | false = follow path normals with sharp corners (default), true = interpolate for smooth corners |
- Source
setStitchInterpolate(enabled)
Sets whether zigzag stitches should interpolate smoothly around corners.
| Name | Type | Description |
|---|---|---|
enabled | boolean | false = follow path normals with sharp corners (default), true = interpolate for smooth corners |
- Source
setStitchWidth(width)
Sets the stitch width parameters for embroidery.
| Name | Type | Description |
|---|---|---|
width | Number | Width of the stitch in millimeters |
- Source
function setup() {
createCanvas(400, 400);
beginRecord();
setStitchWidth(0.2); // width 0.2mm
// Draw embroidery patterns
}setStitchWidth(width)
Sets the stitch width parameters for embroidery.
| Name | Type | Description |
|---|---|---|
width | Number | Width of the stitch in millimeters |
- Source
function setup() {
createCanvas(400, 400);
beginRecord(this);
setStitchWidth(0.2); // width 0.2mm
// Draw embroidery patterns
}setStrokeEntryExit(entry, exit)
Sets the stroke chirality for embroidery stitches.
| Name | Type | Description |
|---|---|---|
entry | string | The entry direction to use ('right' or 'left') |
exit | string | The exit direction to use ('right' or 'left') |
- Source
setStrokeEntryExit(entry, exit)
Sets the stroke chirality for embroidery stitches.
| Name | Type | Description |
|---|---|---|
entry | string | The entry direction to use ('right' or 'left') |
exit | string | The exit direction to use ('right' or 'left') |
- Source
setStrokeJoin(join)
Sets the stroke join mode for embroidery stitches.
| Name | Type | Description |
|---|---|---|
join | string | The stroke join mode to use ('round', 'miter', or 'bevel') |
- Source
function setup() {
createCanvas(400, 400);
beginRecord();
setStrokeJoin('miter');
beginShape();
vertex(20, 20);
vertex(50, 20);
vertex(50, 50);
endShape();
}setStrokeJoin(join)
Sets the stroke join mode for embroidery stitches.
| Name | Type | Description |
|---|---|---|
join | string | The stroke join mode to use ('round', 'miter', or 'bevel') |
- Source
function setup() {
createCanvas(400, 400);
beginRecord(this);
setStrokeJoin('miter');
beginShape();
vertex(20, 20);
vertex(50, 20);
vertex(50, 50);
endShape();
}setStrokeMode(mode)
Sets the stroke mode for embroidery stitches.
| Name | Type | Description |
|---|---|---|
mode | string | The stroke mode to use ('zigzag', 'parallel', or 'sashiko') |
- Source
function setup() {
createCanvas(400, 400);
beginRecord();
setStrokeMode('zigzag');
line(10, 10, 50, 50); // Will use zigzag stitch pattern
}setStrokeMode(mode)
Sets the stroke mode for embroidery stitches.
| Name | Type | Description |
|---|---|---|
mode | string | The stroke mode to use ('zigzag', 'parallel', or 'sashiko') |
- Source
function setup() {
createCanvas(400, 400);
beginRecord(this);
setStrokeMode('zigzag');
line(10, 10, 50, 50); // Will use zigzag stitch pattern
}setStrokeSettings(settings)
Sets the stroke settings for embroidery.
| Name | Type | Description |
|---|---|---|
settings | Object | The settings for the stroke |
- Source
setStrokeSettings(settings)
Sets the stroke settings for embroidery.
| Name | Type | Description |
|---|---|---|
settings | Object | The settings for the stroke |
- Source
trimThread()
Inserts a thread trim command at the current position.
- Source
function setup() {
createCanvas(400, 400);
beginRecord();
line(10, 10, 50, 50);
trimThread(); // Cut thread at current position
line(60, 60, 100, 100);
}trimThread()
Inserts a thread trim command at the current position.
- Source
function setup() {
createCanvas(400, 400);
beginRecord(this);
line(10, 10, 50, 50);
trimThread(); // Cut thread at current position
line(60, 60, 100, 100);
}