-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDrawTool.c
More file actions
88 lines (76 loc) · 2.33 KB
/
Copy pathDrawTool.c
File metadata and controls
88 lines (76 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// DrawTool.c
#include <stdio.h>
#include "DrawTool.h"
void InitializeMap(char Map[][MAXMAPSIZE], int *MyMapSize)
{
int j, k;
char Background = ' ';
printf("How big is the array? (Enter a value between 1 and %d) ", MAXMAPSIZE);
scanf("%d", MyMapSize);
while (*MyMapSize < 1 || *MyMapSize > MAXMAPSIZE)
{
printf("That value is outside of the max bounds of the array. Please reenter\n\n");
printf("How big is the array? (Enter a value between 1 and %d) ", MAXMAPSIZE);
scanf("%d", MyMapSize);
}
printf("What is the background character? ");
scanf(" %c", &Background);
/* Initialize Map to the entered background character */
for (j = 0; j < *MyMapSize; j++)
{
for (k = 0; k < *MyMapSize; k++)
{
Map[j][k] = Background;
}
}
}
void DrawLine(char Map[][MAXMAPSIZE], int from, int to, char LineType, int count, char mark)
{
int j;
if (LineType == 'H')
{
for (j = 0; j < count; j++)
{
Map[from][to+j] = mark;
}
}
else
{
for (j = 0; j < count; j++)
{
Map[from+j][to] = mark;
}
}
}
void PrintMap(char Map[][MAXMAPSIZE], int MyMapSize)
{
int i, j;
printf("\n\n");
for (i = 0; i < MyMapSize; i++)
{
for (j = 0; j < MyMapSize; j++)
{
printf("%c ", Map[i][j]);
}
printf("\n");
}
}
void PrintInstructions()
{
printf("\nDraw commands start with\n\n\tP for a single point\n\tH for a horizontal line\n\t"
"V for a vertical line\n\n");
printf("After the P/V/H, enter a row,col coordinate and the "
"number of spots to mark\nenclosed in () and separated by commas and then the "
"character for the mark.\n\'X\' will be used if a mark is not entered. "
"For example,\n\n\tP(2,3,1)* \tstart at "
"point 2,3 in the array and mark one spot\n\t\t\t"
"with an *. For P, the 3rd parameter is ignored.\n\n");
printf("\tV(1,2,3)$ \tstart at point 1,2 in the array and mark the next\n"
"\t\t\t3 spots to the right with $\n\n");
printf("\tH(4,6,7)# \tstart at point 4,6 in the array and mark the next\n"
"\t\t\t7 spots down from the current position with #\n");
printf("\nCoordinates out of range and lines drawn past the borders are not allowed.\n");
printf("\nEnter Q at the draw command prompt to quit\n");
printf("\nPress <ENTER> to continue");
getchar();
}