]> git.imager.perl.org - imager.git/commitdiff
add red, green, blue, alpha methods to color objects
authorTony Cook <tony@develop-help.com>
Fri, 27 Mar 2020 06:30:00 +0000 (17:30 +1100)
committerTony Cook <tony@develop-help.com>
Fri, 27 Mar 2020 06:30:00 +0000 (17:30 +1100)
Imager.xs
lib/Imager/Color.pm
lib/Imager/Color/Float.pm

index 4bd58b61f47b7156ee2e34be72fae485c9e5b961..9e492986388a70282e6d108bc805d0665ce2469c 100644 (file)
--- 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
index f2bd30d61c21b6d45cc68a4815375f998b5cbf2b..70336f87032d706d5f33ea36c4db0f67640a0f63 100644 (file)
@@ -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
index def4192b0a827bfdb4365cf6cd6ca416035a08fc..24f0426a595274e93d7594c045328ff46ad67835 100644 (file)
@@ -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