~kalon33/corsix-th/master

« back to all changes in this revision

Viewing changes to agg/include/agg_color_rgba.h

  • Committer: corsixth.bot at gmail
  • Date: 2014-03-31 23:30:23 UTC
  • Revision ID: svn-v4:c39591fa-788f-11de-a72b-d90af8dea425:trunk:2687
Remove trailing whitespaces in .h, .cpp, .c and .lua files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
// Anti-Grain Geometry - Version 2.4
3
3
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
4
4
//
5
 
// Permission to copy, use, modify, sell and distribute this software 
6
 
// is granted provided this copyright notice appears in all copies. 
 
5
// Permission to copy, use, modify, sell and distribute this software
 
6
// is granted provided this copyright notice appears in all copies.
7
7
// This software is provided "as is" without express or implied
8
8
// warranty, and with no claim as to its suitability for any purpose.
9
9
//
10
10
//----------------------------------------------------------------------------
11
11
//
12
 
// Adaptation for high precision colors has been sponsored by 
 
12
// Adaptation for high precision colors has been sponsored by
13
13
// Liberty Technology Systems, Inc., visit http://lib-sys.com
14
14
//
15
15
// Liberty Technology Systems, Inc. is the provider of
16
16
// PostScript and PDF technology for software developers.
17
 
// 
 
17
//
18
18
//----------------------------------------------------------------------------
19
19
// Contact: mcseem@antigrain.com
20
20
//          mcseemagg@yahoo.com
143
143
 
144
144
        //--------------------------------------------------------------------
145
145
        static rgba from_wavelength(double wl, double gamma = 1.0);
146
 
    
 
146
 
147
147
        //--------------------------------------------------------------------
148
148
        explicit rgba(double wavelen, double gamma=1.0)
149
149
        {
176
176
            t.r = -1.0 * (wl - 440.0) / (440.0 - 380.0);
177
177
            t.b = 1.0;
178
178
        }
179
 
        else 
 
179
        else
180
180
        if(wl >= 440.0 && wl <= 490.0)
