File: docShading.c

package info (click to toggle)
ted 2.16-5
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 13,944 kB
  • ctags: 20,273
  • sloc: ansic: 167,980; makefile: 12,518; sh: 263
file content (86 lines) | stat: -rw-r--r-- 1,904 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/************************************************************************/
/*									*/
/*  Shading.								*/
/*									*/
/************************************************************************/

#   include	"tedConfig.h"

#   include	<stdlib.h>
#   include	<string.h>
#   include	<stdio.h>

#   include	<appDebugon.h>

#   include	<appUnit.h>
#   include	"docBuf.h"

/************************************************************************/
/*									*/
/*  Derive rgb values for a solidly shaded cell.			*/
/*									*/
/************************************************************************/

int docGetSolidRgbShadeOfItem(	int *			pIsSolid,
				int *			pRed,
				int *			pGreen,
				int *			pBlue,
				const BufferDocument *	bd,
				const ItemShading *	is )
    {
    const DocumentProperties *	dp= &(bd->bdProperties);

    RGB8Color			cf;
    RGB8Color			cb;

    int				fl= is->isLevel;
    int				bl= 10000- is->isLevel;

    int				r;
    int				g;
    int				b;

    cf.rgb8Red= 0;
    cf.rgb8Green= 0;
    cf.rgb8Blue= 0;

    cb.rgb8Red= 255;
    cb.rgb8Green= 255;
    cb.rgb8Blue= 255;

    if  ( is->isPattern != DOCspSOLID )
	{ LDEB(is->isPattern); return -1;	}

    if  ( is->isBackColor <= 0		&&
	  is->isForeColor <= 0		&&
	  is->isLevel == 0		)
	{ *pIsSolid= 0; return 0;	}

    if  ( is->isBackColor > 0			&&
	  is->isBackColor < dp->dpColorCount	)
	{ cb= dp->dpColors[is->isBackColor];	}

    if  ( is->isLevel > 0 )
	{
	if  ( is->isForeColor > 0			&&
	      is->isForeColor < dp->dpColorCount	)
	    { cf= dp->dpColors[is->isForeColor];	}
	}
    else{ cf= cb; }

    r= ( fl* cf.rgb8Red+ bl* cb.rgb8Red )/ 10000;
    g= ( fl* cf.rgb8Green+ bl* cb.rgb8Green )/ 10000;
    b= ( fl* cf.rgb8Blue+ bl* cb.rgb8Blue )/ 10000;

    if  ( r == 255 && g == 255 && b == 255 )
	{ *pIsSolid= 0;	}
    else{
	*pIsSolid= 1;
	*pRed= r;
	*pGreen= g;
	*pBlue= b;
	}

    return 0;
    }