- 1 - Fri 5-November-1993 DRAW LINEs, Copyright (c) 1991, 1993 by Prof. Timo Salmi, (Ver. 1.6) All rights reserved Address: University of Vaasa, P.O.Box 297, FIN-65101, Finland InterNet email address: ts@uwasa.fi Please duly observe the copyright notes in Chapter 7 of this document. DRAWLINE is a graphics system for displaying and demonstrating equations of two variables (that is lines) on an x and y coordinate plane. In particular, the system has been developed for graphical presentation of small linear programming problems, but it is suitable for other line-drawing applications, too. The system has it own command language. First call DRAWLINE. The screen will be divided into two parts, the drawing window, and the command window at the bottom of the screen. To draw a line, say 2x + 3y = 6, type the command li 2,3,6 and the line will be drawn. There are many other graphics commands, and a number of calculation commands, as well. The commands can also be entered from a file such as LPDEMO.DRW. To list the commands type ? or help. For a full description of the commands, see the document TSDRAW.INF. To run DRAWLINE your computer must have a CGA, EGA or VGA graphics adapter. The system applies four-color CGA graphics. 1. Basic graphics commands -------------------------- First call drawline at the MsDos prompt. The graphics and command windows will be opened, the axes will be drawn in the default color (yellow), and you will be prompted for the commands by > at the command window. These commands suffice to get started: li a,b,c Draws the line ax + by = c help Show the list of commands. nw Start anew. Clear the drawing window, and reset all settings. quit Ends the drawline session and returns to MsDos. Exit can be used as a synonym for quit. - 2 - Also the following basic commands can be used: l2 a,k Draws the line y = a + kx sg x1,y1,x2,y2 Draws a line segment from x1,y1 to x2,y2. po x,y Draws a point at x,y (actually a small circle). cl Clear the drawing window, but preserve any settings. There are many other commands for handling graphics and relevant calculations which will be taken up in the following chapters. 2. Colors --------- The default color for drawing is yellow. You can change the drawing color by using ik color where the color is a one letter code: b(lack), g(reen), r(ed), and y(ellow). Alternatively codes 0, 1, 2, and 3 can be used. To rub a line, redraw it is black (the background color). For example if you have drawn li 2.5,3.5,10 and want to erase it, apply ik b li 2.5,3.5,10 ik y 3. Filling areas ---------------- It is possible to fill a closed area. This can be used, for instance, to indicate the area of feasible solutions in graphical presentation of linear programming problems (see lpdemo.drw). fi x,y Floods the area bordered with yellow lines containing the point x,y. (See release notes for version 1.3.) Note that if you have pierced the relevant yellow lines with lines of other colors, and use fill, the flooding color will leak though the holes. Therefore you must see to it that the yellow borders are intact before applying fill. - 3 - 4. Loading data from a file --------------------------- It is possible to take the commands from a file as demonstrated by the demo.drw file. To do this, apply ld filename Load commands from filename The syntax of a command file is the same as in entering the commands from the keyboard. In addition, the exclamation mark (!) can be used for comments in files. See lpdemo.drw for details. 5. Advanced graphics commands ----------------------------- You can redraw the the axes anytime. You can also have a dotted grid on the screen. (Note that the current color will be used. The current color can be changed by ik command, as documented earlier.) ax Redraw the axes ax5 Draw thick notches on the axes every 5 units apart. gr Draw a dotted grid to the drawing window. The notches on the axes are considered to be one unit apart from each other. Thus, for example, the fifth notch on the horizontal axis (x-axis) will present 5, not 50, not 0.5. You may want to change this in accordance of your application. There is a scaling command for that. sc fx,fy Change scale of the x-axis to fx and y-axis to fy, where fx and fy denote the number of units that lies between two adjacent nothes on the axes. For example, if you want the fifth notch to present 50, then apply sc 10. And, if you want it to present 500, apply sc 100, and so on. The f parameter, like all the other parameters, is a real number. Thus you could enter, for example, sc 34.7, even if there is no sense in such a scale. You can also change the location and the proportions of the axes (and the grid) by changing the relevant defaults. To utilize this you will have to have a some understanding of the pixel system used in computer graphics. The parameters are the following. - 4 - xpix = the horizontal location of the grid origin, in pixels from the lower left-hand corner of the window. The width of the of the graphics window is 1500 pixels, and its hight is 1000 pixels. (For those in the know the CGA four-color screen actually uses a 320x200 pixel system, but I use the 1500x1000 system internally to make my programs easily adaptable to the different graphics drivers.) The default is 250 pixels. ypix = the vertical location of the grid origin. The default is 150 pixels. dxpix = the distance between the notches on the x-axis, in the 1500x1000 pixel system. The default is 80 pixels. dypix = the distance between the notches on the y-axis, in the 1500x1000 pixel system. The default is 75 pixels. To change the defaults, apply or xpix,ypix Relocate origin to xpix,ypix. no dxpix,dypix Change the notch distances to dxpix and dypix. 6. Calculator commands ---------------------- There are commands which do not draw anything, but perform relevant calculations for the user: eq x1,y1,x2,y2 Gives the equation ax+by=c of a line going through points (x1,y1) and (x2,y2). c is always made non-negative. es x1,y1,x2,y2,sc Like eq, but scales the a, b, and c by multiplying with sc. sv a1,b1,c1,a2,b2,c2 Solves the simultaneous equations a1*x + b1*y = c1 a2*x + b2*y = c2 ic a,b,c Calculates the intercepts of ax+by=c with the axes. - 5 - The basic arithmetics are available: ad a,b,... Addition a + b + ... sb a,b Subtraction a - b ml a,b,... Multiplication a * b * ... dv a,b Division a / b cr a,b,c,d Cross product a * b + c * d 7. About distributing and using the system ------------------------------------------ All rights reserved. The tsdraw package including drawline system may be used and distributed freely for PRIVATE, NON-COMMERCIAL, NON-INSTITUTIONAL purposes, provided no changes are made to the package (with the exception of a change in the packing method). No part of this package must be distributed separately. For ANY other usage, such as use in a business enterprise or at a university, please contact the author for information on registration. Using this program in business or classroom, or under other comparable public circumstances, without a permission, is a direct violation of the author's copyright. The programs are under development. Comments and contacts are solicited. If you have any questions, please do not hesitate to use electronic mail for communication. The author shall not be liable to the user for any direct, indirect or consequential loss arising from the use of, or inability to use, any program or file howsoever caused. No warranty is given that the system will work under all circumstances. - 6 - 8. Summary of Commands ---------------------- Graphics commands: LONG FORM ar x,y,a,b,r ARc at x,y; angl a to b Arc ax redraw AXes Axes ax5 notch AXes at 5 units Axes5 br x,y,n BaR at x,y n chars wide Bar ci x,y,r CIrcle at x,y radius r Circle cl CLear without resetting Clear fi x,y[,p,c] FIll at seed x,y Fill gr draw dotted GRid Grid gr1 draw pixel GRid Grid1 ik color InK color [b g r y] Ink lb x,y,text LaBel Label ld name LoaD data from file Load li a,b,c draw LIne ax + by = c Line l2 a,k draw Line y = a + kx Line2 no xpix,ypix change NOtching Notch nw NeW: clear and reset New or xpix,ypix relocate ORigin Origin pi x,y PIxel at x,y Pixel po x,y indicate POint at x,y Point quit (exit) QUIT the program - sg x1,y1,x2,y2 draw SeGment Segment sc fx,fy reset SCaling factors Scale tr x,y,r TRiangle Triangle Calculator commands: eq x1,y1,x2,y2 make EQuation Equation es x1,y1,x2,y2,sc Equation Scaled EquationScaled ic a,b,c InterCept Intercept sv a1,b1,c1,a2,b2,c2 SolVe equations Solve ad a,b,... ADd a+b+... - sb a,b SuBtract a-b - ml a,b,... MuLtiply a*b*.. - dv a,b DiVide a/b - cr a,b,c,d CrossProduc a*b+c*d - Other commands: di DIrectory Directory rt Recording toggle RecordToggle sh msdos SHell Shell st stop; files only Stop pa wait for a keypress Pause - 7 - 9. Release notes ---------------- Version 1.1 has the following enhancements and fixes: =========== - The command cr for calculating a cross product. - Scaling of the axes need not be the same. The earlier sc f command has been changed to sc fx,fy. - The label command (lb) now also allows capital letters and multi-word text (maximum 25 words). - The foreign and special characters (ascii 128-254) can be used. To have them properly displayed, you must have loaded MsDos graftabl utility. - More thorough check of the filename in loading the commands from a file with the ld command. - Arc, bar, circle and pixel drawing commands. ar x,y,start_angle,end_angle,r br x,y,n (see help and simeq.drw) ci x,y,r pi x,y - The small circle drawn by the point (po x,y) command has been made thicker and a little bigger. - A simultaneous equations demonstration simeq.drw has been included. - A break-even analysis demonstration has been included in the package. The files are breakev.drw and breakev2.drw. - A linear programming sensitivity analysis demonstration sequence lpdemo1.drw - lpdemo4.drw has been included. - The break key has been inactivated because breaking out of a graphics program leaves the screen "in a funny state". - 8 - Version 1.2 has the following enhancements and fixes: =========== - The choice of palette. The program call DRAWLINE takes palette (0..3) as a parameter. The default is 0, and gives the right colors for the ik (ink) command. In the earlier versions the palette always was palette 1. To see the effect of using the different palettes, I suggest you experiment with them. The usage is DRAWLINE [palette (0..3)] - The color code d (default) in the ik (ink) command is no longer acceptable. I decided that is was best to omit it with the introduction of the palettes. - Colors can optionally be given as numbers from 0 to 3. Do not confuse this with the concept of the palette, where 0 denotes CGAC0, 1 CGAC1, and so on. - Directory command di lets you look at directories from within drawline. - MsDos shell command sh gives a gateway to MsDos. Return to drawline by typing exit, as is usual for MsDos shells. - The filename extension defaults now to .drw. In other words if a stored drawing is loaded from a file (ld command), and no extension is given in the filename, drawline assumes .drw as the extension. To load a file which truly has no extension in the filename, append a point (.) to the filename. - Stop command st This command can be placed in the input file for interrupting the flow of commands. It is convenient in building and testing drawing files. It is for files only. When used in the ordinary interactive command mode, st does not do anything. - 9 - Version 1.3 has the following enhancements and bug fixes: =========== - Optional pattern and (border) color parameters in the fill command fi x, y, [p(attern)], [c(olor)] Pattern and color in fill are advanced options. You have to be both skillful and patient with them. The pattern can range from 0 to 11. The default is 9. Load pattern.drw to see the different patterns. Notice that if you try to fill an area already filled with a pattern, the new pattern will not probably be what you'd expect, since the old pattern defines new (tighter) borders for the area to be filled. The color can range from 0 to 3 (must be given as a digit, not as a letter b,g,r,y). Color defines which color is used as the border when filling. The default border color is 3, that is yellow. See smiley.drw for a simple demonstration. - Fixed (hopefully) the scaling bug in the line commands li and l2. Contrary to the other drawing commands li and l2 did not draw in the correct position when the scale of the axes had been changed with the sc command. - Added tabulate to the command parameter separators. Thus the following formats are acceptable, for example, in the l2 command: l2 1, 2 l2 1 2 l212 as well as all their combinations. - Most importantly, version 1.3 introduces the record mode. If DRAWLINE is called with /r parameter, the commands given from the keyboard are echoed to tmp.drw file. The record mode can be toggled on and off using the rt command provided that the /r switch was initially used. - /s switch suppresses sound. The usage of drawline 1.3 is DRAWLINE [palette (0..3)] [/r(ecord)[filename]] [/s(ilence)] - Pixel grid command gr1 draws a grid made of single pixels. It is less imposing than the gr pattern. - Optional long forms of commands. See the summary of commands, Chapter 8. - 10 - - Allowed usage of EGA64 and IBM8514 graphics drivers. This program has, however, only been tested with CGA and VGA adapters, so I do not know whether they are functional. Version 1.4 has the following enhancements and bug fixes: =========== - Added line-editing and recall potential when input is given from the keyboard. This means that the CursorLeft, CursorRight, Home, End, BackSpace, Delete, and Esc keys can be used to edit the input. Furthermore the latest input can be recalled by pressing the CursorUp key. Some CGA PCs may experience flicker, but CGA adapters are archaic, anyway. - The sh command takes the user to the MsDos shell (and the exit command in the shell takes the user back to the program). Added [TS] to the user's prompt while in the shell as a reminder that the shell is being used. This reminder is useful for avoiding running out of memory by eg calling the program again from within the shell. - A simple correction of the email address information. - Rewrote the di (give directory routine). - On exit back to the text mode the date and the total elapsed time are given. Version 1.5 has the following enhancements and bug fixes: =========== - Added a "pa" pause command. Makes the program wait until a key is pressed. It is particularly well suited for the presentation of sequential prerecorded drawings loaded (ld) from a file. Version 1.6 has the following enhancements and bug fixes: =========== - Introduced DRAWLEGA.EXE "A 16 color EGA version" (ver 1.0) - Prevented the division by zero problem in the li (line) command - Tries to restore text mode if a run-time error occurs