Help for DrawBust Drawing Program
(text updated: 1/09/2014 4:48 PM)
DrawBust copyright 2008-2014 Fred Mangan all rights reserved.
Platform: Euphoria4 + Win32Lib
If you're not into computer programming for graphics – images and pictures, both still and animated – then you are unlikely to have a use for this program other than as a toy to play with. The program is of virtually no use to anyone who has no experience or understanding of writing programs to portray 2D vector drawings on a computer screen. Of course you might have better ideas about this than mine.
I wanted a program that would provide
1. creation and (reloadable) editing of simple 2D vector graphic objects;
2. their exportation in known formats that could be used by computer programs.
The result is DrawBust V3, a simple program written in the Euphoria programming language, which lets you create a vector-drawn object on the screen and save it to file. Saved drawings can be reloaded and edited.
This latest version (2014) of the program is a porting to Win32Lib of program code previously used with EuWinGUI. During the transfer some minor bugs (and one really bad one) were discovered and fixed and some minor improvements were made.
The most significant feature of DrawBust V3 is that, besides saving your drawings, you can export them to file in any one of three formats:
As a pretty_printed Euphoria sequence, which you can use in programs written in the Euphoria programming language. (The sequence is now exported as a function).
As DATA statements usable in programs written in versions of the BASIC language that support DATA statements.
As a Generic text file containing numbers in ASCII, which most programming languages should be able to read.
When you move the mouse around over controls in DrawBust's window, a brief description of what each control does appears as a Hint.
As a result, this Help does not explain the obvious but concentrates on a few topics where the program is not conventional, or needs some extra explanation about how to get things done.
The DrawBust program is not a program for drawing busts - though no doubt it can be used for that purpose.
I gave it this name because it uses (amongst other things) a number of routines (functions) I called "bustouts"; these routines can produce various 2D vector shapes on demand, such as circles, rectangles and stars. Every graphics programmer needs some routines like these.
Just unzip the supplied zip file and move the resulting folder to any convenient place on your computer. Create a shortcut for the DrawBust.exe file and copy it to your Desktop, or to wherever best suits your arrangements. And that's it.
The program makes no changes to your computer system.
To uninstall the program just drag the folder DBV3 to the recycle bin. It will be gone the next time you empty the bin. Bear in mind that this will destroy any drawings you created with the program if you saved them anywhere inside the DBV3 folder.
Click on the file DrawBust.exe (or on the shortcut you created for DrawBust.exe) to start the program, and follow the prompts until you reach the main graphics screen.
I have created a folder called DrawArch which contains some sample drawings. All saved drawing files have the extension "DRB". Probably the best thing to do is to load these files (File → Open) one by one and have a look at them. They range from quite complicated drawings to very simple ones like Sailboat.drb. Try out the buttons in the Manage Group to see what they do to a drawing ... if you try these buttons they will be recorded as changes to the drawing and the program will ask you Drawing has changed; Save it?. Reply No to this question, unless you really want to save your changes, and then save them to a file having a name different from the original file name of the drawing.
A 2D Vector Graphic drawing is as near a computer comes to producing an equivalent to a line drawing such as a human would produce on paper with a pencil or pen. Of course, the computer does not do this by itself; it needs a suitable drawing program, such as DrawBust, or one of the many commercial programs for drawing vector graphic drawings It also needs you, the human, to guide the program in what it draws.
The basic data saved by a vector graphics program consists of the (geometric) coordinates of the many lines of which the drawing is composed. This contrasts with programs which save EVERY pixel (tiny screen dot) of the picture on the screen. Programs like Paint or Photoshop, which do this, are often called bitmap drawing programs.
A bitmap picture saved on disk is relatively easy to reproduce visibly on the screen or on a printer. All a programmer has to do is to load all the pixels from the disk file and (metaphorically) slap them onto the screen or printer.
With a vector graphic drawing saved to disk, to reproduce it on screen, all the data in the file has to be loaded into the computer, and then the data (i.e., the coordinates of the lines) have to be drawn on the screen by program instructions that "understand" and can interpret what the data is. Other program instructions "understand" such things as filling polygons with colour and will do them as needed.
Here are some of the differences between a bitmap picture and a picture drawn with a vector graphics program:
Scalability: A vector graphic drawing can be shrunk as small as wished or increased in scale as much as wished without any loss of information from the data (though even a vector drawing, shrunk very small, will reproduce poorly on the screen, due to limitations of the resolution of the screen). Bitmap drawings are not easily scaled up and down and quickly loose coherence if they are.
Transformations: Using maths' formulas, vector drawings can be quickly and (fairly) easily transformed. Transformation here means doing things like rotating the drawing, flipping it upside down or end-for-end, or "shearing" it – making it appear to lean to left or right. Vector drawings can also be manipulated to produce animation effects. You can't do such things with "objects" portrayed in a bitmap picture.
File Size: Vector graphic data files tend to be small. Relatively, bitmap data files, even compressed, tend to be big.
These differences make vector drawings an attractive proposition for use in computers when you want to use simple animation effects, or are content to reproduce simple line drawings. Some vector graphic programs (e.g., Corel Draw) can produce sophisticated drawings. But few of them export their drawings in a form easily accessed (without specialist "inside" information about the file format) by other programs. I wanted DrawBust to produce its export data in formats at least one of which should be reasonably familiar to users of Euphoria, of the various shades of BASIC and of other computer languages.
All file operations are accessed via the File Menu:
Click on File, then
Make your loading choice from the drop-down list (Open or Recent).
or
Press Alt+F, (for File menu) then
Press O or R (Open or Recent) for the option in drop-down list choice.
When a drawing is saved to disk it is saved in a file having the file-extension "DRB". I have saved some sample files in a folder called "DrawArch". In fact you can save "DRB" files anywhere on your system you like.
Use the "File → Open Drb" menu to load a "DRB" file from disk. In the ensuing file dialog open (say) the "DrawArch" folder and click on one of the "DRB" files in it and then click the "Open" Button. The picture it contains will appear in the main drawing area.
When a drawing is saved to disk it is saved in a file having the file-extension "DRB". I have saved some sample files in a folder called "DrawArch". In fact you can save "DRB" files anywhere on your system you like.
Use the "File → Save As Drb" menu to save a "DRB" file to disk. In the ensuing file dialog, navigate to the place where you want to save the drawing, type the name under which you want to save it (".drb" will be automatically added to your name if you omit it), and then click the "Save" button. The file will be saved. If there is a pre-existing file of that name, the program will warn you about it and offer an opportunity to discontinue the saving operation.
You need to have a picture on the screen before you can export it. Either create it from scratch or load it from a "DRB" file.
To export the drawing to disk, click “File → Export” ... and then click one of the three alternative types of file that appears.
Once you start the Export process, most everything runs automatically. The exported file will be saved in the program's home folder. Exported files are assigned automatically generated names of the form
"BUSnnnnn.out"
where the n's stand for digits. So the first file you generate would be called "BUS00001.out", the second "BUS00002.out" and so on. The program will tell you what name it has given to an exported file.
As you export files it is a good idea to rename them and move them away to the location in which they will finally be used. It is also a good idea to delete unwanted "BUSnnnnn.out" files rather than accumulating dozens of them in the program's home folder.
There is a Menu option (File → Delete Export Files ...) that will get rid of all the "BUSnnnnn.out" files in the programs home folder.
All exported files are text files (even though they are arbitrarily given the extension ".out"). So you can load them into a text editor to view or modify them. It is a good idea to do this so as to get a good idea of what the exported data is and what it looks like; in addition some of the exported files contain additional information about each export format.
SEE: The sub-sections next below for examples of the three export formats.
Whatever type of export you are doing (to Euphoria form, to BASIC DATA form, or to GENeral file form), the program will next ask you about possible colour conversions, in an
"Export Colour Scheme" dialog box:
The dialog box first reports the current colour format of the drawing – either BGR or BAS (Old Basic colour codes).
The dialog then lists 2 or 3 colour schemes to which the colours as exported can be converted. Possible conversions are:
BRG
BGR
BAS (Old BASIC Codes)
Check the one of these that best suits your needs, then click OK to accept your choice.
NOTE ABOUT BGR and RBG COLOURS IN EXPORTS
The program exports each BGR or RGB colour it encounters as a single decimal integer incorporating the B, G, and R (or R, G, and B) components of the colour. If your programming language doesn't support expressing colours in such an integer, but demands to be told each R, B, and G for a colour, then your application will have to "unpick" the decimal integer into its component R, G and B colour. This is commonly done by logically ANDing the decimal integer against suitable masks to extract each of the 3 bit patterns.
This option lets you export a drawing as a pretty-printed Euphoria function. The exported function can
Be copied, then pasted into your program for final display on the screen; or
Be copied, then pasted into an "include" file, and with some extra programming effort (not much), be incorporated into an "include" file from which it may be read into your graphic's program.
The Euphoria data type known as a sequence, is extraordinarily flexible and easy to use in manipulating data for use in graphics' programs.
A sample of its output (produced from the Sailboat.drb drawing) can be found in Appendix 1.
Before you could use this sequence you would need to edit out the lines that read
"-- element_name",
or to convert such lines into comments. In a large graphic file this is easiest done with the Find and Replace feature of your editor. First remove all {“,) and then all (“).
Examples of creating a usable sailboat
Here, _Sample_ stands for a paste-in of the above sample output. As a function it is:
global function sailboat()
return _Sample_
end function
This can be pasted into your program, or into an include file to be included in your program; in this this latter case the function should be left global.
This option lets you export a drawing as numbers in BASIC DATA statements that can be copied, then pasted into your vector graphic drawing program for final display on the screen. The output includes REM statements describing the format of the DATA statements and what the numbers in them represent, as a guide to help you use them.
A sample of its output (produced from the Sailboat.drb drawing) appears in Appendix 2. It looks overly commented and fussy because of all the REMs, but is really no more complicated then the Euphoria version.
Since I am no longer a regular writer of BASIC code, you are on your own from this point on. But …:
SEE F.4. - Export as Generic below for a sample of code that would, with minor modification, read this data.
This option lets you export a drawing in a generic form that could be read by virtually any program written in a language that allows reading of sequential files. The relevant data numbers appear at the beginning of the file, and is followed by text descriptive of how the data might be read into a computer.
A sample of its output (produced from the Sailboat.drb drawing) is in Appendix 3. No comments are embedded amongst the data numbers so as not to hamper the program that would read the numbers.
A drawing of an object executed with a vector drawing program usually consists of lots of individual components (aka elements or segments) which, taken all together, go to make up the appearance of the final object. As elements are drawn, those drawn later will partly conceal elements drawn earlier if they overlap them. So when drawing an object you start with those parts of it most distant from your viewpoint and at the end you are drawing the parts of it closest to your point of view.
If you are unused to the order in which components are added to a vector drawing of an object, load one or two of the sample drawings and, when you have one on the screen, examine what happens when you click the "Undo" Button.
Each click on the "Undo" Button removes a component from the drawing, starting with the most recently drawn one and from there on works backwards through the drawing until nothing is left; the last component removed is the one that was drawn first. The "Undo" Button is a handy way to examine how a drawing object was put together ... as well as serving to remove a badly drawn element.
As mentioned above, drawing a 2D object with a vector graphics program consists of drawing the elements of the object one by one, starting with the one furthest from your viewpoint and continuing on drawing more components until the drawing is finished.
So drawing an object consists of drawing (usually) many components, and how to use the program to draw boils down to knowing how to use it to draw a component.
Drawing a component consists of the following steps:
Selecting the properties you want for the component in the Tools Group.
Selecting the colour you want for it (Colour Pan and Colour Picker).
Selecting the style you want for it.
If it is a polygon is it to be filled (Filled Polygon check).
Starting the process of drawing the component in the DrawGroup.
Drawing the component by clicking in the drawing area.
Ending the process of drawing the component in the Draw Group.
Select the properties you want for drawing a component, if not already selected, using the controls in the Tools Group. The controls are:
Click on this Button if the component you want to draw is a free-hand poly-line or a free-hand polygon. This Button is the one selected by default when you first run the program. |
Click on this Button if the component you want to draw is a rectangle or a square. |
Click on this Button if the component you want to draw is a circle. |
Click on this Button if the component you want to draw is an ellipse. |
Click on this Button if the component you want to draw is a free-hand line or polygon drawn as if with a pencil. |
Polygon Check Check this box if the component you want to draw is to appear as a polygon. Uncheck it if the component is to appear as a line drawing.
|
In the program a polygon will be automatically closed if you have left it open and will be filled with whatever the currently selected colour is.
To select a colour for a component click on the Colour Pan, if the Pan is not already the colour you need. A colour picking chart will appear. Click the colour you want then click OK. The Colour Pan will change its colour to the colour you have selected.
To start the drawing process, click the "Start Seg" Button in the Draw Group.
The method of drawing varies depending on what radio button you selected in the Tools Group. Move the mouse arrow cursor into the drawing area. When you do, the arrow cursor disappears and is replaced by a drawing cursor (you can set a full-window cursor in Preferences, if you like).
F/Hand Poly: Manoeuvre the cursor to cover the place where the first vertex of the poly-line is to be and click in the first point. Keep on going and click in the other points (vertices) of the poly-line; as you click in each point it will be connected to its predecessor by a straight line. When you have drawn enough points, click the "Add Seg" Button in the Drawing Group. What you have just drawn will be added to the drawing as a poly-line or as a polygon (if you had checked the Polygon Check box).
Rectangle: To draw a rectangle you click in only 2 points; the 2 points should be the extremities of a diagonal of the intended rectangle. As soon as 2 points have been clicked, the rectangle will appear. It will be filled with colour if the Polygon check box was checked, otherwise it will be drawn as a line drawing.
Circle: To draw a circle you need to click in two points. The first point should be at the position for the centre of the circle. The second point can be anywhere on the intended circumference of the circle. As soon as both points have been clicked, the circle will appear. It will be filled with colour if the Polygon check box was checked, otherwise it will be drawn as a line drawing.
Ellipse: To draw an ellipse you need to click in two points. The first point should be at the position for the centre of the ellipse. The second point should be at a point that would be the extremity of a diagonal of an imaginary rectangle containing the intended ellipse (this sounds tricky but is quite simple in practice). As soon as both points have been clicked, the ellipse will appear. It will be filled with colour if the Polygon check box was checked, otherwise it will be drawn as a line drawing.
Pencil: To draw with the pencil, move the drawing cursor to the point where you want the pencil line to start and click once. Then move the cursor to trace out the pencil line path intended until you reach the point where the line is to end. At the end point click again. The line will be added to the growing drawing object on the second click and redrawn on the screen in colour. If the Polygon box was checked the ending point will be connected to the starting point; if the Fill Polygon radio is checked the resulting closed figure will be filled with the current colour.
For all the shapes except the free-hand poly-line you need do nothing special to end drawing the shape – it will terminate on your second click and will be added to the drawing automatically.
For the free-hand poly-line – which involves 2 or more clicks – the computer has no way of knowing when you are finished the line. In this case you need to click the "Add Seg" Button to indicate that you have finished it. Alternatively you can now Right Click with the Mouse to end and save a free-hand poly-line or a pencil line (a program change).
After drawing an element, you may sometimes get a message:
"Incomplete segment, not added".
This means that you did not click in a sufficient number of points for the sort of shape you were trying to draw.
If you have made a mess of drawing a component and it comes out all wrong, just click the "Undo" Button after you have drawn it and it will be removed from the object. You can set about drawing it again.
The Select List enables you to select just one element in your drawing, or a range of elements in the drawing, or the entire drawing. Having made a selection there are various things you can do with it, such as copying the element(s) or deleting them or moving them.
Also by making a selection you change the INSERTION POINT of the program. The insertion point is immediately AFTER the item in the Select List that is currently highlighted. More about the insertion point below.
When every element in a drawing is selected, the label under the Select List will read
Selected ALL
and the last element in the Select List will be highlighted and is the insertion point. When you load a drawing from disk, every element in the drawing will be selected automatically and this condition will prevail. This is the standard state to be in when you want the program to add new elements, as you draw them, to the end of the Select List – and display on top of what you have drawn so far.
When there is no drawing in the program, this label will read
Selected NONE
To force the computer to select all elements of a drawing, click on the Select List and then press Ctl_A. You can also select all elements by clicking on the red range-reporting label under the Select List.
To Select One Element:
To select one item in the Select List, click on it until the label under the Select List reads
Selected n - n
where n is the number of the element in the List. Besides having selected element n, the insertion point is now immediately AFTER element n.
To Select a Range of Elements:
In the Select List click on one element at an extreme of the range and click until it is selected. Then click on the element at the other extreme of the range (if the element is out of sight, use the sidebar to get to it). If you selected elements m and n and if m is less than n the label under the Select List should now read
Selected m - n
and element n should be highlighted. The insertion point is now immediately after item n.
You can select the extremes of a range in whatever order you like.
To delete an element or range of elements, select them and then press the Del key. You will be asked to confirm the deletion before deletion is done.
As you already tried out, the Undo Button's real and intended use is to remove the most recently added segment. ALL should be selected in the Select List.
To copy an element or range of elements, select them and then press the key combination Ctl+C. The computer will inform you of what element(s) were copied to memory.
What you have copied will be remembered until you copy something else or until you terminate the program. Copying is not done to the Windows' Clipboard but to memory allocated by the program, so what is copied can't be pasted to an external file.
SEE: Pasting
Internal Pasting
When you have copied an element or range of elements you can paste it/them into another location in the drawing. Just select the element after which you want the copied element(s) to be pasted and press the key combination Ctl_V. You will be asked to confirm the pasting; click Yes if what is offered is OK, click No if it is not.
Anything you copy can be pasted multiple times into your drawing. Just select a suitable insertion point for each pasting before you do it.
When you paste internally, then when you look at the picture it may appear that nothing has happened at all, especially since the pasting will lie directly on top of what you copied. Select the elements of what you have just pasted in and move them (with Move Buttons) to the position they should occupy.
The file “OldTrain.drb” is the result of multiple pasting of drawing elements. There was originally only one railway carriage in this drawing; the carriage was copied and than pasted in 3 times, and each of the 3 pastings was moved one by one to the back of the train.
External Pasting
In addition you can paste part or all of a drawing into another drawing. Select and copy what you want to transfer. Save the active drawing to disk if necessary. Then load the other drawing from disk file, select a suitable insertion point for the pasting, then paste what you have copied. What you have pasted will very likely be in the wrong place and be the wrong size to suit the drawing. To remedy this manoeuvre the entire drawing (Ctl_A for Seleced: ALL) to a convenient position, then select the elements of what you have pasted and move them to their correct position (with Move Buttons) and correct size (with Z+ and/or Z- Buttons) until you are satisfied. Finally adjust the entire drawing (Ctl_A) to suitable dimensions and position, and save the whole thing to disk.
After a lot of manipulations like the above, don't forget to key in Ctl_A (Selected: ALL) if you want to return to the more normal, routine, mode of insertion at the end of the drawing.
NOTE: elements pasted in retain their original identifying names, whether the names were created by you or auto-generated by the program. For complex drawings it would be wise to give meaningful names at least to some of the key elements in the drawing.
SEE: Copying
This option provides a way to
quickly review the data in each of the segments that make up a drawing;
alter colours of individual elements of the drawing if desired.
To activate the option, you must have a drawing on the screen. Then, on the menu bar, select:
Modify Colours and Names (Alt-E,Alt-M).
A new window will appear, headed "Data Lists and Colour Editing". You will see:
On the left, a list headed COLOURS, containing the HEX values of the colour of each element of the drawing. You can change the heading of this list and what appears in it by clicking on one of the three radio buttons:
Colour
LineType
Fill
In the centre of the window is a reproduction of some or all of your drawing. If you click on the top item in the list, you will see only a reproduction of the first element (segment) of your drawing; if you click on the last element in the list, you will see a representation of the entire drawing. Clicking on intermediate items in the list will produce reproduction of all elements preceding that item in the list, as well as of that element itself.
On the right of the window is another list listing all the coordinates of the element that you have selected in the list on the left.
The DrawBust program uses the BGR (Blue,Green,Red) convention for colouring. This means that when we write the number for a colour in Hex notation, the the individual digits of the number are as follows:
Hex: FF0000
The first 2 digits (FF) refer to amount of Blue, the second 2 digits (00) to the amount of Green and the third 2 digits to the amount of Red. Thus the colour FF0000 represents fully saturated blue, with no added green or red. Most modern programming languages express colours in this way, or one closely allied (e.g., users of HTML will know that in HTML colours are represented by hex digit-pairs in the order RGB; confusing).
BASIC LANGUAGES
Old versions of BASIC allow you to use 16 colours, with code numbers 0 to 15 (0 to F in hex). Thus even old BASIC uses a value of 0 for black (000000 in BGR). Since in the BGR system the use of colours 000001-00000F produces a virtual black colour and would not usually be colours called for in BGR, the DrawBust program interprets the values 000001-00000F to stand for the old BASIC codes, and, for instance will reproduce 000001 (meaning blue in old BASIC) as FF0000 in any drawing on the screen, and so on (e.g. 000002 as green, 000003 as cyan, 000004 as red, and so on up to 00000F as bright white).
This means that if you use an old BASIC, you can replace a BGR value in the COLOUR table by the nearest old BASIC approximation to the colour. The screen picture will reproduce the drawing with suitably substituted BGR colours.
In this window you can edit both element colours and element names:
To edit element colours do the following
check the Colour radio button.
work down the COLOUR list from element to element.
at elements where you want to change the colour, type in the substitution you want to make in the edit field. NB, hit Enter to make the change.
the effect of the change will appear in the drawing and in the colour pan below the edit field.
2. The procedure is similar if you want to change element names, only in this case you edit names in the names-edit, hitting <Enter> after each entry you make.
When you are finished making changes, click on the Exit button.
If your colour scheme is inconsistent – that is, BGR mixed with old BASIC codes – you will be warned about it and offered the opportunity to remedy the situation or to abandon the colour changes.
You will next be asked if you want to accept the changes you have made into the drawing. Respond Yes or No as appropriate.
Then, if you have made changes you want to keep, save your work to a "drb" disk file.
SEE also Exporting Pictures for more about exporting colours in drawings.
The listing is reproduced in file Help.odt
The listing is reproduced in file Help.odt