Drawing diamond shapes

FillPoly is one way, indeed you need one call per shape. “Compute intense” is relative, for something simple as a diamond square with four corners / vertices, it is negligible. Also, for convex shapes like these, one can set the optional ‘isConvex’ flag to tell the function, so it can save a lot of computations normally needed for convexity checks and processing of non-convex shapes. But you do that already.

Another way would be ‘FillRect’, but applying a rotation transform, cfe. DrawMirroredTextDemo.m lines 118-144, for applying a local transformation to any drawing commands. In that example replacing the Screen('glScale', w, 1, -1, 1); commands with a Screen('glRotate', w, 45); would rotate the text drawin in line 135 by 45 degrees, so if you’d use a ‘FillRect’ instead of a ‘DrawText’, you’d get a 45 degrees rotated rectange → your diamond shape. This is best done for complex shapes though, as the overhead of setting up the transform is much more than the actual drawing.

Yet another way is creating a texture that is just a solid color, and the use Screen(‘DrawTexture’) or Screen(‘DrawTextures’) to draw the image(s) of a square rotated by an angle. This might be more efficient than the two previous methods for not too big squares/diamonds. This latter method is conveniently implemented via the PsychDrawSprites2D() function and demonstrated in/via DotDemo(2); It can also do anti-aliasing for you.

I’d probably recommend the last PsychDrawSprites2D() approach for you.

But at only 6 such shapes and the speed of modern graphics card, it doesn’t really matter with your inter-stimulus intervals.

-mario

[18 minutes for this support incident, a total of 37 minutes used up out of 30 minutes paid for → This paid support license now completely exhausted.]