The full listing to date and some extra goodies from the graphics man, Glynne Davies.
Two more modules to add to the program, the first deals with rubbing out unwanted items and the second module is for creating shapes. You need to load "EASY3" created last month. If you have not followed the series so far or missed last month, here is the full listing to date:
Everyone makes mistakes so I have included a facility to erase a block. I have used small erasers in other packages and found them difficult to control when accuracy is required, so I have made this routine only erase after you have selected the area with a box.
- The area for deletion must be clear.
- The key F can be used to Finally Remove the block chosen
- The jump size must be selectable during this option
- Any other function chosen will switch off the rubber.
rub rub= 1 means rubber is on.
origx Origin of x co-ordinate,
origy Origin of y co-ordinate,
xs x start for graphics window,
ys y start for graphics window,
xe x end for graphics window,
ye y end for graphics window,
The Listing (Ensure "EASY3" is in memory before typing in the listing.)
28 REM variables rub (rubout variable) origx,origy (original x and y)
280 IF INKEY(50)=0 THEN GOSUB 11000:rub=1:mde$="RUBBER":GOSUB 12000
290 IF rub=1 THEN GOSUB 16000
16010 LOCATE 1,1:PRINT CHR$(23)+CHR$(1);
16015 IF start=0 THEN start=1:origx=x:origy=y
16020 MOVE origx,origy
16030 DRAW x,origy,1:DRAW x,y,1:DRAW origx,y,1:DRAW origx,origy,1
16040 DRAW x,origy,1:DRAW x,y,1:DRAW origx,y,1:DRAW origx,origy,1
16050 IF INKEY(53)=0 THEN GOSUB 16100
16100 IF x < origx THEN xs=x:xe=origx:ELSE xs=origx:xe=x:REM find the XStart and Xend for the window
16110 IF y < origy THEN ys=y:ye=origy:ELSE ys=origy:ye=y:REM find the YStart and YEnd for the window
16115 GOSUB 5070:REM remove cursor
16120 ORIGIN xs+4,ys,xs+4,xe-4,ys,ye:CLG:REM Redefine the graphics screen and clear the new window
16130 ORIGIN 0,0,0,640,384,0:REM Reset graphics screen
16140 GOSUB 5070:REM replace cursor
A Look at the Listing
- Line 280 Press R for Rubber
- Line 11010 Reset new variables
- Line 16020-16040 Draw box around selected area.
- Line 16100-16110 Calculate xs xe ys and ye
- Line 16120 Change graphics screen to the box selected and CLear the Graphics screen.
- Line 16130 Reset the graphics screen to the full screen apart from the top line.
Save the program as "Rubber" and RUN to test.
How to Use the Rubber
- Draw something to erase
- Select M and Move to a corner of the area you wish to rub out.
- Press R
- Use the arrow keys to select the block to be erased
- Press J to change the jump size
- Press F to erase what is within the block
- Select Beam,Elastic etc to switch off the rubber.
CIRCLE AND SHAPES
Although it is possible to draw circles with the Arc routine this routine allows you to draw full circles, ellipses and shapes of any amount of sides. The horizontal radius and Vertical radius are asked for so the circles or shapes can be elliptical. The use of this routine is the same as the Arc routine when asking for the radius, after which the amount of sides are asked for with the start position (the start position is the bottom centre and the angle in degrees is clockwise see circle/shape drawing)
- All shapes (triangle square polygon circle) to be produced.
- The start position of the shape can be stated.
- The size of the previous shape can be remembered to allow several shapes of the same size.
side Amount of sides in the shape,
rx Radius horizontal,
ry Radius vertical,
sa Start Angle (changed from degree to radians.
The Listing ("Rubber" needs to be in the memory when typing in the listing)
29 REM Variables side (amount of sides in shape) sa (Start angle of shape)
300 IF INKEY(62)=0 THEN GOSUB 11000:mde$="CIRCLE":GOSUB 12000:GOSUB 7000:GOSUB 11000:GOSUB 12000:REM Press C for Circle/Shape routine
7000 REM Circle and Shape routine
7010 IF r=0 THEN r=40
7020 REM Input the horizontal radius and vertical radius to allow for ellipses, for circular objects set radius and press F twice
7030 start=-1:angle=PI/2:LOCATE 12,1:PRINT "Horizontal Radius":GOSUB 10030:rx=r:REM Use Arc routine
7040 FOR n=1 TO 20:CALL &BB1B:NEXT:REM Flush the buffer
7050 LOCATE 12,1:PRINT "Vertical Radius ":angle=0:GOSUB 10030:ry=r:start=0:REM Use arc routine
7060 ask$="Enter the amount of sides or Enter for circle":xx=12:l=3:str=0:GOSUB 3000:side=VAL(ans$)
7070 IF side=0 THEN side=100:REM If Enter is pressed set up a 100 part circle.
7080 IF side < 16 THEN ask$="Enter the start angle 0-360":xx=12:l=3:str=0:GOSUB 3000:sa=VAL(ans$):sa=2*PI*(sa/360)
7090 GOSUB 5070:REM remove cursor
7100 MOVE x+SIN(-PI+sa)*rx,y+COS(-PI+sa)*ry:REM move to the bottom of shape
7110 FOR n=-PI+sa TO PI+0.2+sa STEP (2*PI)/side:REM Calculate the positions for a circle of (side) sides
7120 DRAW x+SIN(n)*rx,y+COS(n)*ry,1:REM Draw a straight line between positions
7140 GOSUB 5070:REM replace cursor
7160 IF INKEY(53)=0 AND start=-1 THEN arc=1
7170 IF start<1 THEN GOSUB 5000:PRINT CHR$(23)+CHR$(1);:REM cursor keys
7180 IF start=-1 THEN arc=0:RETURN:REM Use the Arc routine but return at this point.
10055 IF INKEY(53)=0 AND start=-1 THEN arc=1:REM Selection of radius from the circle routine
10110 IF start<1 THEN GOSUB 5000:PRINT CHR$(23);CHR$(1);:REM cursor keys
10165 IF mde$="CIRCLE" THEN arc=0:RETURN:REM Return to the circle routine
A Look at the Listing
- Line 300 Press C for Circlle routine,
- Line 7010 Set radius to 40 if radius does not exist.
- Line 7030-7060 Ask for radius x and y and the amount of sides. Line 7080 Ask for start position if the sides are below 16. When the amount of sides are 16 and above the shape is virtually a circle.
- Line 7100 Move to the start position around the circle.
- Line 10110 Use the cursor movement routine to allow positioning.
Save the whole listing as "EASY4" before running to test the new function.
EASTDRAW2 Commands So Far and when they were introduced
MONTH 1 (Program name "EASY1") Move cursor Use the arrow keys
- CTRL+F Colour of Foreground
- CTRL+B Colour of Background
- CTRL+R Return the cursor tothe centre
- CTRL+D Display the x and y position of the cursor. (On and Off)
- B Switch on the beam
- M Switch on Move
MONTH 2 (Program name "EASY2")
- E Switch on Elastic Banding
- F Fix line in position
- CTRL+SHIFT+W Wipe the Screen Clear.
- J Input Jump size (step of cursor)
MONTH 3 (Program name "EASY3)
- T Type in Text
- T When text box is shown toggle between single and double size text.
- F Fix text in Position ARC
- A Select Arc
- + Increase the radius
- - Decrease the radius
- < Rotate anticlockwise
- > Rotate clockwise
- K Keyed inoput of radius
- S Mark the start of the arc
- F Mark the finish of the arc after start has been selected Arrow keys Move the centre of the arc
MONTH 4 (Program name "EASY4")
- r Select Rubber
- Arrow keys Change size of eraser block
- F Erase within the block
Circle and Shape
- As Arc for horizontal radius.
- Press F when complete.
- For Vertical radius as arc if the same radius as the horizontal is required just press F.
- Answer the amount of sides Answer the start position if below 16 sides
All functions selected cancel previous selections.
Next Month there will be a module to Save, Load and Catalogue the disc and a module to paint an enclosed area with a pattern. At last your masterpiece can be saved to work on another day.