From: Tony Cook Date: Fri, 27 Mar 2020 06:30:00 +0000 (+1100) Subject: add red, green, blue, alpha methods to color objects X-Git-Url: http://git.imager.perl.org/imager.git/commitdiff_plain/0231b97e3ae75091f348ab79775b16802ccf2b40 add red, green, blue, alpha methods to color objects --- diff --git a/Imager.xs b/Imager.xs index 4bd58b61..9e492986 100644 --- a/Imager.xs +++ b/Imager.xs @@ -1137,6 +1137,16 @@ typedef int SysRet; /* avoid some xsubpp strangeness */ #define NEWLINE '\n' +#define ICL_red(c) ((c)->rgba.r) +#define ICL_green(c) ((c)->rgba.g) +#define ICL_blue(c) ((c)->rgba.b) +#define ICL_alpha(c) ((c)->rgba.a) + +#define ICLF_red(c) ((c)->rgba.r) +#define ICLF_green(c) ((c)->rgba.g) +#define ICLF_blue(c) ((c)->rgba.b) +#define ICLF_alpha(c) ((c)->rgba.a) + MODULE = Imager PACKAGE = Imager::Color PREFIX = ICL_ Imager::Color @@ -1201,7 +1211,21 @@ i_rgb_to_hsv(c) OUTPUT: RETVAL +int +ICL_red(c) + Imager::Color c + +int +ICL_green(c) + Imager::Color c + +int +ICL_blue(c) + Imager::Color c +int +ICL_alpha(c) + Imager::Color c MODULE = Imager PACKAGE = Imager::Color::Float PREFIX=ICLF_ @@ -1263,6 +1287,22 @@ i_rgb_to_hsv(c) OUTPUT: RETVAL +double +ICLF_red(c) + Imager::Color::Float c + +double +ICLF_green(c) + Imager::Color::Float c + +double +ICLF_blue(c) + Imager::Color::Float c + +double +ICLF_alpha(c) + Imager::Color::Float c + MODULE = Imager PACKAGE = Imager::ImgRaw PREFIX = IIM_ Imager::ImgRaw diff --git a/lib/Imager/Color.pm b/lib/Imager/Color.pm index f2bd30d6..70336f87 100644 --- a/lib/Imager/Color.pm +++ b/lib/Imager/Color.pm @@ -4,7 +4,7 @@ use Imager; use strict; use vars qw($VERSION); -$VERSION = "1.012"; +$VERSION = "1.013"; # It's just a front end to the XS creation functions. @@ -684,6 +684,16 @@ set() method. Returns the color as a Hue/Saturation/Value/Alpha tuple. +=item red + +=item green + +=item blue + +=item alpha + +Returns the respective component as an integer from 0 to 255. + =back =head1 AUTHOR diff --git a/lib/Imager/Color/Float.pm b/lib/Imager/Color/Float.pm index def4192b..24f0426a 100644 --- a/lib/Imager/Color/Float.pm +++ b/lib/Imager/Color/Float.pm @@ -4,7 +4,7 @@ use Imager; use strict; use vars qw($VERSION); -$VERSION = "1.005"; +$VERSION = "1.006"; # It's just a front end to the XS creation functions. @@ -111,6 +111,17 @@ object contains. Calling info merely dumps the relevant color to the log. +=item red + +=item green + +=item blue + +=item alpha + +Returns the respective component as a floating point value typically +from 0 to 1.0. + =back =head1 AUTHOR