-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvectorgenerator.c
executable file
·106 lines (106 loc) · 2.26 KB
/
vectorgenerator.c
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include "shapes.h"
int main(int argc, char *argv[])
{
if (argc < 5)
{
printf
("%s [number of elements] [height] [width] [number of files] [specific element, leave empty if randomized] [square side, for element 8 only]\nElements\n0\trectangle\n1\tcircle\n2\tellipse\n3\tline\n4\tpolygon\n5\tpolyline\n6\tcurve\n7\tgradient, wont be randomized\n8\trandom squares of color\n",
argv[0]);
return 0;
}
int cycles = atoi(argv[1]), length = atoi(argv[2]), width = atoi(argv[3]), chance, turn =
0, nfil = 0, polycount = 0, polycounter = 0, curvetype;
int a, b, c, d, e;
long ti = time(NULL);
char curv[10], filname[10];
FILE *fil;
srand(ti);
while (nfil < atoi(argv[4]))
{
ti++;
srand(ti);
turn = 0;
sprintf(filname, "%d.svg", nfil);
fil = fopen(filname, "w");
memset(filname, 0, sizeof(filname));
MakeSVGFile(width, length, fil);
MakeWallpaper(width, length, fil);
while (turn < cycles)
{
ti++;
srand(ti);
if (argv[5] == NULL)
{
chance = rand() % 7;
}
else
{
chance = atoi(argv[5]);
}
if (chance == 0) // rect
{
MakeRectangle(width, length, fil);
}
if (chance == 1) // circle
{
MakeCircle(width, length, fil);
}
if (chance == 2) // ellipse
{
MakeEllipse(width, length, fil);
}
if (chance == 3) // line
{
MakeLine(width, length, fil);
}
if (chance == 4) // polygon
{
MakePolygon(width, length, fil);
}
if (chance == 5) // polyline
{
MakePolyline(width, length, fil);
}
if (chance == 6) // curve
{
MakeCurve(width, length, fil);
}
if (chance == 7) // gradient
{
MakeGradient(width, length, fil);
}
if (chance == 8) // random rects
{
cycles = 1;
a = 0;
b = 0;
while (a < width)
{
while (b < length)
{
c = rand() % 256;
d = rand() % 256;
e = rand() % 256;
fprintf(fil,
"<rect width=\"%d\" height=\"%d\" x=\"%d\" y=\"%d\" fill=\"rgb(%d,%d,%d)\"/>\n",
atoi(argv[6]), atoi(argv[6]), a, b, c, d, e);
b += atoi(argv[6]);
}
b = 0;
a += atoi(argv[6]);
}
}
polycounter = 0;
polycount = 0;
turn++;
}
EndSVGFile(fil);
fclose(fil);
turn = 0;
nfil++;
}
}