Rotating text to 90 degrees

조회 수: 137 (최근 30일)
Ananya
Ananya 2024년 2월 16일
댓글: Jérémie 2024년 12월 3일
I want to design an experiment in Psychtoolbox in which the alphabet T is rotated to 90 degrees.
By rotated to 90 degrees, I mean that the alphabet T (vertical) should appear in such a way that the head of the T should be either in the left or right direction.
Here is the code that I made so far but I do not know how to proceed.
% Initialize Psychtoolbox
PsychDefaultSetup(2);
Screen('Preference', 'SkipSyncTests', 1); % Skip sync tests for better compatibility
% Get the screen number
screenNumber = max(Screen('Screens'));
% Open a window
[windowPtr, windowRect] = PsychImaging('OpenWindow', screenNumber, 0); % 0 is black background
% Set text parameters
textSize = 50;
textColor = [255 255 255]; % White color
fontName = 'Arial';
% Define the alphabet 'T'
alphabetT = 'T';

답변 (3개)

Star Strider
Star Strider 2024년 2월 16일
편집: Star Strider 2024년 2월 16일
I’ve never used PsychToolbox, however that would be relatively straightforward in MATLAB graphics —
alphabetT = 'T';
figure
text(0.5, 0.5, alphabetT, 'FontSize',50)
set(gca, 'Visible','off')
figure
text(0.5, 0.5, alphabetT, 'FontSize',50, 'Rotation',90)
set(gca, 'Visible','off')
It might be necessaary to add an axes reference to the text call. See the documentation reference in ax for details.
EDIT — Corrected typographical errors.
.

Adam Danz
Adam Danz 2024년 2월 16일
It looks like you're working with embedded text.
You may find this resource helpful: https://peterscarfe.com/rotatingText.html
It contains a demo for rotating text in psychtoolbox by drawing the text to a texture and then to the screen.

Jérémie
Jérémie 2024년 12월 2일
편집: Jérémie 2024년 12월 2일
Hi there, in the same way, I would like to know whether there is a simple way to do so while working with Cogent buffers? For a bit of context, I am currently plotting arrays of letters (4 rows of 6 coloumns). Here are extracts of my code.
SurrLett = 'COJURQGBDPS';
IndLett = 'XXXXXXXXXXX';
allXpos = [-411.4 -246.9 -82.3 82.3 246.9 411.4];
allYpos = [-259.2 -86.4 86.4 259.2];
----
for i = 1:4 % 4 rows
rng('shuffle');
rrRes = randperm(length(SurrLett)); % Randomize letters of other lines
currLineLett = SurrLett(rrRes(1:6)); % Pick random letters for other lines
% Place letters at corresponding positions with random colours
for xp = 1:length(allXpos)
v = randi(size(AllColours, 1)); % AllColours is a list of 19x3 elements (19 RGB codes)
randomColour = AllColours(v, :);
if i == indexToRemove % Checking for a random line (because indexToRemove = randi([1, 4], 1))
setforecolour(1, 1, 1);
preparestring(cuedLineLett(xp), 2, allXpos(xp), allYpos(3));
else
setforecolour(randomColour(1), randomColour(2), randomColour(3))
preparestring(currLineLett(xp), 2, allXpos(xp), allYpos(i));
end
end
end
Thanks for you help in this matter. Feel free to ask for details whether it is unclear :)
Edit: Even tho I am looking for a random line, I am forcing to plot on allYpos(3), but it does not really matter for me by the end. Like I just need to screenshot the matrix where the white line is on this allYpos(3) location. Otherwise it would have been randomized as well.
  댓글 수: 1
Jérémie
Jérémie 2024년 12월 3일
The letters can be turned thanks to the
cgfont(Font, Size, Rotation);
function.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Installation and Operational Settings에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by