diff --git a/src/components/PixelEditor.vue b/src/components/PixelEditor.vue index cbf6d60..f723c2d 100644 --- a/src/components/PixelEditor.vue +++ b/src/components/PixelEditor.vue @@ -73,6 +73,7 @@ import {chunk, debounce} from 'lodash'; import {saveAs} from 'file-saver'; import {isMatrixEqual} from '../utils/array'; +import {getDateInfix} from '../utils/date'; import {loadImageFromFile, openFileDialog} from '../utils/file'; import {createResizedCanvas} from '../utils/image'; @@ -84,6 +85,7 @@ export default { aspectRatio: {type: Number, default: 4.0 / 3}, fgColor: {type: String, default: 'white'}, bgColor: {type: String, default: 'black'}, + name: {type: String, default: 'image'}, }, data() { return { @@ -126,9 +128,8 @@ export default { ctx.fillRect(px.x, px.y, 1, 1); }); - canvas.toBlob(function(blob) { - const dateInfix = new Date().toISOString().replace(/\..*/, '').replace(/[T:]/g, '-'); - saveAs(blob, `image-${dateInfix}.png`); + canvas.toBlob((blob) => { + saveAs(blob, `${this.name}-${getDateInfix()}.png`); }); }, diff --git a/src/components/PlayerEditor.vue b/src/components/PlayerEditor.vue index 3936f5e..30314c2 100644 --- a/src/components/PlayerEditor.vue +++ b/src/components/PlayerEditor.vue @@ -107,6 +107,7 @@ :aspectRatio="160/192" v-model="frame.pixels" :fgColor="fgColor" + :name="name" @input="handleChildChange" /> @@ -157,7 +158,7 @@ import {playfieldToMatrix} from '../utils/pixels'; export default defineComponent({ components: {PixelEditor}, - props: ['storageFactory', 'title', 'fgColor'], + props: ['storageFactory', 'title', 'fgColor', 'name'], setup(props) { const getMaxId = (elements) => { return max(elements.map((o) => o.id))||0; diff --git a/src/utils/date.js b/src/utils/date.js new file mode 100644 index 0000000..6aad5ee --- /dev/null +++ b/src/utils/date.js @@ -0,0 +1 @@ +export const getDateInfix = () => new Date().toISOString().replace(/\..*/, '').replace(/[T:]/g, '-'); diff --git a/src/views/BackgroundEditor.vue b/src/views/BackgroundEditor.vue index 4599307..7f5b5c5 100644 --- a/src/views/BackgroundEditor.vue +++ b/src/views/BackgroundEditor.vue @@ -52,6 +52,7 @@