[cairo-commit] cairo/src cairo_pattern.c,1.6,1.7
David Reveman
commit at pdx.freedesktop.org
Tue May 4 04:01:21 PDT 2004
Committed by: davidr
Update of /cvs/cairo/cairo/src
In directory pdx:/tmp/cvs-serv3596/src
Modified Files:
cairo_pattern.c
Log Message:
Corrected some confusing comments about the math used for radial gradients
Index: cairo_pattern.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_pattern.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** a/cairo_pattern.c 30 Apr 2004 03:26:56 -0000 1.6
--- b/cairo_pattern.c 4 May 2004 11:01:18 -0000 1.7
***************
*** 621,638 ****
factor = (sqrt (ex * ex + ey * ey) - r0) * r1;
} else {
! /* Here we need to calulate distance c0 -> x; the distance from
! the inner circle center c0, through point (ex, ey) to
! point x where it crosses the outer circle. The gradient offset
! can then be calculated within the distance of the inner and
! outer circles.
!
! y y_x (ex, ey)
c0 -------------------+---------- x
\ | __--
\ | __--
! r0 \ | c1_y __--
\ | __-- r1
\ | __--
c1 --
*/
--- 621,646 ----
factor = (sqrt (ex * ex + ey * ey) - r0) * r1;
} else {
! /*
! y (ex, ey)
c0 -------------------+---------- x
\ | __--
\ | __--
! \ | __--
\ | __-- r1
\ | __--
c1 --
+
+ We need to calulate distance c0->x; the distance from
+ the inner circle center c0, through fragment position
+ (ex, ey) to point x where it crosses the outer circle.
+
+ From points c0, c1 and (ex, ey) we get angle C0. With
+ angle C0 we calculate distance c1->y and c0->y and by
+ knowing c1->y and r1, we also know y->x. Adding y->x to
+ c0->y gives us c0->x. The gradient offset can then be
+ calculated as:
+
+ offset = (c0->e - r0) / (c0->x - r0)
+
*/
More information about the cairo-commit
mailing list