Rotation of Text, Images and Barcodes

<< Click to Display Table of Contents >>

Navigation:  Programming Techniques >

Rotation of Text, Images and Barcodes

Previous pageReturn to chapter overviewNext page

VPE is able to rotate text, images and barcodes freely in 90 degree steps. RTF can not be rotated. Some charts can be rotated by 90 degrees only to the right (with the property ChartGridRotation). Rotation is done clockwise, the <angle> parameter is specified in 1/10 degrees. So the value for rotating an object by 90 degrees to the right would be 900.

 

Examples:

DLL:

VpeSetRotation( hDoc, 900 );

 

Control:

<Object>.Rotation = 900

 

Note:When images or text are rotated, the given starting coordinate (x, y) remains unchanged. But x2 and y2 are transformed into x2’, y2’.

 

Look at the following simple example for images:

0 degrees:

90 degrees:

180 degrees:

270 degrees:

x, y

x, y

x, y

x, y

ProgrammersManual_img3

ProgrammersManual_img4

ProgrammersManual_img5

ProgrammersManual_img6

x2, y2

X2’, y2’

x2’, y2’

x2’, y2’

This example is simple, because the width and the height is the same, so rotation doesn’t matter.

 

The same for text, but now width and height aren’t identical:

0 degrees:

 

90 degrees:

180 degrees:

 

270 degrees:

x, y

 

x, y

x, y

 

x, y

ProgrammersManual_img7

x2, y2

 

ProgrammersManual_img8

ProgrammersManual_img9

x2’, y2’

 

ProgrammersManual_img10

 

 

x2’, y2’

 

 

x2’, y2’

 

How rotation is performed:

Say, you insert the text above at position (0, 0, 1, 0.5). The command would be:

VpeWriteBox(hdoc, 0, 0, 1, 0.5, "Hello World!")

 

Now you want to rotate it by 90 degrees. The commands would be:

VpeSetRotation(hdoc, 900)

VpeWriteBox(hdoc, 0, 0, 1, 0.5, "Hello World!")

 

Why the same coordinates? - Because VPE transforms them! Before rotating an object, VPE computes the width and the height of the object.

Regardless of the angle, the width and height will always stay the same. This makes rotation for you much easier (especially if you let VPE render the height of a text / image object), if you keep this in mind and use only relative coordinates for x2, y2 (negative signs).

 

Now the same example again, but with relative coordinates and the starting position (3.5, 2.2):

VpeSetRotation(hdoc, 900)

VpeWriteBox(hdoc, 3.5, 2.2, -1, -0.5, "Hello World!")

 

Do you get the idea? The "-1" is always the width, and the "-0.5" is always the height.

 

What about the rendering features of VPE? Of course it will work! The command: VpeWriteBox(hdoc, 3.5, 2.2, -1, VFREE, "Hello World!") will do fine with every rotation angle.

 

Now, after this explanation, keep the following two rules in mind:

1.As x2 and y2 are transformed, the best way to use rotation is, not to use absolute coordinates for x2, y2 but relative = width and height (this means: with a negative sign).

2.x2’ / y2’ is the final right / bottom position of the rotated object. These are the coordinates you will retrieve with VRIGHT / VBOTTOM.

 

See Also: “Dynamic Positioning