configuring matrix dimensions

This commit is contained in:
waltem01 2024-02-16 09:15:32 +01:00
parent b11292ec85
commit 846778b969
3 changed files with 33 additions and 3 deletions

View File

@ -1,2 +1,9 @@
API_SERVER_IP=
API_SERVER_PORT=
PUBLIC_LED_WIDTH=
PUBLIC_LED_HEIGHT=
PUBLIC_LED_CHAIN=
PUBLIC_LED_PARALLEL=

View File

@ -1,3 +1,11 @@
// Interface to represent the entire matrix data
export interface Matrix {
width: number;
height: number;
scale?: number;
grid?: MatrixCell[][];
}
// Interface to represent a singualr matrix cell object
export interface MatrixCell {
x: number;

View File

@ -1,5 +1,13 @@
<script lang="ts">
import {
PUBLIC_LED_WIDTH,
PUBLIC_LED_HEIGHT,
PUBLIC_LED_CHAIN,
PUBLIC_LED_PARALLEL
} from '$env/static/public';
import type { Matrix } from '$lib/client/matrix';
import type { APIResponse } from '$lib/interfaces';
import { onMount } from 'svelte';
interface UploadData {
start: number;
@ -8,7 +16,7 @@
}
let imageURL: string | null, lastImage: File;
let uploadData: UploadData;
let uploadData: UploadData, matrix: Matrix;
async function updateMatrix() {
await fetch('/api/redirect?endpoint=update');
@ -97,12 +105,19 @@
elapsed: '0'
};
}
onMount(() => {
matrix = {
width: +PUBLIC_LED_WIDTH * +PUBLIC_LED_CHAIN,
height: +PUBLIC_LED_HEIGHT * +PUBLIC_LED_PARALLEL
};
});
</script>
<input type="file" name="image" accept="image/*" on:change={uploadImage} />
{#if imageURL}
<img src={imageURL} alt="User uploaded" />
{#await fileAsDataURL(lastImage, 192, 192)}
{#await fileAsDataURL(lastImage, matrix.width, matrix.height)}
<p>Loading image data . . .</p>
<p>{uploadData.elapsed} seconds elapsed.</p>
{:then dataUrl}