File: picture.cal

package info (click to toggle)
radiance 3R9%2B20080530-4
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 26,244 kB
  • ctags: 10,546
  • sloc: ansic: 105,887; csh: 3,558; tcl: 3,358; python: 875; makefile: 280; sh: 14
file content (45 lines) | stat: -rw-r--r-- 1,615 bytes parent folder | download | duplicates (3)
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
{
	Calculation of 2d picture coordinates.
	Picture is projected onto xy plane with lower left corner at origin.

	A1		- Ratio of height to width for tiles.
	A2		- Average red value for fadered or grey for fadegrey
	A3		- Average green value for fadegreen
	A4		- Average blue value for fadeblue
	A2, A3, A4	- Chroma key color for mixpict
}
					{ straight coordinates }
pic_u = Px;
pic_v = Py;
					{ picture aspect ratio }
pic_aspect = if(arg(0)-.5, arg(1), 1);
					{ compute borders for mixture }
inpic = if(and(pic_u, and(pic_v,
		if(pic_aspect-1, and(1-pic_u,pic_aspect-pic_v),
				and(1/pic_aspect-pic_u,1-pic_v) ) ) ), 1, 0);
					{ chroma-key mixing }
chroma_sum`P = A2 + A3 + A4;
chroma_tol`P = 0.02 * chroma_sum`P;
intol`P(a,b) : and(a-b+chroma_tol`P, b-a+chroma_tol`P);
ischroma`P(r,g,s) = if(FTINY-chroma_sum`P, .001-s,
		if(.001-s, -1,
		and(intol`P(r*chroma_sum`P,A2*s),intol`P(g*chroma_sum`P,A3*s))
		) );
infore(r,g,b) = if(inpic-.5, if(ischroma`P(r,g,r+g+b), 0, 1), 0);
					{ standard tiling }
tile_u = mod(pic_u,max(1,1/pic_aspect));
tile_v = mod(pic_v,max(1,pic_aspect));
					{ tiling with inversion matching }
match_u = tri(pic_u,max(1,1/pic_aspect));
match_v = tri(pic_v,max(1,pic_aspect));
					{ brick-type staggering }
stag_u = if(pic_aspect-1,
		frac(if(frac(pic_v/pic_aspect/2)-.5,pic_u,pic_u+.5)),
		mod(if(frac(pic_v/2)-.5,pic_u,pic_u+.5/pic_aspect),
			1/pic_aspect));
stag_v = tile_v;
					{ fade colors for distant viewing }
fadered(r,g,b) = fade(r, A2, T*.1);
fadegreen(r,g,b) = fade(g, A3, T*.1);
fadeblue(r,g,b) = fade(b, A4, T*.1);
fadegrey(r,g,b) = fade(grey(r,g,b), A2, T*.1);