Updating the changelog in the VERSION file, and version_sync.
[shapes.git] / source / concretecolors.h
blob5334a613a82eed659a5e350c89e4fbd9690e5bfc
1 /* This file is part of Shapes.
3 * Shapes is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * any later version.
8 * Shapes is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with Shapes. If not, see <http://www.gnu.org/licenses/>.
16 * Copyright 2008 Henrik Tidefelt
19 #pragma once
21 #include "Shapes_Ast_decls.h"
23 #include "pdfstructure.h"
24 #include "refcount.h"
26 #include <iostream>
29 namespace Shapes
31 namespace Concrete
34 class Gray
36 public:
37 double gr_;
38 Gray( double gr ) : gr_( gr ) { }
40 void setStroking( std::ostream & os ) const;
41 void setNonStroking( std::ostream & os ) const;
42 RefCountPtr< SimplePDF::PDF_Vector > componentVector( ) const;
44 Concrete::Gray add( const Concrete::Gray & col2, const Ast::SourceLocation & callLoc ) const;
45 Concrete::Gray mul( double factor, const Ast::SourceLocation & factorLoc ) const;
46 Concrete::Gray addNoCheck( const Concrete::Gray & col2 ) const
48 return Concrete::Gray( gr_ + col2.gr_ );
50 Concrete::Gray mulNoCheck( double factor ) const
52 return Concrete::Gray( factor * gr_ );
56 class RGB
58 public:
59 double r_;
60 double g_;
61 double b_;
62 RGB( double r, double g, double b ) : r_( r ), g_( g ), b_( b ) { }
64 void setStroking( std::ostream & os ) const;
65 void setNonStroking( std::ostream & os ) const;
66 RefCountPtr< SimplePDF::PDF_Vector > componentVector( ) const;
68 Concrete::RGB add( const Concrete::RGB & col2, const Ast::SourceLocation & callLoc ) const;
69 Concrete::RGB mul( double factor, const Ast::SourceLocation & factorLoc ) const;
70 Concrete::RGB addNoCheck( const Concrete::RGB & col2 ) const
72 return Concrete::RGB( r_ + col2.r_, g_ + col2.g_, b_ + col2.b_ );
74 Concrete::RGB mulNoCheck( double factor ) const
76 return Concrete::RGB( factor * r_, factor * g_, factor * b_ );
79 double mean( ) const { return (1./3) * ( r_ + g_ + b_ ); }
82 class CMYK
84 public:
85 double c_;
86 double m_;
87 double y_;
88 double k_;
89 CMYK( double c, double m, double y, double k ) : c_( c ), m_( m ), y_( y ), k_( k ) { }
91 void setStroking( std::ostream & os ) const;
92 void setNonStroking( std::ostream & os ) const;
93 RefCountPtr< SimplePDF::PDF_Vector > componentVector( ) const;
95 CMYK add( const CMYK & col2, const Ast::SourceLocation & callLoc ) const;
96 CMYK mul( double factor, const Ast::SourceLocation & factorLoc ) const;
97 CMYK addNoCheck( const CMYK & col2 ) const
99 return CMYK( c_ + col2.c_, m_ + col2.m_, y_ + col2.y_, k_ + col2.k_ );
101 CMYK mulNoCheck( double factor ) const
103 return CMYK( factor * c_, factor * m_, factor * y_, factor * k_ );