Methods
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();
}
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(this);
// Draw embroidery patterns
endRecord();
exportDST('pattern.dst');
}
exportEmbroidery(filename)
Exports the recorded embroidery data as a file.
Name | Type | Description |
---|---|---|
filename | String | Output filename with extension |
- Source
function setup() {
createCanvas(400, 400);
beginRecord(this);
// Draw embroidery patterns here
endRecord();
exportEmbroidery('pattern.dst');
}
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');
}
mmToPixel(mm, dpiopt) → {Number}
Converts millimeters to pixels.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
mm | Number | Millimeters | ||
dpi | Number | <optional> | 96 | Dots per inch |
- Source
Pixels
- Type:
- Number
function setup() {
let pixels = mmToPixel(10); // Convert 10mm to pixels
if(_DEBUG) console.log(pixels);
}
pixelToMm(pixels, dpiopt) → {Number}
Converts pixels to millimeters.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
pixels | Number | Pixels | ||
dpi | Number | <optional> | 96 | Dots per inch |
- Source
Millimeters
- Type:
- Number
function setup() {
let mm = pixelToMm(100); // Convert 100 pixels to mm
if(_DEBUG) console.log(mm);
}
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
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(this);
setStitch(1, 3, 0.2); // min 1mm, desired 3mm, 20% noise
// Draw embroidery patterns
}
setStrokeMode(mode)
Sets the stroke mode for embroidery stitches.
Name | Type | Description |
---|---|---|
mode | string | The stroke mode to use ('zigzag', 'lines', 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
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);
}