1 /**************************************************************************/
2 /*  Copyright 2009 Tim Day                                                */
3 /*                                                                        */
4 /*  This file is part of Fracplanet                                       */
5 /*                                                                        */
6 /*  Fracplanet is free software: you can redistribute it and/or modify    */
7 /*  it under the terms of the GNU General Public License as published by  */
8 /*  the Free Software Foundation, either version 3 of the License, or     */
9 /*  (at your option) any later version.                                   */
10 /*                                                                        */
11 /*  Fracplanet is distributed in the hope that it will be useful,         */
12 /*  but WITHOUT ANY WARRANTY; without even the implied warranty of        */
13 /*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         */
14 /*  GNU General Public License for more details.                          */
15 /*                                                                        */
16 /*  You should have received a copy of the GNU General Public License     */
17 /*  along with Fracplanet.  If not, see <http://www.gnu.org/licenses/>.   */
18 /**************************************************************************/
19 
20 /*! \file
21   \brief Implementation for class ByteRGBA and class FloatRGBA.
22 */
23 
24 #include "rgb.h"
25 
write(std::ostream & out) const26 std::ostream& ByteRGBA::write(std::ostream& out) const
27 {
28   return out << static_cast<uint>(r) << " " << static_cast<uint>(g) << " " << static_cast<uint>(b) << " " << static_cast<uint>(a);
29 }
30 
format_comma() const31 const std::string ByteRGBA::format_comma() const
32 {
33   std::ostringstream s;
34   s << static_cast<uint>(r) << "," << static_cast<uint>(g) << "," << static_cast<uint>(b) << "," << static_cast<uint>(a);
35   return s.str();
36 }
37 
write(std::ostream & out) const38 std::ostream& FloatRGBA::write(std::ostream& out) const
39 {
40   return out << r << " " << g << " " << b << " " << a;
41 }
42 
format_pov_rgb() const43 const std::string FloatRGBA::format_pov_rgb() const
44 {
45   std::ostringstream s;
46   s << "<" << r << "," << g << "," << b << ">";
47   return s.str();
48 }
49 
format_pov_rgbf() const50 const std::string FloatRGBA::format_pov_rgbf() const
51 {
52   std::ostringstream s;
53   s << "<" << r << "," << g << "," << b << "," << 1.0f-a << ">";
54   return s.str();
55 }
56