[cairo] Problems with gradients...

benoit.vautrin at free.fr benoit.vautrin at free.fr
Wed Apr 21 07:23:18 PDT 2004


Selon David Reveman <c99drn at cs.umu.se>:  
> On Tue, 2004-04-20 at 22:42 +0200, benoit.vautrin at free.fr wrote:  
> > Hi !   
> >    
> > Adapting a example code from David Reveman, I've made a simple test case  
> > which shows up some bugs in gradients patterns...   
> >    
[...]  
> >    
> > 3- Image backend:   
> >    
> > Gradients are beautifull but from time to time don't fill the whole  
> shape...   
> >    
> > There are other issues but I'm still trying to find simple test cases to  
> show   
> > them.   
>   
> This patch should fix problem 3.  
>   
  
It works ! Thanks...  
  
BTW, I've taken my pencil and did some math:  
When using a scaling matrix like this one:  
| sx  0 |  
| 0  sy |  
if the linear gradient coordinates are ( x1, y1, x2, y2 ), they should be  
transformed as  
  
x'1= (x1+x2)*sx/2 - dx  
x'2= (x1+x2)*sx/2 + dx  
y'1= (y1+y2)*sy/2 - dy  
y'2= (y1+y2)*sy/2 + dy  
  
with:  
dx = (x2-x1)sx(y2-y1)²sy² / ((x2-x1)²sx² + (y2-y1)²sy²)  
dy = (x2-x1)²sx²(y2-y1)sy / ((x2-x1)²sx² + (y2-y1)²sy²)  
  
Which gives x'1 = sx*x1, x'2 = sx*x2, y'1 = sy*x1 and y'2 = sy*y2 only when  
sx=sy...  
  
Bye,  
  
Ben.  
 
 
 




More information about the cairo mailing list