diff options
| author | iceyrazor <iceyrazor@mailfence.com> | 2026-03-13 20:25:06 -0500 |
|---|---|---|
| committer | iceyrazor <iceyrazor@mailfence.com> | 2026-03-13 20:25:06 -0500 |
| commit | d8d1ab660b2dc0e6d9d41d80c2f869a918f0aa9e (patch) | |
| tree | c08d5002c63b3050f8d71f8477f04b5dd6ce5bad | |
| parent | 801c119f1f44ea7509e705af416ecb23e5167e28 (diff) | |
project restructure
- created build.sh
- changed window name
- font is now definition
- readme change
| -rw-r--r-- | .gitignore | 2 | ||||
| -rwxr-xr-x | Makefile | 7 | ||||
| -rw-r--r-- | README | 5 | ||||
| -rw-r--r-- | README.md | 12 | ||||
| -rwxr-xr-x | build.sh | 19 | ||||
| -rwxr-xr-x | src/main.c (renamed from main.c) | 10 |
6 files changed, 36 insertions, 19 deletions
@@ -1,2 +1,2 @@ paladins.ttf -ascii +bin/** diff --git a/Makefile b/Makefile deleted file mode 100755 index f8c88d3..0000000 --- a/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -LIB= - -main: main.c - gcc -o ascii main.c -lSDL2 `sdl2-config --cflags --libs` -lSDL2_ttf -lSDL2_image -lm ${LIB} - -debug: main.c - gcc -o ascii main.c -lSDL2 `sdl2-config --cflags --libs` -lSDL2_ttf -lSDL2_image -lm ${LIB} -g -fsanitize=address @@ -1,5 +0,0 @@ -Makes ASCII from text using SDL2. Do --help for help - -Just a little project i wanted to make because ascii is cool. No plans to optimize this. It works fine. There're are definitely better terminal only based ones. - -You need to download the paladins.ttf font and put it in the same directory as this executable. Yes I'm lazy. diff --git a/README.md b/README.md new file mode 100644 index 0000000..49d948b --- /dev/null +++ b/README.md @@ -0,0 +1,12 @@ +# ascii + +Makes ASCII from text using SDL2. Do `bin/ascii --help` for help + +Just a little project i wanted to make because ascii is cool. There are definitely better terminal only based ones. + +# requirements + +- clang +- sdl2 +- sdl2_ttf +- sdl2_image diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..10eeb23 --- /dev/null +++ b/build.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +DEBUG="" +LIB="-lSDL2_gfx -lSDL2_ttf -lSDL2_image" + +[ ! -d "bin" ] && mkdir bin + +while getopts "d" opt; do + case "$opt" in + d) DEBUG="-Wall -fsanitize=address -g" + ;; + esac +done + +shift $((OPTIND-1)) +[ "${1:-}" = "--" ] && shift + +printf "\n\nmaking project\n" +clang -o "bin/ascii" src/main.c $LIB `sdl2-config --cflags --libs` -lm $DEBUG @@ -1,6 +1,3 @@ -#include <SDL2/SDL_pixels.h> -#include <SDL2/SDL_render.h> -#include <SDL2/SDL_stdinc.h> #include <stdio.h> #include <string.h> #include <stdlib.h> @@ -12,6 +9,7 @@ #include <SDL2/SDL_image.h> #include <SDL2/SDL_ttf.h> +#define conf_font "/usr/share/fonts/TTF/Inconsolata-Regular.ttf" float map(float value, float start1, float stop1, float start2, float stop2){ @@ -199,7 +197,7 @@ void draw(SDL_Renderer* renderer,SDL_Window* window, uint32_t pix_format,TTF_Fon //textRect2->w = textRect2->h = 10; - + SDL_Texture *textllure; textllure=IMG_LoadTexture(renderer,parsed_args->file); @@ -328,7 +326,7 @@ int main(int argc, char *argv[]) - SDL_Window *window = SDL_CreateWindow("SDL Tutorial", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, parsed_args.width, parsed_args.height, SDL_WINDOW_SHOWN); + SDL_Window *window = SDL_CreateWindow("SDL Ascii", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, parsed_args.width, parsed_args.height, SDL_WINDOW_SHOWN); if (!window) { printf("Failed to create window: %s\n", SDL_GetError()); } @@ -340,7 +338,7 @@ int main(int argc, char *argv[]) uint32_t wnd_pix_fmt = SDL_GetWindowPixelFormat(window); - TTF_Font *font = TTF_OpenFont("/usr/share/fonts/TTF/Inconsolata-Regular.ttf",parsed_args.char_size); + TTF_Font *font = TTF_OpenFont(conf_font,parsed_args.char_size); draw(renderer,window,wnd_pix_fmt,font,&parsed_args); |
