commit 32669d211aaf775178ab951b97d3ffda0a405483
parent 457e48b1380a39fd5f37083845940c573931b97c
Author: Martin J. Klöckner <64109770+mjkloeckner@users.noreply.github.com>
Date: Thu, 22 Dec 2022 19:22:00 -0300
Merge branch 'main' into tmp
Diffstat:
6 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/README.md b/README.md
@@ -4,16 +4,16 @@ The idea is to develop a visual program that shows how an array is being sorted
Written in C using SDL2 library for graphics
-![screenshot](https://user-images.githubusercontent.com/64109770/177228195-dd10ba72-31b1-4c26-a32f-0942d945f6f8.png)
+![sav](https://user-images.githubusercontent.com/64109770/182065206-e766b30e-6f7d-4232-b1d2-de840974892d.gif)
## Dependencies
-- ![SDL2](https://www.libsdl.org/)
+- [SDL2](https://www.libsdl.org/)
+- [SDL2-ttf](https://github.com/libsdl-org/SDL_ttf/releases)
## Building and running
```console
-$ make
+$ make -j $(nproc)
$ ./sav
-
```
## Keybindings
@@ -23,5 +23,9 @@ $ ./sav
- `S` - change array shuffle method (random, in order, reversed).
- `R` - restart.
+## Font
+
+The font used is [Victor Mono Regular](https://rubjo.github.io/victor-mono/)
+
## License
[MIT](./LICENSE)
diff --git a/VictorMono-Regular.ttf b/VictorMono-Regular.ttf
Binary files differ.
diff --git a/drw.h b/drw.h
@@ -14,7 +14,7 @@
#define NORM_COLOR 0xFF000000
#define FONT_SIZE 12
-#define FONT_NAME "/home/mk/.local/share/fonts/VictorMono-Bold.ttf"
+#define FONT_NAME "VictorMono-Regular.ttf"
#define FONT_COLOR 0xBBBBBB
#define BAR_HEIGHT 15
diff --git a/main.c b/main.c
@@ -97,6 +97,7 @@ end:
if(p1 != 0) pthread_join(p1, NULL);
SAV_destroy(sav);
+
drw_destroy(drw);
return 0;
}
diff --git a/sdl_extra.c b/sdl_extra.c
@@ -13,7 +13,7 @@ status_t SDL_setup(SDL_Window **win, SDL_Renderer **rend) {
SDL_WINDOW_RESIZABLE
);
- *rend = SDL_CreateRenderer(*win, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
+ *rend = SDL_CreateRenderer(*win, -1, SDL_RENDERER_ACCELERATED);
if ((*win == NULL) || (*rend == NULL))
return ERROR_NULL_POINTER;
diff --git a/sort.c b/sort.c
@@ -172,6 +172,7 @@ void merge(SAV *sav, int low, int middle, int high) {
/* merge B and C in order */
for(k = low, i = j = 0; (k < high) && (i < n1) && (j < n2); k++) {
+ sav->cmp = middle + j;
if(B[i] <= C[j]) {
sav->arr->v[k] = B[i++];
sav->cmps += 1;
@@ -329,9 +330,11 @@ void selection_sort(SAV *sav)
min = i;
for (j = i + 1; j < sav->arr->len; j++) {
sav->sel = j;
- if (sav->arr->v[j] < sav->arr->v[min]) min = j;
+ if (sav->arr->v[j] < sav->arr->v[min]) {
+ min = j;
+ sav->cmp = min;
+ }
sav->cmps += 1;
- sav->cmp = j;
if(sort_delay(sav) == STOP) return;
if(sort_pause(sav) == STOP) return;
}