💾 Archived View for sotiris.papatheodorou.xyz › works › sp.c › frames.awk captured on 2024-12-17 at 11:27:44. Gemini links have been rewritten to link to archived content
-=-=-=-=-=-=-
function max(a, b) { return a < b ? b : a }
function escape(s) { gsub("\"", "\\\"", s); gsub("\\\\", "\\\\", s); return s }
BEGIN {
print "#include <stddef.h>\n"
print "const char *frame(int id)"
print "{"
print "\tswitch (id) {"
}
!f && /^./ { f = 1; hh = 0; printf "\t\tcase %d: return \\", frames++ }
f && /^$/ { f = 0; h = max(h, hh); print ";" }
f { w = max(w, length); hh++; printf "\n\t\t\"%s\"", escape($0) }
END {
print ";"
print "\t}"
print "\treturn NULL;"
print "}\n"
print "#define FRAMES " frames
print "#define FRAME_WIDTH " w
print "#define FRAME_HEIGHT " h
}