Merge pull request #10 from leomurca/feature/support_pec_format
Feature/support pec format
This commit is contained in:
commit
2a9710b840
4 changed files with 19 additions and 4 deletions
|
@ -1,11 +1,10 @@
|
||||||
# Embroidery Viewer
|
# Embroidery Viewer
|
||||||
|
|
||||||
A free online tool to view embroidery files.
|
A free online tool to view embroidery files.
|
||||||
Available at https://embroideryviewer.xyz.
|
Available at https://embroideryviewer.xyz.
|
||||||
|
|
||||||
![Demo](/demo.gif)
|
![Demo](/demo.gif)
|
||||||
|
|
||||||
Current supported formats: **.pes**.
|
Current supported formats: **.pes, .dst and .pec**.
|
||||||
|
|
||||||
|
|
||||||
Inspired by https://github.com/redteam316/html5-embroidery.git.
|
Inspired by https://github.com/redteam316/html5-embroidery.git.
|
||||||
|
|
|
@ -2,6 +2,7 @@ import { jDataView } from "./jdataview";
|
||||||
import { pesRead } from "../format-readers/pes";
|
import { pesRead } from "../format-readers/pes";
|
||||||
import { dstRead } from "../format-readers/dst";
|
import { dstRead } from "../format-readers/dst";
|
||||||
import { Pattern } from "./pattern";
|
import { Pattern } from "./pattern";
|
||||||
|
import { pecRead } from "../format-readers/pec";
|
||||||
|
|
||||||
String.prototype.endsWith = function (suffix) {
|
String.prototype.endsWith = function (suffix) {
|
||||||
return this.indexOf(suffix, this.length - suffix.length) !== -1;
|
return this.indexOf(suffix, this.length - suffix.length) !== -1;
|
||||||
|
@ -15,6 +16,8 @@ function displayFileText(filename, evt, canvas) {
|
||||||
pesRead(view, pattern);
|
pesRead(view, pattern);
|
||||||
} else if (filename.endsWith("dst")) {
|
} else if (filename.endsWith("dst")) {
|
||||||
dstRead(view, pattern);
|
dstRead(view, pattern);
|
||||||
|
} else if (filename.endsWith("pec")) {
|
||||||
|
pecRead(view, pattern);
|
||||||
}
|
}
|
||||||
pattern.moveToPositive();
|
pattern.moveToPositive();
|
||||||
pattern.drawShape(canvas);
|
pattern.drawShape(canvas);
|
||||||
|
|
13
src/format-readers/pec.js
Normal file
13
src/format-readers/pec.js
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
import { pecColors, pecReadStitches } from "./pes";
|
||||||
|
|
||||||
|
export function pecRead(file, pattern) {
|
||||||
|
let colorChanges, i;
|
||||||
|
file.seek(0x38);
|
||||||
|
colorChanges = file.getUint8();
|
||||||
|
for (i = 0; i <= colorChanges; i++) {
|
||||||
|
pattern.addColor(pecColors[file.getUint8() % 65]);
|
||||||
|
}
|
||||||
|
file.seek(0x21c);
|
||||||
|
pecReadStitches(file, pattern);
|
||||||
|
return true;
|
||||||
|
}
|
|
@ -9,7 +9,7 @@
|
||||||
let rejectedFiles;
|
let rejectedFiles;
|
||||||
let areAcceptedFilesRendered = false;
|
let areAcceptedFilesRendered = false;
|
||||||
const fileRequirements = {
|
const fileRequirements = {
|
||||||
supportedFormats: [".pes", ".dst"],
|
supportedFormats: [".pes", ".dst", ".pec"],
|
||||||
maxSize: 700000,
|
maxSize: 700000,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue