@@ -6,6 +6,10 @@ import Mousetrap = require('mousetrap');
66
77export type UintArray = number [ ] | Uint8Array | Uint16Array | Uint32Array ; //{[i:number]:number};
88
9+ const MAX_SIZE_X = 600 ;
10+ const MAX_SIZE_Y = 800 ;
11+ const MAX_SCALE = 16 ;
12+
913// TODO: separate view/controller
1014export interface EditorContext {
1115 setCurrentEditor ( div : JQuery , editing : JQuery , node : PixNode ) : void ;
@@ -921,9 +925,13 @@ export class CharmapEditor extends PixNode {
921925 chooser . width = this . fmt . w || 1 ;
922926 chooser . height = this . fmt . h || 1 ;
923927 chooser . recreate ( agrid , ( index , viewer ) => {
924- var yscale = Math . ceil ( 256 / this . fmt . w ) ; // TODO: variable scale?
925- var xscale = yscale * ( this . fmt . aspect || 1.0 ) ;
926- var editview = this . createEditor ( aeditor , viewer , xscale , yscale ) ;
928+ // TODO: variable scale?
929+ const aspect = this . fmt . aspect || 1.0 ;
930+ const yscale = Math . min ( MAX_SCALE ,
931+ MAX_SIZE_X / this . fmt . w * aspect ,
932+ MAX_SIZE_Y / this . fmt . h ) ;
933+ const xscale = yscale * aspect ;
934+ this . createEditor ( aeditor , viewer , xscale , yscale ) ;
927935 this . context . setCurrentEditor ( aeditor , $ ( viewer . canvas ) , this ) ;
928936 this . rgbimgs [ index ] = viewer . rgbdata ;
929937 } ) ;
@@ -953,9 +961,6 @@ export class CharmapEditor extends PixNode {
953961 im . updateImage ( ) ;
954962 var w = viewer . width * xscale ;
955963 var h = viewer . height * yscale ;
956- while ( w > 500 || h > 500 ) {
957- w /= 2 ; h /= 2 ;
958- }
959964 im . canvas . style . width = w + 'px' ; // TODO
960965 im . canvas . style . height = h + 'px' ; // TODO
961966 im . makeEditable ( this , aeditor , this . left . palette ) ;
0 commit comments