Yes, fair point about being constant within an element. The below is somewhat inelegant but would seem to work more completely:
import numpy as np
import psychopy.visual
import psychopy.event
import pyglet.gl
bg_col = -1.0
win = psychopy.visual.Window(
size=[400, 400],
units="pix",
color=[bg_col] * 3,
fullscr=False
)
n_dots = 500
dots = psychopy.visual.ElementArrayStim(
win=win,
nElements=n_dots,
xys=np.random.uniform(-120, 120, (n_dots, 2)),
units="pix",
sizes=5.0,
elementTex=None,
elementMask="circle"
)
mask_tex = psychopy.visual.GratingStim(
win=win,
tex=np.ones([256, 256]) * bg_col,
mask="gauss",
units="pix",
size=[256, 256]
)
dots.draw()
pyglet.gl.glBlendFunc(
pyglet.gl.GL_ONE_MINUS_SRC_ALPHA,
pyglet.gl.GL_SRC_ALPHA
)
mask_tex.draw()
pyglet.gl.glBlendFunc(
pyglet.gl.GL_SRC_ALPHA,
pyglet.gl.GL_ONE_MINUS_SRC_ALPHA
)
win.flip()
psychopy.event.waitKeys()
win.close()