Skip to content

Commit

Permalink
feat: 0.4.5 Add init_s4c_color_pair_ex() to pass a background color i…
Browse files Browse the repository at this point in the history
…ndex (#94)

- Bump s4c-scripts to 0.1.1
  • Loading branch information
jgabaut authored May 6, 2024
1 parent ae4e8e9 commit 59962e4
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 12 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
C 2 107 348 606
C/C++ Header 2 45 50 158
C 2 114 380 644
C/C++ Header 2 47 50 167
-------------------------------------------------------------------------------
SUM: 4 152 398 764
SUM: 4 161 430 811
-------------------------------------------------------------------------------
```

Expand Down
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Define the package name and version
AC_INIT([sprites4curses], [0.4.4], [jgabaut@github.com])
AC_INIT([sprites4curses], [0.4.5], [jgabaut@github.com])

# Verify automake version and enable foreign option
AM_INIT_AUTOMAKE([foreign -Wall])
Expand Down Expand Up @@ -83,7 +83,7 @@ AM_CONDITIONAL([LINUX_BUILD], [test "$build_linux" = "yes"])
# Set a default version number if not specified externally
AC_ARG_VAR([VERSION], [Version number])
if test -z "$VERSION"; then
VERSION="0.4.4"
VERSION="0.4.5"
fi

# Output variables to the config.h header
Expand Down
2 changes: 1 addition & 1 deletion documentation/s4c.doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ PROJECT_NAME = "sprites4curses"
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = "0.4.4"
PROJECT_NUMBER = "0.4.5"

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
30 changes: 27 additions & 3 deletions s4c-animate/animate.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// jgabaut @ github.com/jgabaut
// SPDX-License-Identifier: GPL-3.0-only
/*
Copyright (C) 2023 jgabaut
Copyright (C) 2023-2024 jgabaut
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -117,8 +117,9 @@ S4C_Sprite s4c_new_sprite(char data[][MAXCOLS], int frameheight, int framewidth,
* Initialises a color pair from a passed S4C_Color pointer.
* @param palette The S4C_Color pointer array at hand.
* @param color_index The resulting color index for defined colorpair.
* @param bg_color_index The color index for background color of defined colorpair. Typical values are 0 or, only after use_default_colors(), -1.
*/
void init_s4c_color_pair(S4C_Color* color, int color_index) {
void init_s4c_color_pair_ex(S4C_Color* color, int color_index, int bg_color_index) {

if (color == NULL) {
fprintf(stderr,"Error: invalid S4C_Color at %s().",__func__);
Expand All @@ -137,8 +138,31 @@ void init_s4c_color_pair(S4C_Color* color, int color_index) {
int proportional_g = (((float)g + 1.0) / 256)*1000;
int proportional_b = (((float)b + 1.0) / 256)*1000;
init_color(color_index, proportional_r, proportional_g, proportional_b);
init_pair(color_index, color_index, 0);
init_pair(color_index, color_index, bg_color_index);
}

/**
* Initialises a color pair from a passed S4C_Color pointer.
* The background color index for the defined color pair is 0.
* @param palette The S4C_Color pointer array at hand.
* @param color_index The resulting color index for defined colorpair.
*/
void init_s4c_color_pair(S4C_Color* color, int color_index) {
init_s4c_color_pair_ex(color, color_index, 0);
}

/**
* Initialises a color pair from a passed S4C_Color pointer.
* It sets the background color index for the pair to -1.
* This is useless to any curses implementation that does not support use_default_colors().
* In that case, plain init_s4c_color_pair() should be used.
* @param palette The S4C_Color pointer array at hand.
* @param color_index The resulting color index for defined colorpair.
*/
void init_s4c_color_pair_default_bg(S4C_Color* color, int color_index) {
init_s4c_color_pair_ex(color, color_index, -1);
}

#endif

const char* s4c_color_strings[S4C_MAX_COLOR_INDEX+1] = {
Expand Down
8 changes: 5 additions & 3 deletions s4c-animate/animate.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// jgabaut @ github.com/jgabaut
// SPDX-License-Identifier: GPL-3.0-only
/*
Copyright (C) 2023 jgabaut
Copyright (C) 2023-2024 jgabaut
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -35,10 +35,10 @@
#endif // S4C_RAYLIB_EXTENSION


#define S4C_ANIMATE_VERSION "0.4.4"
#define S4C_ANIMATE_VERSION "0.4.5"
#define S4C_ANIMATE_MAJOR_VERSION 0
#define S4C_ANIMATE_MINOR_VERSION 4
#define S4C_ANIMATE_PATCH_VERSION 4
#define S4C_ANIMATE_PATCH_VERSION 5

#define S4C_MAJOR S4C_ANIMATE_MAJOR_VERSION
#define S4C_MINOR S4C_ANIMATE_MINOR_VERSION
Expand Down Expand Up @@ -191,7 +191,9 @@ typedef struct animate_args {

void init_s4c_color_pairs(FILE* palette_file);

void init_s4c_color_pair_ex(S4C_Color* color, int color_index, int bg_color_index);
void init_s4c_color_pair(S4C_Color* color, int color_index);
void init_s4c_color_pair_default_bg(S4C_Color* color, int color_index);

void test_s4c_color_pairs(WINDOW* win);

Expand Down

0 comments on commit 59962e4

Please sign in to comment.