Browse code

(tables.c) Renamed to circle128.c

Devine Lu Linvega authored on 09/06/2023 04:21:22
Showing 3 changed files
1 1
new file mode 100755
... ...
@@ -0,0 +1,7 @@
1
+#!/bin/sh -e
2
+
3
+clang-format -i circle128.c
4
+rm -f circle128
5
+cc -lm circle128 -o circle128.c
6
+circle128 128
7
+
0 8
similarity index 70%
1 9
rename from etc/tables/tables.c
2 10
rename to etc/circle128/circle128.c
... ...
@@ -1,8 +1,8 @@
1 1
 #include <stdio.h>
2 2
 #include <math.h>
3 3
 
4
-/* 
5
-Copyright (c) 2020 Devine Lu Linvega
4
+/*
5
+Copyright (c) 2020-2023 Devine Lu Linvega
6 6
 
7 7
 Permission to use, copy, modify, and distribute this software for any
8 8
 purpose with or without fee is hereby granted, provided that the above
... ...
@@ -23,10 +23,30 @@ clamp(int val, int min, int max)
23 23
 }
24 24
 
25 25
 int
26
-main()
26
+cinu(char c)
27 27
 {
28
-	int seg = 1024, offset = seg / 4, i;
29
-	double segf = 1024.0;
28
+	return c >= '0' && c <= '9';
29
+}
30
+
31
+int
32
+sint(char *s)
33
+{
34
+	int i = 0, num = 0;
35
+	while(s[i] && cinu(s[i]))
36
+		num = num * 10 + (s[i++] - '0');
37
+	return num;
38
+}
39
+
40
+int
41
+main(int argc, char *argv[])
42
+{
43
+	int seg = 12, offset = seg / 4, i;
44
+	double segf = (double)seg;
45
+	if(argc < 2) {
46
+		printf("usage: circle128 length\n", argc);
47
+		return 1;
48
+	}
49
+	seg = sint(argv[1]);
30 50
 	printf("%d points on a circle128:\n\n", seg);
31 51
 	for(i = 0; i < seg; ++i) {
32 52
 		double cx = 128, cy = 128, r = 128;
33 53
deleted file mode 100755
... ...
@@ -1,16 +0,0 @@
1
-#!/bin/bash
2
-
3
-echo "Formatting.."
4
-clang-format -i tables.c
5
-
6
-echo "Cleaning.."
7
-rm -f ../../bin/tables
8
-
9
-echo "Building.."
10
-mkdir -p ../../bin
11
-cc  -lm tables.c -o ../../bin/tables
12
-
13
-echo "Assembling.."
14
-../../bin/tables 
15
-
16
-echo "Done."