diff options
| author | timb <opuscule@gmail.com> | 2015-07-30 02:59:28 -0700 |
|---|---|---|
| committer | timb <opuscule@gmail.com> | 2015-07-30 02:59:28 -0700 |
| commit | 2b1ba37c195761b32f7126a874067e7549925ddd (patch) | |
| tree | ef08f0fb0dab29c7b8c575518ff8bf9b4f99388d | |
| parent | f1d7257029468ff093bfec89e783bfa37b421cc0 (diff) | |
make a note of data structure for sanity purposes if code is read years later
| -rw-r--r-- | js/png.js | 8 | ||||
| -rw-r--r-- | js/undo.js | 12 |
2 files changed, 17 insertions, 3 deletions
@@ -60,6 +60,14 @@ var crc32 = function(u8){ var signature = new Uint8Array([137, 80, 78, 71, 13, 10, 26, 10]) var te, td +// decodes chunks in png +// see http://www.w3.org/TR/PNG/#5Chunk-layout +// returns something like +// [{length: Number, +// type: String[4], +// crc: Number, +// data: Uint8Array[] // optional +// }, ...] var decode = function(buf, err){ var u8a = new Uint8Array(buf) var dv = new DataView(buf) @@ -33,6 +33,12 @@ var update_dom = function(){ update_dom_visibility('redo') } +// state is an undo or redo state that might contain these props +// {lexs: {'0,0': LexState, ...}, +// focus: {x:, y: }, +// size: {w:, h: }, +// rects: [{x:, y:, w:, h:, lexs: [LexState, ...]}, ...] +// } var new_state = function(){ var state = {lexs:{}}; save_focus(canvas.focus_x, canvas.focus_y, state) @@ -98,20 +104,20 @@ var save_resize = function(w, h, old_w, old_h, state){ state = state || current_undo save_size(old_w, old_h, state) if (old_w > w){ - // .----. + // .---XX // | XX // |___XX save_rect(w, 0, old_w - w, old_h, state) if (old_h > h){ // .----. // | | - // |XXX_| + // XXXX_| save_rect(0, h, w, old_h - h, state) } } else if (old_h > h){ // .----. // | | - // |XXXX| + // XXXXXX save_rect(0, h, old_w, old_h - h, state) } } |
