Home » Archimedes archive » Acorn User » AU 1997-10 A.adf » Extras » Apple][e/PD/BOB/ARMBOB/!ArmBob/progs/main/drawex
Apple][e/PD/BOB/ARMBOB/!ArmBob/progs/main/drawex
This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.
Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.
Tape/disk: | Home » Archimedes archive » Acorn User » AU 1997-10 A.adf » Extras |
Filename: | Apple][e/PD/BOB/ARMBOB/!ArmBob/progs/main/drawex |
Read OK: | ✔ |
File size: | 0854 bytes |
Load address: | 0000 |
Exec address: | 0000 |
File contents
/**************************************************** * * * Example program using the draw library * * * * GCW 29/12/94 * * * ****************************************************/ main() { ox = oy = 180; // Centre for B's display A = new drawfile(); // Creates a new drawfile object called A B = new drawfile(); // and another called B A->begin(); // Creates A's header banner = A->text("Draw Library Example",50,200); // create text mygroup = A->group(); // Create a group called mygroup mypath = A->path(); // containing a path called mypath A->ellipse(100,100,50,40); // given by an ellipse A->endpath(mypath); // end of mypath mytxt = A->text("Ellipse",70,40); // mygroup also contains mytxt A->endgroup(mygroup); // end of mygroup /* ellipse and mytxt now grouped together */ B->begin(); // now define B figure = B->path(); // containing a path called figure for (i = -5; i < 6; i++) if (i != 0) { B->circle(ox + (a = 100/i),oy, (a<0)?(-a):a ); B->circle(ox, oy + (a = 100/i),(a<0)?(-a):a ); } B->endpath(figure); // end of figure /* modify attributes of objects in A */ colour(banner,red); font(banner,Trinity_Medium); A->font_x(banner,20); A->font_y(banner,20); fill(mypath,azure); outline(mypath,none); colour(mytxt,green); font(mytxt,Homerton_Bold_Oblique); A->font_x(mytxt,16); A->font_y(mytxt,16); /* modify attributes of objects in B */ fill(figure,blue); outline(figure, orange); winding_rule(figure,Even_Odd); /* save and display */ B->end("RAM:B"); // save B to RAM:B and display it A->end("RAM:A"); // save A to RAM:A and display it }
00000000 2f 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a |/***************| 00000010 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a |****************| * 00000030 2a 2a 2a 2a 2a 0a 20 2a 20 20 20 20 20 20 20 20 |*****. * | 00000040 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00000060 20 20 20 20 20 20 20 20 20 20 2a 0a 20 2a 20 20 | *. * | 00000070 20 20 20 45 78 61 6d 70 6c 65 20 70 72 6f 67 72 | Example progr| 00000080 61 6d 20 75 73 69 6e 67 20 74 68 65 20 64 72 61 |am using the dra| 00000090 77 20 6c 69 62 72 61 72 79 20 20 20 20 20 20 20 |w library | 000000a0 2a 0a 20 2a 20 20 20 20 20 20 20 20 20 20 20 20 |*. * | 000000b0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 000000d0 20 20 20 20 20 20 2a 0a 20 2a 20 20 20 20 20 47 | *. * G| 000000e0 43 57 20 20 20 32 39 2f 31 32 2f 39 34 20 20 20 |CW 29/12/94 | 000000f0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000100 20 20 20 20 20 20 20 20 20 20 20 20 2a 0a 20 2a | *. *| 00000110 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00000140 20 20 2a 0a 20 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a | *. ***********| 00000150 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a |****************| * 00000170 2a 2a 2a 2a 2a 2a 2a 2a 2a 2f 0a 0a 6d 61 69 6e |*********/..main| 00000180 28 29 0a 7b 0a 20 6f 78 20 3d 20 6f 79 20 3d 20 |().{. ox = oy = | 00000190 31 38 30 3b 20 20 20 20 20 20 20 20 20 20 20 20 |180; | 000001a0 2f 2f 20 43 65 6e 74 72 65 20 66 6f 72 20 42 27 |// Centre for B'| 000001b0 73 20 64 69 73 70 6c 61 79 0a 20 41 20 3d 20 6e |s display. A = n| 000001c0 65 77 20 64 72 61 77 66 69 6c 65 28 29 3b 20 20 |ew drawfile(); | 000001d0 20 20 20 20 20 2f 2f 20 43 72 65 61 74 65 73 20 | // Creates | 000001e0 61 20 6e 65 77 20 64 72 61 77 66 69 6c 65 20 6f |a new drawfile o| 000001f0 62 6a 65 63 74 20 63 61 6c 6c 65 64 20 41 0a 20 |bject called A. | 00000200 42 20 3d 20 6e 65 77 20 64 72 61 77 66 69 6c 65 |B = new drawfile| 00000210 28 29 3b 20 20 20 20 20 20 20 2f 2f 20 61 6e 64 |(); // and| 00000220 20 61 6e 6f 74 68 65 72 20 63 61 6c 6c 65 64 20 | another called | 00000230 42 0a 20 41 2d 3e 62 65 67 69 6e 28 29 3b 20 20 |B. A->begin(); | 00000240 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 43 | // C| 00000250 72 65 61 74 65 73 20 41 27 73 20 68 65 61 64 65 |reates A's heade| 00000260 72 0a 20 20 62 61 6e 6e 65 72 20 3d 20 41 2d 3e |r. banner = A->| 00000270 74 65 78 74 28 22 44 72 61 77 20 4c 69 62 72 61 |text("Draw Libra| 00000280 72 79 20 45 78 61 6d 70 6c 65 22 2c 35 30 2c 32 |ry Example",50,2| 00000290 30 30 29 3b 20 20 20 2f 2f 20 63 72 65 61 74 65 |00); // create| 000002a0 20 74 65 78 74 20 0a 20 20 6d 79 67 72 6f 75 70 | text . mygroup| 000002b0 20 3d 20 41 2d 3e 67 72 6f 75 70 28 29 3b 20 20 | = A->group(); | 000002c0 20 20 20 20 20 20 20 20 2f 2f 20 43 72 65 61 74 | // Creat| 000002d0 65 20 61 20 67 72 6f 75 70 20 63 61 6c 6c 65 64 |e a group called| 000002e0 20 6d 79 67 72 6f 75 70 0a 20 20 20 20 6d 79 70 | mygroup. myp| 000002f0 61 74 68 20 3d 20 41 2d 3e 70 61 74 68 28 29 3b |ath = A->path();| 00000300 20 20 20 20 20 20 20 20 20 2f 2f 20 63 6f 6e 74 | // cont| 00000310 61 69 6e 69 6e 67 20 61 20 70 61 74 68 20 63 61 |aining a path ca| 00000320 6c 6c 65 64 20 6d 79 70 61 74 68 0a 20 20 20 20 |lled mypath. | 00000330 20 20 41 2d 3e 65 6c 6c 69 70 73 65 28 31 30 30 | A->ellipse(100| 00000340 2c 31 30 30 2c 35 30 2c 34 30 29 3b 20 20 20 20 |,100,50,40); | 00000350 20 20 20 2f 2f 20 67 69 76 65 6e 20 62 79 20 61 | // given by a| 00000360 6e 20 65 6c 6c 69 70 73 65 0a 20 20 20 20 41 2d |n ellipse. A-| 00000370 3e 65 6e 64 70 61 74 68 28 6d 79 70 61 74 68 29 |>endpath(mypath)| 00000380 3b 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |; | 00000390 20 2f 2f 20 65 6e 64 20 6f 66 20 6d 79 70 61 74 | // end of mypat| 000003a0 68 0a 20 20 20 20 6d 79 74 78 74 20 3d 20 41 2d |h. mytxt = A-| 000003b0 3e 74 65 78 74 28 22 45 6c 6c 69 70 73 65 22 2c |>text("Ellipse",| 000003c0 37 30 2c 34 30 29 3b 20 20 2f 2f 20 6d 79 67 72 |70,40); // mygr| 000003d0 6f 75 70 20 61 6c 73 6f 20 63 6f 6e 74 61 69 6e |oup also contain| 000003e0 73 20 6d 79 74 78 74 0a 20 20 20 41 2d 3e 65 6e |s mytxt. A->en| 000003f0 64 67 72 6f 75 70 28 6d 79 67 72 6f 75 70 29 3b |dgroup(mygroup);| 00000400 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f | /| 00000410 2f 20 65 6e 64 20 6f 66 20 6d 79 67 72 6f 75 70 |/ end of mygroup| 00000420 0a 20 20 20 2f 2a 20 65 6c 6c 69 70 73 65 20 61 |. /* ellipse a| 00000430 6e 64 20 6d 79 74 78 74 20 6e 6f 77 20 67 72 6f |nd mytxt now gro| 00000440 75 70 65 64 20 74 6f 67 65 74 68 65 72 20 2a 2f |uped together */| 00000450 0a 0a 20 42 2d 3e 62 65 67 69 6e 28 29 3b 20 20 |.. B->begin(); | 00000460 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000470 20 20 20 20 20 20 20 20 20 2f 2f 20 6e 6f 77 20 | // now | 00000480 64 65 66 69 6e 65 20 42 0a 20 20 66 69 67 75 72 |define B. figur| 00000490 65 20 3d 20 42 2d 3e 70 61 74 68 28 29 3b 20 20 |e = B->path(); | 000004a0 20 20 20 20 20 20 20 20 20 2f 2f 20 63 6f 6e 74 | // cont| 000004b0 61 69 6e 69 6e 67 20 61 20 70 61 74 68 20 63 61 |aining a path ca| 000004c0 6c 6c 65 64 20 66 69 67 75 72 65 0a 20 20 20 66 |lled figure. f| 000004d0 6f 72 20 28 69 20 3d 20 2d 35 3b 20 69 20 3c 20 |or (i = -5; i < | 000004e0 36 3b 20 69 2b 2b 29 0a 20 20 20 20 69 66 20 28 |6; i++). if (| 000004f0 69 20 21 3d 20 30 29 0a 20 20 20 20 20 7b 0a 20 |i != 0). {. | 00000500 20 20 20 20 20 42 2d 3e 63 69 72 63 6c 65 28 6f | B->circle(o| 00000510 78 20 2b 20 28 61 20 3d 20 31 30 30 2f 69 29 2c |x + (a = 100/i),| 00000520 6f 79 2c 20 28 61 3c 30 29 3f 28 2d 61 29 3a 61 |oy, (a<0)?(-a):a| 00000530 20 29 3b 0a 20 20 20 20 20 20 42 2d 3e 63 69 72 | );. B->cir| 00000540 63 6c 65 28 6f 78 2c 20 6f 79 20 2b 20 28 61 20 |cle(ox, oy + (a | 00000550 3d 20 31 30 30 2f 69 29 2c 28 61 3c 30 29 3f 28 |= 100/i),(a<0)?(| 00000560 2d 61 29 3a 61 20 29 3b 0a 20 20 20 20 20 7d 0a |-a):a );. }.| 00000570 20 20 42 2d 3e 65 6e 64 70 61 74 68 28 66 69 67 | B->endpath(fig| 00000580 75 72 65 29 3b 20 20 20 20 20 20 20 20 20 20 20 |ure); | 00000590 20 20 20 2f 2f 20 65 6e 64 20 6f 66 20 66 69 67 | // end of fig| 000005a0 75 72 65 0a 0a 20 20 2f 2a 20 6d 6f 64 69 66 79 |ure.. /* modify| 000005b0 20 61 74 74 72 69 62 75 74 65 73 20 6f 66 20 6f | attributes of o| 000005c0 62 6a 65 63 74 73 20 69 6e 20 41 20 2a 2f 0a 20 |bjects in A */. | 000005d0 20 63 6f 6c 6f 75 72 28 62 61 6e 6e 65 72 2c 72 | colour(banner,r| 000005e0 65 64 29 3b 20 20 20 20 20 20 20 20 20 20 20 20 |ed); | 000005f0 20 20 20 20 20 20 0a 20 20 66 6f 6e 74 28 62 61 | . font(ba| 00000600 6e 6e 65 72 2c 54 72 69 6e 69 74 79 5f 4d 65 64 |nner,Trinity_Med| 00000610 69 75 6d 29 3b 20 20 20 20 20 20 20 20 20 20 20 |ium); | 00000620 20 20 20 20 20 20 20 20 0a 20 20 41 2d 3e 66 6f | . A->fo| 00000630 6e 74 5f 78 28 62 61 6e 6e 65 72 2c 32 30 29 3b |nt_x(banner,20);| 00000640 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000650 20 20 20 20 20 20 20 20 20 0a 20 20 41 2d 3e 66 | . A->f| 00000660 6f 6e 74 5f 79 28 62 61 6e 6e 65 72 2c 32 30 29 |ont_y(banner,20)| 00000670 3b 20 20 20 20 20 20 20 20 0a 20 20 66 69 6c 6c |; . fill| 00000680 28 6d 79 70 61 74 68 2c 61 7a 75 72 65 29 3b 20 |(mypath,azure); | 00000690 20 20 20 20 20 20 20 20 20 20 20 0a 20 20 6f 75 | . ou| 000006a0 74 6c 69 6e 65 28 6d 79 70 61 74 68 2c 6e 6f 6e |tline(mypath,non| 000006b0 65 29 3b 20 20 20 20 20 20 20 20 20 20 0a 20 20 |e); . | 000006c0 63 6f 6c 6f 75 72 28 6d 79 74 78 74 2c 67 72 65 |colour(mytxt,gre| 000006d0 65 6e 29 3b 20 20 20 20 20 20 20 20 20 20 20 20 |en); | 000006e0 20 20 20 0a 20 20 66 6f 6e 74 28 6d 79 74 78 74 | . font(mytxt| 000006f0 2c 48 6f 6d 65 72 74 6f 6e 5f 42 6f 6c 64 5f 4f |,Homerton_Bold_O| 00000700 62 6c 69 71 75 65 29 3b 20 20 0a 20 20 41 2d 3e |blique); . A->| 00000710 66 6f 6e 74 5f 78 28 6d 79 74 78 74 2c 31 36 29 |font_x(mytxt,16)| 00000720 3b 20 20 20 20 0a 20 20 41 2d 3e 66 6f 6e 74 5f |; . A->font_| 00000730 79 28 6d 79 74 78 74 2c 31 36 29 3b 20 20 20 20 |y(mytxt,16); | 00000740 20 0a 0a 20 2f 2a 20 6d 6f 64 69 66 79 20 61 74 | .. /* modify at| 00000750 74 72 69 62 75 74 65 73 20 6f 66 20 6f 62 6a 65 |tributes of obje| 00000760 63 74 73 20 69 6e 20 42 20 2a 2f 0a 20 20 66 69 |cts in B */. fi| 00000770 6c 6c 28 66 69 67 75 72 65 2c 62 6c 75 65 29 3b |ll(figure,blue);| 00000780 0a 20 20 6f 75 74 6c 69 6e 65 28 66 69 67 75 72 |. outline(figur| 00000790 65 2c 20 6f 72 61 6e 67 65 29 3b 0a 20 20 77 69 |e, orange);. wi| 000007a0 6e 64 69 6e 67 5f 72 75 6c 65 28 66 69 67 75 72 |nding_rule(figur| 000007b0 65 2c 45 76 65 6e 5f 4f 64 64 29 3b 0a 0a 20 2f |e,Even_Odd);.. /| 000007c0 2a 20 73 61 76 65 20 61 6e 64 20 64 69 73 70 6c |* save and displ| 000007d0 61 79 20 2a 2f 0a 20 42 2d 3e 65 6e 64 28 22 52 |ay */. B->end("R| 000007e0 41 4d 3a 42 22 29 3b 20 20 20 20 20 20 20 20 20 |AM:B"); | 000007f0 20 20 20 2f 2f 20 73 61 76 65 20 42 20 74 6f 20 | // save B to | 00000800 52 41 4d 3a 42 20 61 6e 64 20 64 69 73 70 6c 61 |RAM:B and displa| 00000810 79 20 69 74 0a 20 41 2d 3e 65 6e 64 28 22 52 41 |y it. A->end("RA| 00000820 4d 3a 41 22 29 3b 20 20 20 20 20 20 20 20 20 20 |M:A"); | 00000830 2f 2f 20 73 61 76 65 20 41 20 74 6f 20 52 41 4d |// save A to RAM| 00000840 3a 41 20 61 6e 64 20 64 69 73 70 6c 61 79 20 69 |:A and display i| 00000850 74 0a 7d 0a |t.}.| 00000854