Skip to content

Commit

Permalink
Move _color_from_obj definition
Browse files Browse the repository at this point in the history
  • Loading branch information
Temmie3754 committed Oct 25, 2024
1 parent 0eae228 commit 9e9aaaa
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions src_c/transform.c
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,32 @@ surf_rotate(PyObject *self, PyObject *args, PyObject *kwargs)
return (PyObject *)pgSurface_New(newsurf);
}

/* _color_from_obj gets a color from a python object.
Returns 0 if ok, and sets color to the color.
-1 means error.
If color_obj is NULL, use rgba_default.
If rgba_default is NULL, do not use a default color, return -1.
*/
int
_color_from_obj(PyObject *color_obj, SDL_Surface *surf, Uint8 rgba_default[4],
Uint32 *color)
{
if (color_obj) {
if (!pg_MappedColorFromObj(color_obj, surf, color,
PG_COLOR_HANDLE_ALL)) {
return -1;
}
}
else {
if (!rgba_default)
return -1;
*color = SDL_MapRGBA(surf->format, rgba_default[0], rgba_default[1],
rgba_default[2], rgba_default[3]);
}
return 0;
}

static PG_INLINE int
_check_inside(SDL_Surface *surf, SDL_Point p)
{
Expand Down Expand Up @@ -2269,32 +2295,6 @@ get_threshold(SDL_Surface *dest_surf, SDL_Surface *surf,
return similar;
}

/* _color_from_obj gets a color from a python object.
Returns 0 if ok, and sets color to the color.
-1 means error.
If color_obj is NULL, use rgba_default.
If rgba_default is NULL, do not use a default color, return -1.
*/
int
_color_from_obj(PyObject *color_obj, SDL_Surface *surf, Uint8 rgba_default[4],
Uint32 *color)
{
if (color_obj) {
if (!pg_MappedColorFromObj(color_obj, surf, color,
PG_COLOR_HANDLE_ALL)) {
return -1;
}
}
else {
if (!rgba_default)
return -1;
*color = SDL_MapRGBA(surf->format, rgba_default[0], rgba_default[1],
rgba_default[2], rgba_default[3]);
}
return 0;
}

static PyObject *
surf_threshold(PyObject *self, PyObject *args, PyObject *kwds)
{
Expand Down

0 comments on commit 9e9aaaa

Please sign in to comment.