181
181
        {
182
182
            t.g = (wl - 440.0) / (490.0 - 440.0);
218
218
 
219
219
 
220
220
 
221
 
    
 
221
 
222
222
    //===================================================================rgba8
223
223
    struct rgba8
224
224
    {
244
244
 
245
245
        //--------------------------------------------------------------------
246
246
        rgba8(unsigned r_, unsigned g_, unsigned b_, unsigned a_=base_mask) :
247
 
            r(value_type(r_)), 
248
 
            g(value_type(g_)), 
249
 
            b(value_type(b_)), 
 
247
            r(value_type(r_)),
 
248
            g(value_type(g_)),
 
249
            b(value_type(b_)),
250
250
            a(value_type(a_)) {}
251
251
 
252
252
        //--------------------------------------------------------------------
253
253
        rgba8(const rgba& c, double a_) :
254
 
            r((value_type)uround(c.r * double(base_mask))), 
255
 
            g((value_type)uround(c.g * double(base_mask))), 
256
 
            b((value_type)uround(c.b * double(base_mask))), 
 
254
            r((value_type)uround(c.r * double(base_mask))),
 
255
            g((value_type)uround(c.g * double(base_mask))),
 
256
            b((value_type)uround(c.b * double(base_mask))),
257
257
            a((value_type)uround(a_  * double(base_mask))) {}
258
258
 
259
259
        //--------------------------------------------------------------------
262
262
 
263
263
        //--------------------------------------------------------------------
264
264
        rgba8(const rgba& c) :
265
 
            r((value_type)uround(c.r * double(base_mask))), 
266
 
            g((value_type)uround(c.g * double(base_mask))), 
267
 
            b((value_type)uround(c.b * double(base_mask))), 
 
265
            r((value_type)uround(c.r * double(base_mask))),
 
266
            g((value_type)uround(c.g * double(base_mask))),
 
267
            b((value_type)uround(c.b * double(base_mask))),
268
268
            a((value_type)uround(c.a * double(base_mask))) {}
269
269
 
270
270
        //--------------------------------------------------------------------
272
272
        {
273
273
            r = g = b = a = 0;
274
274
        }
275
 
        
 
275
 
276
276
        //--------------------------------------------------------------------
277
277
        const self_type& transparent()
278
278
        {
365
365
            calc_type cr, cg, cb, ca;
366
366
            if(cover == cover_mask)
367
367
            {
368
 
                if(c.a == base_mask) 
 
368
                if(c.a == base_mask)
369
369
                {
370
370
                    *this = c;
371
371
                }
420
420
 
421
421
 
422
422
    //-------------------------------------------------------------rgba8_pre
423
 
    inline rgba8 rgba8_pre(unsigned r, unsigned g, unsigned b, 
 
423
    inline rgba8 rgba8_pre(unsigned r, unsigned g, unsigned b,
424
424
                           unsigned a = rgba8::base_mask)
425
425
    {
426
426
        return rgba8(r,g,b,a).premultiply();
503
503
 
504
504
        //--------------------------------------------------------------------
505
505
        rgba16(unsigned r_, unsigned g_, unsigned b_, unsigned a_=base_mask) :
506
 
            r(value_type(r_)), 
507
 
            g(value_type(g_)), 
508
 
            b(value_type(b_)), 
 
506
            r(value_type(r_)),
 
507
            g(value_type(g_)),
 
508
            b(value_type(b_)),
509
509
            a(value_type(a_)) {}
510
510
 
511
511
        //--------------------------------------------------------------------
514
514
 
515
515
        //--------------------------------------------------------------------
516
516
        rgba16(const rgba& c) :
517
 
            r((value_type)uround(c.r * double(base_mask))), 
518
 
            g((value_type)uround(c.g * double(base_mask))), 
519
 
            b((value_type)uround(c.b * double(base_mask))), 
 
517
            r((value_type)uround(c.r * double(base_mask))),
 
518
            g((value_type)uround(c.g * double(base_mask))),
 
519
            b((value_type)uround(c.b * double(base_mask))),
520
520
            a((value_type)uround(c.a * double(base_mask))) {}
521
521
 
522
522
        //--------------------------------------------------------------------
523
523
        rgba16(const rgba& c, double a_) :
524
 
            r((value_type)uround(c.r * double(base_mask))), 
525
 
            g((value_type)uround(c.g * double(base_mask))), 
526
 
            b((value_type)uround(c.b * double(base_mask))), 
 
524
            r((value_type)uround(c.r * double(base_mask))),
 
525
            g((value_type)uround(c.g * double(base_mask))),
 
526
            b((value_type)uround(c.b * double(base_mask))),
527
527
            a((value_type)uround(a_  * double(base_mask))) {}
528
528
 
529
529
        //--------------------------------------------------------------------
530
530
        rgba16(const rgba8& c) :
531
 
            r(value_type((value_type(c.r) << 8) | c.r)), 
532
 
            g(value_type((value_type(c.g) << 8) | c.g)), 
533
 
            b(value_type((value_type(c.b) << 8) | c.b)), 
 
531
            r(value_type((value_type(c.r) << 8) | c.r)),
 
532
            g(value_type((value_type(c.g) << 8) | c.g)),
 
533
            b(value_type((value_type(c.b) << 8) | c.b)),
534
534
            a(value_type((value_type(c.a) << 8) | c.a)) {}
535
535
 
536
536
        //--------------------------------------------------------------------
537
537
        rgba16(const rgba8& c, unsigned a_) :
538
 
            r(value_type((value_type(c.r) << 8) | c.r)), 
539
 
            g(value_type((value_type(c.g) << 8) | c.g)), 
540
 
            b(value_type((value_type(c.b) << 8) | c.b)), 
 
538
            r(value_type((value_type(c.r) << 8) | c.r)),
 
539
            g(value_type((value_type(c.g) << 8) | c.g)),
 
540
            b(value_type((value_type(c.b) << 8) | c.b)),
541
541
            a(value_type((             a_ << 8) | c.a)) {}
542
542
 
543
543
        //--------------------------------------------------------------------
545
545
        {
546
546
            r = g = b = a = 0;
547
547
        }
548
 
        
 
548
 
549
549
        //--------------------------------------------------------------------
550
550
        const self_type& transparent()
551
551
        {
638
638
            calc_type cr, cg, cb, ca;
639
639
            if(cover == cover_mask)
640
640
            {
641
 
                if(c.a == base_mask) 
 
641
                if(c.a == base_mask)
642
642
                {
643
643
                    *this = c;
644
644
                }
694
694
 
695
695
 
696
696
    //--------------------------------------------------------------rgba16_pre
697
 
    inline rgba16 rgba16_pre(unsigned r, unsigned g, unsigned b, 
 
697
    inline rgba16 rgba16_pre(unsigned r, unsigned g, unsigned b,
698
698
                             unsigned a = rgba16::base_mask)
699
699
    {
700
700
        return rgba16(r,g,b,a).premultiply();