Selaa lähdekoodia

Merge pull request #80 from tsoding/79

(#79) Update usage output
Alexey Kutepov 5 vuotta sitten
vanhempi
commit
18d78651e6
4 muutettua tiedostoa jossa 41 lisäystä ja 26 poistoa
  1. 2 2
      src/stb_image.h
  2. 33 18
      src/vodus_main.cpp
  3. 3 3
      src/vodus_video_params.cpp
  4. 3 3
      src/vodus_video_params.hpp

+ 2 - 2
src/stb_image.h

@@ -6508,7 +6508,7 @@ static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, i
    int pcount;
    STBI_NOTUSED(req_comp);
 
-   // on first frame, any non-written pixels get the background colour (non-transparent)
+   // on first frame, any non-written pixels get the background color (non-transparent)
    first_frame = 0;
    if (g->out == 0) {
       if (!stbi__gif_header(s, g, comp,0)) return 0; // stbi__g_failure_reason set by stbi__gif_header
@@ -6522,7 +6522,7 @@ static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, i
          return stbi__errpuc("outofmem", "Out of memory");
 
       // image is treated as "transparent" at the start - ie, nothing overwrites the current background;
-      // background colour is only used for pixels that are not rendered first frame, after that "background"
+      // background color is only used for pixels that are not rendered first frame, after that "background"
       // color refers to the color that was there the previous frame.
       memset(g->out, 0x00, 4 * pcount);
       memset(g->background, 0x00, 4 * pcount); // state of the background (starts transparent)

+ 33 - 18
src/vodus_main.cpp

@@ -76,27 +76,27 @@ void render_message(Image32 surface, FT_Face face,
     slap_text_onto_image32_wrapped(surface,
                                    face,
                                    message.nickname,
-                                   params.nickname_colour,
+                                   params.nickname_color,
                                    x, y,
                                    params.font_size);
 
 
     auto text = message.message.trim();
-    auto text_colour = params.text_colour;
+    auto text_color = params.text_color;
     const char *nick_text_sep = ": ";
 
     const auto slash_me = "/me"_sv;
 
     if (text.has_prefix(slash_me)) {
         text.chop(slash_me.count);
-        text_colour = params.nickname_colour;
+        text_color = params.nickname_color;
         nick_text_sep = " ";
     }
 
     slap_text_onto_image32_wrapped(surface,
                                    face,
                                    nick_text_sep,
-                                   params.nickname_colour,
+                                   params.nickname_color,
                                    x, y,
                                    params.font_size);
 
@@ -125,7 +125,7 @@ void render_message(Image32 surface, FT_Face face,
             slap_text_onto_image32_wrapped(surface,
                                            face,
                                            word,
-                                           text_colour,
+                                           text_color,
                                            x, y,
                                            params.font_size);
         }
@@ -133,7 +133,7 @@ void render_message(Image32 surface, FT_Face face,
         slap_text_onto_image32_wrapped(surface,
                                        face,
                                        " ",
-                                       text_colour,
+                                       text_color,
                                        x, y,
                                        params.font_size);
     }
@@ -348,7 +348,7 @@ void sample_chat_log_animation(FT_Face face,
 
         message_cooldown -= VODUS_DELTA_TIME_SEC;
 
-        fill_image32_with_color(surface, params.background_colour);
+        fill_image32_with_color(surface, params.background_color);
         h = message_entry_buffer.render(surface, face, emote_cache, params);
         encoder->encode_frame(surface, frame_index);
 
@@ -360,7 +360,7 @@ void sample_chat_log_animation(FT_Face face,
     }
 
     for (size_t i = 0; i < TRAILING_BUFFER_SEC * params.fps; ++i, ++frame_index) {
-        fill_image32_with_color(surface, params.background_colour);
+        fill_image32_with_color(surface, params.background_color);
         message_entry_buffer.render(surface, face, emote_cache, params);
 
         emote_cache->update_gifs(VODUS_DELTA_TIME_SEC);
@@ -425,10 +425,25 @@ void usage(FILE *stream)
 {
     // TODO(#79): usage output is outdated
     println(stream, "Usage: vodus [OPTIONS] <log-filepath>");
-    println(stream, "    --help|-h                 Display this help and exit");
-    println(stream, "    --output|-o <filepath>    Output path");
-    println(stream, "    --font <filepath>         Path to the Font face file");
-    println(stream, "    --limit <number>          Limit the amout of messages to render");
+    println(stream, "    --help|-h                       Display this help and exit");
+    println(stream, "    --output|-o <filepath>          Output path");
+    println(stream, "    --font <filepath>               Path to the Font face file");
+    println(stream, "    --font-size <number>            The size of the Font face");
+    println(stream, "    --limit <number>                Limit the amount of messages to render");
+    println(stream, "    --width <number>                Width of the output video");
+    println(stream, "    --height <number>               Height of the output video");
+    println(stream, "    --fps <number>                  Frames per second of the output video");
+    println(stream, "    --background-color <color-hex>  Color of the background");
+    println(stream, "    --nickname-color <color-hex>    Color of the nickname part of the rendered message");
+    println(stream, "    --text-color <color-hex>        Color of the text part of the rendered message");
+    println(stream, "    --bitrate <number>              The average bitrate in bits/s (probably, libavcodec\n"
+                    "                                    didn't really tell me the exact units)");
+    println(stream, "  Values:");
+    println(stream, "    <filepath>                      Path to a file according to the platform format");
+    println(stream, "    <number>                        Positive integer");
+    println(stream, "    <color-hex>                     8 hex characters digits describing RGBA.\n"
+                    "                                    Case insensitive. No leading # character.\n"
+                    "                                    Examples: ffffffff, 000000FF, A0eA0000");
 }
 
 Maybe<Pixel32> hexstr_as_pixel32(String_View hexstr)
@@ -455,9 +470,9 @@ int main(int argc, char *argv[])
     params.width             = 1920;
     params.height            = 1080;
     params.font_size         = 128;
-    params.background_colour = {32, 32, 32, 255};
-    params.nickname_colour   = {255, 100, 100, 255};
-    params.text_colour       = {200, 200, 200, 255};
+    params.background_color = {32, 32, 32, 255};
+    params.nickname_color   = {255, 100, 100, 255};
+    params.text_color       = {200, 200, 200, 255};
     params.bitrate           = 400'000;
 
     for (int i = 1; i < argc;) {
@@ -524,11 +539,11 @@ int main(int argc, char *argv[])
         } else if (arg == "--font-size"_sv) {
             INTEGER_PARAMETER(size_t, params.font_size);
         } else if (arg == "--background-color"_sv) {
-            COLOR_PARAMETER(params.background_colour);
+            COLOR_PARAMETER(params.background_color);
         } else if (arg == "--nickname-color"_sv) {
-            COLOR_PARAMETER(params.nickname_colour);
+            COLOR_PARAMETER(params.nickname_color);
         } else if (arg == "--text-color"_sv) {
-            COLOR_PARAMETER(params.text_colour);
+            COLOR_PARAMETER(params.text_color);
         } else if (arg == "--bitrate"_sv) {
             INTEGER_PARAMETER(int, params.bitrate);
         } else if (arg.has_prefix("-"_sv)) {

+ 3 - 3
src/vodus_video_params.cpp

@@ -7,9 +7,9 @@ void print1(FILE *stream, Video_Params params)
     println(stream, "    .width = ", params.width, ",");
     println(stream, "    .height = ", params.height, ",");
     println(stream, "    .font_size = ", params.font_size, ",");
-    println(stream, "    .background_colour = ", params.background_colour, ",");
-    println(stream, "    .nickname_colour = ", params.nickname_colour, ",");
-    println(stream, "    .text_colour = ", params.text_colour, ",");
+    println(stream, "    .background_color = ", params.background_color, ",");
+    println(stream, "    .nickname_color = ", params.nickname_color, ",");
+    println(stream, "    .text_color = ", params.text_color, ",");
     println(stream, "    .bitrate = ", params.bitrate, ",");
     print(stream, "}");
 }

+ 3 - 3
src/vodus_video_params.hpp

@@ -7,9 +7,9 @@ struct Video_Params
     size_t width;
     size_t height;
     size_t font_size;
-    Pixel32 background_colour;
-    Pixel32 nickname_colour;
-    Pixel32 text_colour;
+    Pixel32 background_color;
+    Pixel32 nickname_color;
+    Pixel32 text_color;
     int bitrate;
 };