I would like to replace cursor feedback with a ring centred at a start target that changes radius as a function of cursor position (distance from the start target).
I have added ring_state to the main trial block in indicate when the ring should be switched on, and have created a hollow target for the ring. The ring’s location is provided by the parameters table (entered into the target block). I am not sure how to bypass the VISUAL_RADIUS value from the parameter table in order to change the radius of the ring dynamically.
Can I simply modify the VCODES that leave the target block with a function that replaces VCode(10) with the distance of cursor position and start target, or should I modify the target row inputs that enter the target block? Thanks in advance.
You can simply modify the VCODES that leave the target block with a function that replaces VCODE(10) with the distance of cursor position and start target.
The VISUAL_RADIUS value in the Parameter Table Defn block is only referenced in the Show Target blocks which creates the VCODE. After the VCODE leaves the Show Target block, you can overwrite any parts of it to your liking. The VCODE values that are passed into the Process Video CMD block are the ones that are drawn.
I have written the following function to modify the target VCODES:
function VCODES_OUT = Feedback_Ring(Ring_state, Cursor_X, Cursor_Y, VCODES_IN)
VCODES = VCODES_IN;
radii = hypot((Cursor_X -VCODES(3)), (Cursor_Y-VCODES(4))); %determine distance of cursor from start target center
if Ring_state == 1;
VCODES(10) = radii;
VCODES(5) = -2^31; % set to no-fill
% Set stroke value to ‘green’ by converting to uint32 format
full = (2^32 – 1);
VCODES(6) =(full*(2^64)) + full; % THIS DOES NOT WORK
VCODES(10) = VCODES(10);
VCODES_OUT = VCODES;
But I am unclear as to how I can change the stroke colour to green. Specifically how to format in uint32. Are you able to assist with this?
For colours, what I do is I find the hex value using a website like http://www.color-hex.com/ and then convert to decimal using hex2dec. So maybe for green, if you want to use #00ff00:
VCODES(6) = hex2dec(’00ff00′);
I find it’s easy for me to keep track of what colour is what and also easy to swap in another colour.