mirror of
https://github.com/Terncode/pixel.horse.git
synced 2026-09-25 06:05:52 +02:00
Project sanity check (#76)
* tslint: CRLF -> LF * gitignore more build artifacts * Add proposed .editorconfig * Allow for "clean" builds src/ts/generated/ content is still required (sprites.ts, gamepad-mappings.ts), but src/scripts is not. * Add --sprites option to production build * Add note about sprites to README
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
/// <reference path="../../typings/my.d.ts" />
|
||||
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import { createCanvas, Image } from 'canvas';
|
||||
import { ExtCanvas, Point } from './types';
|
||||
|
||||
@@ -167,6 +170,12 @@ export function isCanvasEmpty(canvas: ExtCanvas | undefined): boolean {
|
||||
}
|
||||
|
||||
export function saveCanvas(filePath: string, canvas: HTMLCanvasElement) {
|
||||
try {
|
||||
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
||||
} catch (e) {
|
||||
if (e.code !== 'EEXIST') throw e;
|
||||
}
|
||||
|
||||
fs.writeFileSync(filePath, canvas.toBuffer());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user