**TI92P*ieditorRieditor&Z&6() Prgm: 2.2 10/20/98 Local i,1,b2,b3,b4,b5,b6,b7,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,i1,i2,i3,i4,m1,m2,p1,p2,p3,p4,p5,p6,p7,p8,p9,pa,wait Define wait(x)=Prgm:If x=1:Goto clr:PxlText "Please",10,10:PxlText "Wait",19,10:Goto end:Lbl clr:PxlText " ",10,10:PxlText " ",19,10:Lbl end:EndPrgm Try:Unarchiv mall,pfold:Else:ClrErr:EndTry:getMode("ALL")mall:getFold()pfold:Archive mall,pfold:Goto def Lbl top:0b5:1b6:CopyVar i2,i3:If s7"show":newMat(16,16)m2:ClrDraw:ClrGraph:For i,10,90,5:PxlLine i,80,i,160:EndFor:For i,80,160,5:PxlLine 10,i,90,i:EndFor:PxlLine 41,30,41,47:PxlLine 41,47,58,47:PxlLine 58,47,58,30:PxlLine 58,30,41,30:PxlText "IMAGE EDITOR",2,84:PxlText "h:"&string(p6)&" w:"&string(p5)&" ",82,165:PxlOn {36,36,36,36,36,36,36},{32,35,36,39,40,43,46}:PxlOn {37,37,37,37,37,37,37},{32,34,38,41,43,44,46}:PxlOn {38,38,38,38,38,38,38},{32,34,38,41,43,45,46}:PxlOn {39,39,39,39,39,39,39},{32,35,36,39,40,43,46}:If getType(logo)="PIC":RclPic logo,60,0:If s7="show":Goto show:If s7="new":Goto new:If s7"" Then:0b6:Goto rqst:EndIf:Goto tb Lbl edit:PxlText "Use ENTER ",10,165:PxlText " to toggle ",19,165:PxlText " pixels. ",28,165:PxlText "Press ENTER",37,165:PxlText " off grid to",46,165:PxlText " return to ",55,165:PxlText " menu. ",64,165 Loop:Input :If xc<0 or xc16 or yc>0 or yc16 Then:wait(0):If m2=0*m2:0b5:wait(1):Goto tb:EndIf:1b5:floor(xc)p2:floor(abs(yc))p1:If m2[p1+1,p2+1]=0 Then:1m2[p1+1,p2+1]:Else:0m2[p1+1,p2+1]:EndIf:XorPic i1,5*p1+10,5*p2+80:PxlChg p1+42,p2+31:EndLoop Lbl invrt:wait(0):1b5:For p1,0,15:For p2,0,15:If m2[p1+1,p2+1]=0 Then:1m2[p1+1,p2+1]:Else:0m2[p1+1,p2+1]:EndIf:XorPic i1,5*p1+10,5*p2+80:PxlChg p1+42,p2+31:EndFor:EndFor:Goto tb Lbl tb:0b2:""s7:If b4=1:Goto tbloop:PxlText "F1- File ",10,165:PxlText "F2- Edit ",19,165:PxlText "F3- Test ",28,165:PxlText "F4- Quit ",37,165:PxlText "F5- Help ",46,165:PxlText " ",55,165:PxlText " ",64,165 Lbl tbloop:wait(1):If b4=0:Goto tbi:Toolbar:Title "File":Item "Open Picture",opnpic:Item "Open Matrix",open1:Item "Save Picture",save1:Item "Save Matrix",savem:Title "Edit":Item "Edit",edit:Item "Paste",mpic:Item "Dimensions",chgres:Item "Flip Vertical",rswp:Item "Flip Horizontal",cswp:Item "Flip Diagonal",tpos:Item "Negative Image",invrt:Item "Clear Grid",vrfy:Item "Preferences",prefs:Title i3,tb1:Title "Exit",end:Title "Help":Item "Picture",helppic:Item "Matrix",helpmat:Item "Editing",helppe:Item "Preferences",helpprf:Item "Test",helptest:Item "About",about:EndTBar:Goto tbloop Lbl tbi:Toolbar:Title file_i:Item "Open Picture",opnpic:Item "Open Matrix",open1:Item "Save Picture",save1:Item "Save Matrix",savem:Title edit_i:Item "Edit",edit:Item "Paste",mpic:Item "Dimensions",chgres:Item "Flip Vertical",rswp:Item "Flip Horizontal",cswp:Item "Flip Diagonal",tpos:Item "Negative Image",invrt:Item "Clear Grid",vrfy:Item "Preferences",prefs:Title i3,tb1:Title door_i,end:Title help_i:Item "Picture",helppic:Item "Matrix",helpmat:Item "Editing",helppe:Item "Preferences",helpprf:Item "Test",helptest:Item "About",about:EndTBar:Goto tbloop:Lbl tb1:wait(0):Try:NewPic m1,i3,p6-1,p5-1:Else:ClrErr:EndTry:Goto tb Lbl savem:1b2:Lbl save1:"SAVE"s7:Goto rqst:Lbl save:newMat(1,2)m1:For p1,1,p6+0:For p2,1,p5+0:If m2[p1,p2]=1:augment(m1;[[p1-1,p2-1]])m1:EndFor:EndFor:subMat(m1,2,1)m1:If b2=1 Then:m1#s3:Else:NewPic m1,#s3,p6-1,p5-1:EndIf:If 1=2:Archive #s3:0b5:""s7:Goto tb Lbl open1:"OPEN"s7:Goto rqst:Lbl open:#s3m1:newMat(16,16)m2:For i,1,rowDim(m1):m1[i,1]p1:m1[i,2]p2:1m2[p1+1,p2+1]:XorPic i1,5*p1+10,5*p2+80:PxlChg p1+42,p2+31:EndFor:""s7:Goto tb Lbl opnpic:"OPENpic"s7:Goto rqst Lbl openpic:0ymax:102ymin:238xmax:0xmin:1p8:1p4:ClrDraw:RclPic #s3 Loop:Input xcp3:abs(yc)p7 If p7+p6>102 Then:p7+p6-102p9:Else:1p9:EndIf If p3+p5>238 Then:p3+p5-238pa:Else:1pa:EndIf If p80 and p40 Then PxlLine p8,p4,p8+p6-p9,p4,1:PxlLine p8,p4,p8,p4+p5-pa,1:PxlLine p8,p4+p5-pa,p8+p6-p9,p4+p5-pa,1:PxlLine p8+p6-p9,p4,p8+p6-p9,p4+p5-pa,1 EndIf If p7=p8 and p3=p4:Exit PxlLine p7,p3,p7+p6-p9,p3,1:PxlLine p7,p3,p7,p3+p5-pa,1:PxlLine p7,p3+p5-pa,p7+p6-p9,p3+p5-pa,1:PxlLine p7+p6-p9,p3,p7+p6-p9,p3+p5-pa,1:p7p8:p3p4 EndLoop newMat(16,16)m2 For p1,p7,p7+p6-p9:For p2,p3,p3+p5-pa:Text string(expr("p1-p7+1"))&":"&string(expr("p2-p3+1")) If pxlTest(p1,p2):1m2[p1-p7+1,p2-p3+1] EndFor:EndFor:2ymax:18.4ymin:31.6xmax:16xmin:"show"s7:Goto top Lbl show:wait(0):""s7:For p1,0,15:For p2,0,15:If m2[p1+1,p2+1]=1 Then:XorPic i1,5*p1+10,5*p2+80:PxlChg p1+42,p2+31:EndIf:EndFor:EndFor:1b5:Goto tb Lbl mpic:If getType(#s3)="PIC" and s3"i1" and b7=1 Then:"mpic1"s7:Try:Unarchiv #s3:Else:ClrErr:EndTry:0ymax:102ymin:238xmax:0xmin:1p8:1p4:ClrDraw:RclPic #s3:newMat(1,2)m1:For p1,1,p6+0:For p2,1,p5+0:If m2[p1,p2]=1:augment(m1;[[p1-1,p2-1]])m1:EndFor:EndFor:If m1=0*m1 Then:0m1:Else:subMat(m1,2,1)m1:NewPic m1,#s3,p6-1,p5-1:EndIf:Else:Text "You must first open a picture":Goto tb:EndIf:Lbl mpic1:StoPic i4,p7,p3,p5,p6:XorPic i4,p7,p3:If m10 Then:NewPic m1,i4,p6-1,p5-1:RclPic i4,p7,p3:EndIf:StoPic #s3:Lbl mptb:""s7:If b4=0:Goto mptbi:Toolbar:Title "File":Item "Archive Pic",mpica:Item "New Pic",top:Title "Edit":Item "Copy & edit",openpic:Title test_i,mptb:Title "Quit",mpice:Title "Help":Item "Picture",mpich:EndTBar:Goto mptb:Lbl mptbi:Toolbar:Title file_i:Item "Archive Pic",mpica:Item "New Pic",top:Title edit_i:Item "Copy & edit",openpic:Title i3,mptb:Title door_i,mpice:Title help_i:Item "Picture",mpich:EndTBar:Goto mptb Lbl mpich:"mpic"s7:Goto helppe:Lbl mpice:0b5:Goto end:Lbl mpica:Archive #s3:Text "File Archived: "&s3:Goto mptb Lbl vrfy:Dialog:Title "VERIFICATION":Text "OK to clear grid?":EndDlog:If ok=0 Then:1b6:Goto tbloop:EndIf:Goto top Lbl tpos:wait(0):m2m2:"show"s7:Goto top Lbl rswp:wait(0):For i,1,8:rowSwap(m2,17-i,i)m2:EndFor:"show"s7:Goto top Lbl cswp:wait(0):m2m2:For i,1,8:rowSwap(m2,17-i,i)m2:EndFor:m2m2:"show"s7:Goto top Lbl rqst:If b6=1 and b5=1 and s7"SAVE":Goto vrfy:1b6:If s2="" Then:If s7="OPEN" Then:"File must be an nx2 matrix (MAT)"s2:"s10"s5:ElseIf s7="OPENpic" Then:"File must be a picture (PIC)"s2:"s11"s5:1b7:ElseIf s7="SAVE" Then:"s11"s5:If b2=1:"s10"s5:EndIf:left(s7,4)s1:EndIf:Dialog:Title s1&" FILE":Text s2:Request "Folder",#s5:Request "Name",s6:EndDlog:""s2:If ok=0:Goto tb:wait(0):If dim(s6)>8 or dim(#s5)>8 or dim(s6)=0 Then:" Invalid name!"s2:0b6:Goto rqst:EndIf:#s5&"\"&s6s3:If left(s7,4)="OPEN" and getType(#s3)="NONE" Then:" No such file!"s2:0b6:Goto rqst:EndIf:If s7="SAVE" Then:Dialog:DropDown "Archive file?",{"No","Yes"},1:EndDlog:Try:If getType(#s3)"NONE" Then:Dialog:Title "ERROR!":DropDown "File exists! Overwrite?",{"No","Yes"},b3:EndDlog:If ok=0:Goto tb:0b7:If b3=1:Goto rqst:EndIf:Else:ClrErr:"Unable to write to: "&s3s2:Goto rqst:EndTry:Try:Unarchiv #s3:Else:ClrErr:EndTry:ElseIf getType(#s3)="PIC" Then:Goto #s7:ElseIf getType(#s3)"MAT" or colDim(#s3)2 Then:Dialog:Title "ERROR!":Text "This is not an nx2 matrix!":EndDlog:If ok=0:Goto tb:0b6:Goto rqst:EndIf:Goto #s7 Lbl about:Dialog:Title "IMAGE EDITOR 2.2":Text " Copyright 1998 Frank P. Westlake":Text " westlake@mail.per.to":Text "This program is freely distributable.":Text "":Text " Updates available at":Text " http://www.per.to/westlake":EndDlog:Goto tb Lbl helppic:1i:Goto help:Lbl helpmat:2i:Goto help:Lbl helptest:3i:Goto help:Lbl helped:4i:Goto help:Lbl helpprf:5i:Goto help:Lbl helppe:6i:Goto help:Lbl help:setFold(#s8)pfold:If getType(help)="PRGM" Then:help(s9&"\ieditorh",i):Else:Text "Can't find help() program":EndIf:setFold(#pfold):If s7="mpic":Goto mptb:Goto tb Lbl chgres:p6l:p5m:Dialog:Title "PICTURE DIMENSIONS":DropDown "Picture height",seq(string(j),j,1,16),l:DropDown "Picture width",seq(string(k),k,1,16),m:EndDlog:lp6:mp5:PxlText "h:"&string(p6)&" w:"&string(p5)&" ",82,165:DelVar j,k,l,m:Goto tb Lbl prefs:Dialog:Title "PREFERENCES":Text "Program Information:":Request "Toolbar icons",s12:Request "Help program folder",s8:Request "Help database folder",s9:Text "":Text "User Information:":Request "Matrix files",s10:Request "Image files",s11:EndDlog:If ok=0:Goto tb:If s4="":"ieditori"s4:If getType(#s4)="NONE":newList(5)#s4:If getType(#s4)="LIST" Then:Unarchiv #s4:s12#s4[1]:s8#s4[2]:s9#s4[3]:s10#s4[4]:s11#s4[5]:Archive #s4:Else:Text "Can't open preferences.":EndIf:Goto tb Lbl def:NewPic [[0,0][0,1][0,2][0,3][0,4][1,0][1,1][1,2][1,3][1,4][2,0][2,1][2,2][2,3][2,4][3,0][3,1][3,2][3,3][3,4][4,0][4,1][4,2][4,3][4,4]],i1,5,5:NewPic [[10,0][10,1][10,2][10,4][10,5][10,6][10,9][10,10][10,11][10,13][10,14][10,15][11,1][11,4][11,8][11,14][12,1][12,4][12,5][12,9][12,10][12,14][13,1][13,4][13,11][13,14][14,1][14,4][14,5][14,6][14,8][14,9][14,10][14,14]],i2,15,15:2ymax:18.4ymin:31.6xmax:16xmin:1xscl:1yscl:1xres:16p6:16p5:21:""s2:"i1"s3:""s7:0b5:0b7:pfolds5:""s4:FnOff :setGraph("Coordinates","Rect"):setGraph("Axes","Off"):setGraph("Labels","Off"):setGraph("Grid","Off"):setMode("Split Screen","FULL"):1b4:If getType(ieditori)="LIST" Then:"ieditori"s4:ElseIf getType(main\ieditori)="LIST" Then:"main\ieditori"s4:ElseIf getType(#(pfold&"\ieditori"))="LIST" Then:pfold&"ieditori"s4:EndIf:If s4"" Then:#s4[2]s8:#s4[3]s9:#s4[4]s10:#s4[5]s11:#s4[1]s12:Try:setFold(#s12):Else:ClrErr:EndTry:Else:pfolds8:pfolds9:pfolds10:pfolds11:EndIf:If getType(file_i)="PIC" and getType(edit_i)="PIC" and getType(help_i)="PIC" and getType(door_i)="PIC":0b4:Goto top Lbl end:" "s2:If b5=1:"File not saved, quit anyway?"s2:Dialog:Title "QUIT?":Text s2:EndDlog:If ok=0 Then:""s2:If b5=0:Goto mptb:Goto tb:EndIf:setMode(mall):setFold(#pfold):Unarchiv mall,pfold:DelVar mall,pfold:FnOn :ClrGraph:ClrDraw EndPrgmK