Graphic display problem after using normalized coordinates in Matlab
Hi,guys.
I encountered a problem. That is, when I use normalized coordinates, no matter how I adjust the diameter of my target circle, there is no change in the image. I can feel the change in the coordinates. But I don’t need this. I want the entire image to change after adjusting the diameter.
Here are the codes:
function startTask()
targetCenters = zeros(8, 2);
angles = linspace(0, 2*pi, 9);
angles = angles(1:end-1);
radii = 0.3;
waitingForNextTarget = false;
firstMove = true;
resetPosition = [0, 0];
targetSequence = [1,3,5,7,2,4,6,8,8,6,4,2,7,5,3,1];
currentSequenceIndex = 1;
for i = 1:length(angles)
targetCenters(i, 1) = radii * cos(angles(i));
targetCenters(i, 2) = radii * sin(angles(i));
end
targetActivated = false;
currentTarget = 0;
hoverStartTime = [];
cyclesCompleted = 0;
maxCycles = 64;
mousePath = [];
mouseDot = [];
x = 0;
y = 0;
timerObj = timer(‘TimerFcn’, @recordMousePos, ‘Period’, 0.02 , ‘ExecutionMode’, ‘fixedRate’);
checkTargetTimer = timer(‘TimerFcn’, @checkAndActivateTarget, ‘Period’, 0.02 , ‘ExecutionMode’, ‘fixedRate’);
start(checkTargetTimer);
fig = figure(‘Color’, ‘black’, ‘Pointer’, ‘custom’, ‘Units’, ‘normalized’, ‘Position’, [0 0 1 1], ‘MenuBar’, ‘none’, ‘ToolBar’, ‘none’);
ax = axes(‘Color’, ‘black’, ‘Units’, ‘normalized’, ‘Position’, [0 0 1 1], ‘DataAspectRatio’, [1 1 1]);
axis off;
hold on;
drawCircles();
set(fig, ‘WindowButtonMotionFcn’, @mouseMoved);
setInvisibleCursor();
showBlackPanelScreen(2)
resetMouseAndDotPositionToCenter();
activateRandomTarget();
function setInvisibleCursor()
transparentCursor = NaN(16, 16);
hotspot = [8, 8];
set(fig, ‘Pointer’, ‘custom’, ‘PointerShapeCData’, transparentCursor, ‘PointerShapeHotSpot’, hotspot);
end
function drawCircles()
angles = linspace(0, 2*pi, 9);
angles = angles(1:end-1);
circleDiameter = radii * 0.2;
%axis equal;
for i = 1:length(angles)
x = radii * cos(angles(i));
y = radii * sin(angles(i));
rectangle(‘Position’, [x – circleDiameter/2, y – circleDiameter/2, circleDiameter, circleDiameter], ‘Curvature’, [1, 1], ‘EdgeColor’, ‘w’, ‘FaceColor’, ‘k’, ‘LineStyle’, ‘–‘, ‘LineWidth’, 3, ‘UserData’, i);
end
end
SichengHi,guys.
I encountered a problem. That is, when I use normalized coordinates, no matter how I adjust the diameter of my target circle, there is no change in the image. I can feel the change in the coordinates. But I don’t need this. I want the entire image to change after adjusting the diameter.
Here are the codes:
function startTask()
targetCenters = zeros(8, 2);
angles = linspace(0, 2*pi, 9);
angles = angles(1:end-1);
radii = 0.3;
waitingForNextTarget = false;
firstMove = true;
resetPosition = [0, 0];
targetSequence = [1,3,5,7,2,4,6,8,8,6,4,2,7,5,3,1];
currentSequenceIndex = 1;
for i = 1:length(angles)
targetCenters(i, 1) = radii * cos(angles(i));
targetCenters(i, 2) = radii * sin(angles(i));
end
targetActivated = false;
currentTarget = 0;
hoverStartTime = [];
cyclesCompleted = 0;
maxCycles = 64;
mousePath = [];
mouseDot = [];
x = 0;
y = 0;
timerObj = timer(‘TimerFcn’, @recordMousePos, ‘Period’, 0.02 , ‘ExecutionMode’, ‘fixedRate’);
checkTargetTimer = timer(‘TimerFcn’, @checkAndActivateTarget, ‘Period’, 0.02 , ‘ExecutionMode’, ‘fixedRate’);
start(checkTargetTimer);
fig = figure(‘Color’, ‘black’, ‘Pointer’, ‘custom’, ‘Units’, ‘normalized’, ‘Position’, [0 0 1 1], ‘MenuBar’, ‘none’, ‘ToolBar’, ‘none’);
ax = axes(‘Color’, ‘black’, ‘Units’, ‘normalized’, ‘Position’, [0 0 1 1], ‘DataAspectRatio’, [1 1 1]);
axis off;
hold on;
drawCircles();
set(fig, ‘WindowButtonMotionFcn’, @mouseMoved);
setInvisibleCursor();
showBlackPanelScreen(2)
resetMouseAndDotPositionToCenter();
activateRandomTarget();
function setInvisibleCursor()
transparentCursor = NaN(16, 16);
hotspot = [8, 8];
set(fig, ‘Pointer’, ‘custom’, ‘PointerShapeCData’, transparentCursor, ‘PointerShapeHotSpot’, hotspot);
end
function drawCircles()
angles = linspace(0, 2*pi, 9);
angles = angles(1:end-1);
circleDiameter = radii * 0.2;
%axis equal;
for i = 1:length(angles)
x = radii * cos(angles(i));
y = radii * sin(angles(i));
rectangle(‘Position’, [x – circleDiameter/2, y – circleDiameter/2, circleDiameter, circleDiameter], ‘Curvature’, [1, 1], ‘EdgeColor’, ‘w’, ‘FaceColor’, ‘k’, ‘LineStyle’, ‘–‘, ‘LineWidth’, 3, ‘UserData’, i);
end
end
Sicheng Hi,guys.
I encountered a problem. That is, when I use normalized coordinates, no matter how I adjust the diameter of my target circle, there is no change in the image. I can feel the change in the coordinates. But I don’t need this. I want the entire image to change after adjusting the diameter.
Here are the codes:
function startTask()
targetCenters = zeros(8, 2);
angles = linspace(0, 2*pi, 9);
angles = angles(1:end-1);
radii = 0.3;
waitingForNextTarget = false;
firstMove = true;
resetPosition = [0, 0];
targetSequence = [1,3,5,7,2,4,6,8,8,6,4,2,7,5,3,1];
currentSequenceIndex = 1;
for i = 1:length(angles)
targetCenters(i, 1) = radii * cos(angles(i));
targetCenters(i, 2) = radii * sin(angles(i));
end
targetActivated = false;
currentTarget = 0;
hoverStartTime = [];
cyclesCompleted = 0;
maxCycles = 64;
mousePath = [];
mouseDot = [];
x = 0;
y = 0;
timerObj = timer(‘TimerFcn’, @recordMousePos, ‘Period’, 0.02 , ‘ExecutionMode’, ‘fixedRate’);
checkTargetTimer = timer(‘TimerFcn’, @checkAndActivateTarget, ‘Period’, 0.02 , ‘ExecutionMode’, ‘fixedRate’);
start(checkTargetTimer);
fig = figure(‘Color’, ‘black’, ‘Pointer’, ‘custom’, ‘Units’, ‘normalized’, ‘Position’, [0 0 1 1], ‘MenuBar’, ‘none’, ‘ToolBar’, ‘none’);
ax = axes(‘Color’, ‘black’, ‘Units’, ‘normalized’, ‘Position’, [0 0 1 1], ‘DataAspectRatio’, [1 1 1]);
axis off;
hold on;
drawCircles();
set(fig, ‘WindowButtonMotionFcn’, @mouseMoved);
setInvisibleCursor();
showBlackPanelScreen(2)
resetMouseAndDotPositionToCenter();
activateRandomTarget();
function setInvisibleCursor()
transparentCursor = NaN(16, 16);
hotspot = [8, 8];
set(fig, ‘Pointer’, ‘custom’, ‘PointerShapeCData’, transparentCursor, ‘PointerShapeHotSpot’, hotspot);
end
function drawCircles()
angles = linspace(0, 2*pi, 9);
angles = angles(1:end-1);
circleDiameter = radii * 0.2;
%axis equal;
for i = 1:length(angles)
x = radii * cos(angles(i));
y = radii * sin(angles(i));
rectangle(‘Position’, [x – circleDiameter/2, y – circleDiameter/2, circleDiameter, circleDiameter], ‘Curvature’, [1, 1], ‘EdgeColor’, ‘w’, ‘FaceColor’, ‘k’, ‘LineStyle’, ‘–‘, ‘LineWidth’, 3, ‘UserData’, i);
end
end
Sicheng graphics,, normalized coordinates MATLAB Answers — New Questions