This demo shows a couple of uses of bitmap images as masks. You can use them either as textures for images or as the mask for another texture (the face on the left is used as a mask for a blue and yellow grating).

To work the demo needs a square image called face.jpg (e.g. this one)

from psychopy import core, visual, event

#create a window to draw in
myWin = visual.Window((600,600), allowGUI=False, rgb=(-1,-1,-1))

#INITIALISE SOME STIMULI
faceRGB = visual.AlphaStim(myWin,tex='face.jpg',
    mask=None,
    rgb=[1.0,-1.0,1.0],
    pos=(0.0,0.0),
    size=(1.0,1.0),
    sf=(1.0, 1.0))
faceALPHA = visual.AlphaStim(myWin,pos=(-0.5,0),
    tex="sin",mask="face.jpg",
    rgb=[1.0,1.0,-1.0],
    size=(0.5,0.5), sf=1.0, units="norm")
message = visual.TextStim(myWin,pos=(-0.95,-0.90),
    text='Hit Q to quit', rgb=1)

t=lastFPSupdate=0
framePeriod=1.0/60.0
while True:
    t=t+framePeriod
    faceRGB.setOri(1,'+')#advance ori by 1 degree
    faceRGB.draw()

    faceALPHA.setPhase(0.01,"+")#advance phase by 1/100th of a cycle
    faceALPHA.draw()

    message.draw()

    myWin.flip()

    #handle key presses each frame
    for keys in event.getKeys():
        if keys in ['escape','q']:
            core.quit()
    event.clearEvents()
Valid XHTML 1.0! Valid CSS!