Temp commit

This commit is contained in:
Nathan Kunicki 2018-01-22 20:23:10 +00:00
parent bda89911fc
commit 64a1c07134
9 changed files with 98 additions and 11 deletions

View File

@ -4,10 +4,7 @@
<title>BittMapp</title>
<link rel="stylesheet" href="./static/css/reset.css" />
<link rel="stylesheet" href="./static/css/styles.css" />
<script src="./static/js/serialisers.js"></script>
<script src="./static/js/bmptools.js"></script>
<script src="./static/js/editor.js"></script>
<script src="./static/js/main.js"></script>
<script src="./static/js/dist.js"></script>
</head>
<body>
<header>

View File

@ -3,7 +3,7 @@
"version": "0.0.1",
"description": "BittMapp - A monochrome bitmap editor",
"scripts": {
"build": "tslint -c tslint.json \"src/**/*.ts\" && tsc"
"build": "rm static/js/*.js && tslint -c tslint.json \"src/**/*.ts\" && tsc && cat static/js/*.js > static/js/dist.js"
},
"author": "Nathan Kunicki <me@nathankunicki.com>",
"license": "MIT",

12
src/actionlist.ts Normal file
View File

@ -0,0 +1,12 @@
class ActionList extends LinkedList {
private _current: ActionNode;
public push (node: LinkedNode): void {
// super(node);
}
}

15
src/actionnode.ts Normal file
View File

@ -0,0 +1,15 @@
class ActionNode extends LinkedNode {
public undo: () => void;
public redo: () => void;
constructor (undo: () => void, redo: () => void) {
super();
this.undo = undo;
this.redo = redo;
}
}

View File

@ -15,11 +15,9 @@ interface IBMPHeaderData {
interface IBittMappData {
data: Uint8Array;
width: number;
height: number;
}

View File

@ -1,4 +1,4 @@
interface IBittMappEditorConstructorOptions {
interface IEditorConstructorOptions {
canvas: HTMLCanvasElement;
canvasWidth: number;
canvasHeight: number;
@ -20,7 +20,7 @@ enum Mode {
}
class BittMappEditor {
class Editor {
public canvasWidth: number;
@ -55,7 +55,7 @@ class BittMappEditor {
private _selection: Uint8Array;
constructor (options: IBittMappEditorConstructorOptions) {
constructor (options: IEditorConstructorOptions) {
options = options || {};

31
src/linkedlist.ts Normal file
View File

@ -0,0 +1,31 @@
class LinkedList {
private _start: LinkedNode;
private _end: LinkedNode;
public push (node: LinkedNode): void {
if (!this._start) {
this._start = node;
this._end = node;
return;
}
this._end.next = node;
this._end = node;
}
public pop (): LinkedNode | null {
if (!this._end) {
return null;
}
const node: LinkedNode = this._end;
this._end = this._end.prev;
return node;
}
}

34
src/linkednode.ts Normal file
View File

@ -0,0 +1,34 @@
class LinkedNode {
private _prev: LinkedNode;
private _next: LinkedNode;
get next (): LinkedNode {
return this._next;
}
set next (node: LinkedNode) {
this._next = node;
if (node.prev !== this) {
node.prev = this;
}
}
get prev (): LinkedNode {
return this._prev;
}
set prev (node: LinkedNode) {
this._prev = node;
if (node.next !== this) {
node.next = this;
}
}
}

View File

@ -1,6 +1,6 @@
window.onload = (): void => {
const editor: BittMappEditor = new BittMappEditor({
const editor: Editor = new Editor({
canvas: document.getElementById("editor") as HTMLCanvasElement,
canvasHeight: 480,
canvasWidth: 480,