File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -99,6 +99,12 @@ namespace microcode {
9999 const str = buf . readString ( )
100100 return { num : str }
101101 }
102+ toText ( field : BoxedNumAsStr ) {
103+ return field . num
104+ }
105+ fromText ( txt : string ) {
106+ return { num : txt }
107+ }
102108 }
103109
104110 export class DigitEditor extends ModifierEditor {
@@ -176,6 +182,24 @@ namespace microcode {
176182 }
177183 return img
178184 }
185+ toText ( img : Bitmap ) {
186+ let ret = ""
187+ for ( let row = 0 ; row < 5 ; row ++ ) {
188+ for ( let col = 0 ; col < 5 ; col ++ ) {
189+ ret += img . getPixel ( col , row ) ? `1 ` : `. `
190+ }
191+ ret += `\n`
192+ }
193+ return ret
194+ }
195+ fromText ( txt : string ) : Bitmap {
196+ let ret = bitmaps . create ( 5 , 5 )
197+ let seq = txt . split ( " \n" )
198+ seq . forEach ( ( s , i ) => {
199+ ret . setPixel ( i % 5 , Math . idiv ( i , 5 ) , s == "1" ? 1 : 0 )
200+ } )
201+ return ret
202+ }
179203 }
180204
181205 export class IconEditor extends ModifierEditor {
You can’t perform that action at this time.
0 commit comments