Alpha blending for mixtures with Screen('FillRect')

I'd like to create a visual stimulus that is a mixture of two components, each of which is created using the Screen('FillRect', ...) command. The alpha-blending strategies suggested in BubbleDemo.m for example, seems like a reasonable approach, but I can't get it to work. In particular, I can't get the mixing weights to apply to an image drawn with Screen('FillRect', ...) rather than Screen('DrawTexture', ...). For example, exchanging the relevant Screen('DrawTexture', ...) commands in the SimpleImageMixingDemo.m (lines 127 and 131 in my version of PTB) with Screen('FillRect', ...) commands does not work.

I've also tried the strategies used in both BubbleDemo.m and ImageMixingTutorial.m, but neither seems to work. Is it possible to use alpha-blending to mix two rectangles drawn via Screen('FillRect', ...) rather than Screen('DrawTexture', ...)?

To be clear, I know that I can mix two rectangles by specifying their alpha-values directly in the Screen('FillRect', ...) command. This would work if the two objects are in the same spatial location on the screen and if the alpha value was constant across the entire rectangle. But I would like to use the alpha blending to specify a spatial arrangement of the components, i.e., one will only be at one location and the other will be at another location. Furthermore, the location of each component will change over time. So I'd really like to be able to specify the alpha-mask texture as an arbitrary matrix, whose elements select which rectangles are in which location on the screen.
Hi, 

I think I am facing the same issue. Although there are many ways to display our stimuli, I would like to simply switch from drawtexture to fillrect in my code as (the following code is based on ImageMixingTutorial.m)

for ll = 1 : MaskMotion
% Draw the mask
      
            Screen('BlendFunction', number, GL_ONE, GL_ZERO, [0 0 0 1]); 
            Screen('FillOval', number, [0 0 0 0], Tab(ll).Rect); 

%  Draw peripheral image

            Screen('BlendFunction', number, GL_DST_ALPHA, GL_ZERO, [1 1 1 0]);
            Screen('DrawTexture', number, ImageTexture1,  [] ,  []);

% Draw foveated imag,

            Screen('BlendFunction', number, GL_ONE_MINUS_DST_ALPHA, GL_ONE, [1 1 1 0]);

             if Condition1 %image to be displayed
                   Screen('DrawTexture', number, ImageTexture2,   [] ,  []);
              elseif Condition2 % simple color to be displayed instead
                    Screen('FillRect', number, [R G B]);
              end 

If condition 1 is called here, the blending function works fine (see image 2 through an apperture/mask, but if condition 2 is called, the fillrect fills the all screen, so I guess that fillrect dosn't obey 'blendfunction'.

I worked around this issue writing condition 2 as:
          elseif Condtion2 % simple color to be displayed instead
                     MyRectBack = cat(3, R, G, B);
                     rectText = Screen('MakeTexture', number, MyRectBack);     
                      Screen('DrawTexture', number,rectText , [] , []);
              end 

It works fine, but it is still slower than fillrect (x10 slower) and I wonder why fillrect does not obey blendfunction? I checked the C code and isn't it supposed to do so?

Best regards 
 

Romain
Quick update,
it might be a bug since the previous code works fine if I call 'FillOval' or FillPoly instead od 'FillRect'


Romain