Separate render and read logic to different folders

This commit is contained in:
Leonardo Murça 2022-11-22 15:13:50 -03:00
parent 4a9bddd767
commit 36c33e4f95
5 changed files with 7 additions and 7 deletions

View file

@ -1,6 +1,6 @@
import { jDataView } from "../utils/jdataview"; import { jDataView } from "./jdataview";
import { pesRead } from "../utils/pesformat"; import { pesRead } from "../format-readers/pes";
import { Pattern } from "../utils/pattern"; import { Pattern } from "./pattern";
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;
@ -49,7 +49,7 @@ function handleFileReadError(evt) {
} }
} }
export function startFileRead(fileObject, canvas) { export default function renderFileToCanvas(fileObject, canvas) {
const reader = new FileReader(); const reader = new FileReader();
reader.onloadend = function (x) { reader.onloadend = function (x) {

View file

@ -1,4 +1,4 @@
import { Color, stitchTypes } from "./pattern"; import { Color, stitchTypes } from "../file-renderer/pattern";
const namedColors = [ const namedColors = [
new Color(0, 0, 0, "Unknown"), new Color(0, 0, 0, "Unknown"),

View file

@ -1,5 +1,5 @@
<script> <script>
import { startFileRead } from "../utils/main"; import renderFileToCanvas from "../file-renderer";
export let files = []; export let files = [];
let canvasRefs = []; let canvasRefs = [];
@ -12,7 +12,7 @@
<canvas bind:this={canvasRefs[i]} class="canvas" /> <canvas bind:this={canvasRefs[i]} class="canvas" />
<p>{file.name}</p> <p>{file.name}</p>
</div> </div>
{canvasRefs[i] && startFileRead(file, canvasRefs[i])} {canvasRefs[i] && renderFileToCanvas(file, canvasRefs[i])}
{/each} {/each}
</div> </div>
{/if} {/if}