Scripting Guide > Three-Dimensional Scenes > Drawing Text > Using Text with Rotate and Translate
发布日期: 08/07/2020

Using Text with Rotate and Translate

The following example uses the text command in conjunction with the Translate and Rotate commands.

scene = Scene Box( 600, 600 ); // make a scene box...holds an OpenGL scene
New Window( "Example 2", scene ); // put the scene in a window
 

// the "lens" is 45 degrees, near is 3 units from the camera, far is 7

scene << Perspective( 45, 3, 7 );
 

// move the world so that 0,0,0 is visible in the camera

scene << Translate( 0.0, 0.0, -4.5 );
 

// rotate the first text about the Y (vertical on screen) axis

scene << Rotate( 30, 0, 1, 0 );
scene << Color( 1, 0, 2 ); // magenta
scene << Text( "center", "baseline", .2, "Top magenta string" );
 

// the next string is even farther away from the camera

scene << Translate( 0.0, 0.0, -2.0 );
 

// rotate the second text about the Y (vertical on screen) axis

scene << Rotate( 30, 0, 1, 0 );
scene << Color( 0, 1, 1); // aqua blue
scene << Text( "center", "baseline", .2, "Back aqua blue very long string" );
 

// update the display box in the window using the current display list

scene << Update;

Rotating and Translating Text Strings 

Note the green string is extending backward beyond the far clipping plane. Change the 7 to 10 in the Perspective command to see the complete string.

需要更多信息?有问题?从 JMP 用户社区得到解答 (community.jmp.com).