# GTEST.GUI -- Graphics user interface for the "hello world" demo task, # as modified to test the class Gterm graphics primitives. reset-server appInitialize hello Hello { ! ! Application defaults for the hello world program. ! Hello*objects:\ toplevel Form helloForm\ helloForm Label helloLabel\ helloForm Command quitButton\ helloForm Command drawButton\ helloForm Gterm plotwin Hello*helloForm*background: bisque Hello*helloForm*helloLabel.label: Hello, world! Hello*helloForm*quitButton.fromHoriz: helloLabel Hello*helloForm*quitButton.label: Quit Hello*helloForm*drawButton.fromHoriz: quitButton Hello*helloForm*drawButton.label: Draw Hello*helloForm*plotwin.fromHoriz: drawButton } createObjects proc quit args { send client gkey q; deactivate unmap } # draw -- Graphics test procedure. proc draw args { global R1_width R1_height R1_depth R1_colors R1_pixels R1_encoding global R2_width R2_height R2_depth R2_colors R2_pixels R2_encoding global R3_width R3_height R3_depth R3_colors R3_pixels R3_encoding send plotwin queryRaster 0 wid ht type depth print "raster query: wid=" $wid " ht=" $ht " type= " $type " depth=" $depth # Test pixel i/o. send plotwin setPixel 0 10 10 1 send plotwin setPixel 0 11 11 3 send plotwin setPixel 0 12 12 4 # Test line drawing. send plotwin { setLineWidth 5 setColorIndex blue drawPolyline { {20 20} {100 100} {200 50} {300 350} {400 250} } } # Test fill polygon. send plotwin { setFillType solid setColorIndex green drawPolygon { {105 115} {174 115} {174 183} {105 183} } } # Test text drawing and area fills, show static colors. send plotwin drawAlphaText 400 100 "Gterm Graphics Test" for {set i 0} {$i < 10} {incr i 1} { send plotwin setPixels 0 $i pixel [expr 370+($i*20)] 105 20 20 } # Test basic image raster drawing. Image R1 has its own colormap, while # R2 uses the static colors. set bias [send plotwin getBias] send plotwin "\ writeColormap 0 \{ $R1_colors \} $bias; \ writePixels 0 \{ $R1_pixels \} $R1_encoding $R1_depth \ 109 118 $R1_width $R1_height $bias; \ writePixels 0 \{ $R2_pixels \} $R2_encoding $R2_depth \ 560 400 $R2_width $R2_height" # Set up for test below; also test extending colormap. set x 20 set bias [expr $bias + [llength $R1_colors]] send plotwin "\ writeColormap 0 \{ $R3_colors \} $bias; \ writePixels 0 \{ $R3_pixels \} $R3_encoding $R3_depth \ $x 400 $R3_width $R3_height $bias" # Test various image encodings. foreach encoding {numeric hex1 hex2 hex1-rle hex2-rle} { set pixels [send plotwin \ readPixels 0 $encoding $R3_depth 20 400 $R3_width $R3_height $bias] send plotwin \ writePixels 0 $pixels $encoding $R3_depth \ $x 400 $R3_width $R3_height $bias incr x 64 } } send quitButton addCallback quit send drawButton addCallback draw activate # Raster "porsche". set R1_width 64; set R1_height 64; set R1_depth 8 set R1_colors { {255 255 255} { 0 0 0} {106 90 205} {255 0 0} {255 255 0} } set R1_encoding "hex1-rle" set R1_pixels { 2%861@k2@E1@k2@E114@g112@E11441@2441@2441@2441@2441@2441441441@244112@E11 4414414414414414414414414414414414414414@3112@E114414414414414414414414@3 14@314414414@3112@E11441@2441441441114441@24414@31@2441@244112@E114414@31 4414414414@314414@314414414@3112@E114414@31441441441441441441441441441441 4@3112@E114414@31@2441441441@2441@2441441441@244112@E114@g112@E1@k2@E114@ J1@N2@E114@414441444114@31@N2@E114@31444144414@21441@N2@E114@211441141@54 441@N2@E114441@64@41144113@J112@E11441@24@D113@J112@E1141114@F113@J112@E1 14@814414@5113@J112@E114@3144414414@6113@J112@E114@214441441441@U2@E114@2 141@74@C1@F2@E114441@24@51@U2@E11441114@714@C1@F2@E1141114@814441114@61@F 2@E114@7144141441@34@51@F2@E114@3144144144144141114@31413@C112@E114@21441 44144114@21114@211413@C112@E114441141@5414@21114@211413@C112@E11441@34@41 14441@344414413@C112@E1141114@8141@94413@C112@E114@C14141@74413@C112@E1@F 41414@21@2441@F2@E1@F44414@31414414@C112@E1@F4@6114114144414414@5112@F1@E 4@614414414414414441444112@G1@E4@5144144414144144414@2112@G1@F4@A141@8444 112@H113@C14@81@24@6114112@I113@D14@61@24@A112@J113@D1@64@514414@2112@K11 3@G114@31444144144144112@L113@F114@21444144144144112@M113@F114441141@6444 112@N1@I4441@24@4114112@P1@H441114@912@Q1@H41114@9112@R1@G4@C112@T1@F4441 41414@3112@V1@E441414144144112@X113@911441@544112@Z113@81141114@214112@b1 13@7114114@4112@d1113@5114@51112@f1@23@3114@31@22@i1@2333114441@22@m1@231 141@22@q1@62@u1@22@x112%5D } # Raster "nobozos". set R2_width 64; set R2_height 64; set R2_depth 8 set R2_colors { } set R2_encoding "hex1-rle" set R2_pixels { 1%590@91@l0@H1@e0@N1@Z0@R1@V0@V1@S0@X1@P0@b1@M0@d1@K0@F1@70@F1@I0@C1@F0@C 1@G0@B1@J0@B1@E0@A1@N0@A1@C0@C1@N0@A1@B0@D1@O0@81@A0@F1@O0@81@80@81110@41 @P0@71@70@41@30110@41@M0101110@31@60@510111001@30001@K00111010@41@50@3111 0@2101010110001@F0101010@21110@21@40@311001010@2110010@21@D00110@21010011 0@21@30@3101010010100010110@21@C0100010100101010@21@300011100110010010@31 10@21@A0@31001001100111001@20@210010001010@3110011001@A00110@310100010010 001110@2110100010001010001001@20@31@4010001010001000101100011100011100010 @610@41001@3001010@310@610001110011100010010@510@31010001@700101010@310@5 100100110@21101010001000100010@21@90@310001000100010101100010@31110010@21 00010@31@B010@2100010@21001110@210@310010@510@3101@D0010@310@510010@210@3 1101010001000101001110@21110@211100010100010001010110@210@411100010@61011 0011001001100110010@610001110@310@410010@31010@31101@20101@20110@41010@31 0010@310@4110101110@210001110100101010010111001010@2111010110@310@51@3001 01010001110100100010010111001010101001@30@410@61@30101@3011101110@3111011 101@40101@20@610@61@B01110@B11101@B0@610@61@B01@40@51@40101@80@7110@61@A0 1@40@51@401001@70@61110@61@A01@50@31@5010001@60@61110@61@A011100111000111 00111010@21@50@61110@71@A010@21@50@210110@31@30@71@20@61@A01001001@300100 1010@51@20@61@30@71@901100110@3110011010@6110@71@30@71@A011001@500110110@ 710@71@40@71@A0110@7110110@H1@50@81@9001@90010@I1@60@71@A001@700110@H1@70 @81@B001@3001110@I1@80@81@C0@31@50@F1@A0@81@O0@D1@B0@A1@N0@C1@C0@A1@N0@A1 @E0@B1@J0@B1@G0@C1@F0@C1@I0@F1@70@F1@K0@d1@M0@b1@P0@X1@S0@V1@V0@R1@Z0@N1@ e0@H1@l0@91@O } # Raster "city". set R3_width 64; set R3_height 64; set R3_depth 8 set R3_colors { { 0 191 255} { 178 34 34} {224 224 0} } set R3_encoding "hex1-rle" set R3_pixels { 0%FF%FF%FF%E610@z10@z10@P1@30@S1110@O121110@S1110@O111210@R1@30@N1@30@R1@ 30@N121110@P1@80@K111210@P10010010010@K1@30@P10010010010@D110@3112110@P1@ 80@D110@31@30@P1001@20010@D110@3121110@P1001@20010@D110@31@30@91@20@A1@80 1@9000110@3111210@910010@21@30001@2001@2010121010011000110@31@30@91@20@21 21010001@2001@201@9000110@31@30@910010@2121010001@8010112110001000110@310 0010@91@20@21@30001001@501@9000110@31@30@910010@2121110001001@50100121001 21001@20@2111210@91@20@2121110001@200100101@90010010@21@30@91@20@21112100 01@2001001010121010001001@20@2112110@91@20@2111210001@801@90010010@21@80@ 410010@21@30001@8011001211001001@20@21@3001110@41@20@21@30001@801@9001@20 @21@50010@41@20@2111210001@8011001210001001@20@2121@60@410010@21112100010 01@200101@90010010@21@3001110@21@50001@30001001@2001010100100011001@20@21 121@50@210@3100011121@C01@90012110@21@50010@21@500011121@6001001010121100 121001@20@21112100111001@70001@421@300100101@90011210@21@80010@5100012101 21@A010121121011001@4001112111001001@700012101@3001@501@C00111001@3001110 01@70001@4211001@821110012101@40001@5001001@F21@M211001110011121@40010@51 @321@8001@4001@2001121@500121@H211121@8001@H00101001@5001@20@51@521@E2101 121001@7001@3001@221@D21121@6001@C2101@5001@I21@321@7001@2211100121121@42 1@4001@I21@P2101@521@3001@20@5121@321121@600111211001@421@201121@821@8211 1211121@7001@821@3001@42111001@40@51@321@G0001@521@521@6001@J211001@H2110 0101@3001@521@20@211121@32111001@721@3001121@621@J21@U211001%BF }