Rotate Text Demo Demo Experiment Run Experiment

Rotate Text Demo

Jaap Murre

Brief demo showing how to rotate and flip text using CSS styles.

Note that the CSS transform is odd in that its argument is a string of scale() and other transformations, separated with a space. You cannot call the style() function twice with a transform but you must combine them into a single string as shown in this example. See this page for more information.

BTW: This approach will not work on very old browsers, which do not yet support the CSS transform. To ensure that you must use a different approach.

If you are a registered user and signed in, you can here copy this script and its stimuli to your own account, where you can edit it and change it in any way you want.

It is absolutely free to register (no credit card info asked!). You can then instantly copy this experiment with one click and edit it, change its accompanying texts, its landing page, stimuli, etc. Invite your colleagues, friends, or students to check out your experiment. There is no limit on how many people can do your experiment, even with a free account.

The catch? There is no catch! Just keep in mind that with a free account, you cannot collect data. For teaching that is usually not a problem. For research, prepaid data collection (unlimited subjects) starts as low as €10.00 for a 10-day period.

var b = addblock(20,20,60,60), degrees, i, stim = ['A','B','C','d','F','f'];

var s; // style transform string

for (i = 0; i < stim.length; i++) 
{
    b.text(stim[i],1000);
    degrees = randint(360);
    s = 'rotate(' + degrees + 'deg)';
    if (Math.random() < 0.5) { // Additional transforms are separated with a space
        s += ' scale(-1, 1)';  // Horizontal flip. Vertical is (1,-1)
    }
    b.style('transform',s);
    await(1000);    
}

b.clear();
text("Or add animation!",80);
await(3000);
clear();
b.text("N",300);

for (i = 0; i < 300; i++) {
    RAF();
    b.style('transform','rotate(' + i*5 + 'deg)');
}

await(1000);

You can download the files as follows: Click on the file (link) and then right-click and choose Save as... from the menu. Some media files (e.g., sound) will have a download button for this purpose.

This experiment has no files of this type
This experiment has no files of this type
This experiment has no files of this type
This experiment has no YouTube links
This experiment has no files of this type