From 288970d475c638f0cae96760ca30e1b41ae8e6cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Mur=C3=A7a?= Date: Wed, 30 Nov 2022 10:36:33 -0300 Subject: [PATCH 1/2] Include support for pec file format --- src/file-renderer/index.js | 3 +++ src/format-readers/pec.js | 13 +++++++++++++ src/lib/FileViewer.svelte | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 src/format-readers/pec.js diff --git a/src/file-renderer/index.js b/src/file-renderer/index.js index 39ad778..048ab76 100644 --- a/src/file-renderer/index.js +++ b/src/file-renderer/index.js @@ -2,6 +2,7 @@ import { jDataView } from "./jdataview"; import { pesRead } from "../format-readers/pes"; import { dstRead } from "../format-readers/dst"; import { Pattern } from "./pattern"; +import { pecRead } from "../format-readers/pec"; String.prototype.endsWith = function (suffix) { return this.indexOf(suffix, this.length - suffix.length) !== -1; @@ -15,6 +16,8 @@ function displayFileText(filename, evt, canvas) { pesRead(view, pattern); } else if (filename.endsWith("dst")) { dstRead(view, pattern); + } else if (filename.endsWith("pec")) { + pecRead(view, pattern); } pattern.moveToPositive(); pattern.drawShape(canvas); diff --git a/src/format-readers/pec.js b/src/format-readers/pec.js new file mode 100644 index 0000000..402e613 --- /dev/null +++ b/src/format-readers/pec.js @@ -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; +} diff --git a/src/lib/FileViewer.svelte b/src/lib/FileViewer.svelte index 31050d4..08a1148 100644 --- a/src/lib/FileViewer.svelte +++ b/src/lib/FileViewer.svelte @@ -9,7 +9,7 @@ let rejectedFiles; let areAcceptedFilesRendered = false; const fileRequirements = { - supportedFormats: [".pes", ".dst"], + supportedFormats: [".pes", ".dst", ".pec"], maxSize: 700000, }; From 4a018ce6abec4945d62c8be3e23a671f72610fa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Mur=C3=A7a?= Date: Wed, 30 Nov 2022 10:39:19 -0300 Subject: [PATCH 2/2] Update readme --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 354d3af..92aaad1 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,10 @@ # Embroidery Viewer -A free online tool to view embroidery files. +A free online tool to view embroidery files. Available at https://embroideryviewer.xyz. ![Demo](/demo.gif) -Current supported formats: **.pes**. - +Current supported formats: **.pes, .dst and .pec**. Inspired by https://github.com/redteam316/html5-embroidery.git.