1 |
# Import the necessary modules. |
2 |
from esys.pyvisi import Scene, Text2D, LocalPosition |
3 |
from esys.pyvisi.constant import * |
4 |
import os |
5 |
|
6 |
PYVISI_EXAMPLE_MESHES_PATH = "data_meshes" |
7 |
PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images" |
8 |
X_SIZE = 600 |
9 |
Y_SIZE = 600 |
10 |
|
11 |
IMAGE_NAME = "text.jpg" |
12 |
JPG_RENDERER = Renderer.ONLINE_JPG |
13 |
|
14 |
# Create a Scene. |
15 |
s = Scene(renderer = JPG_RENDERER, num_viewport = 4, x_size = X_SIZE, |
16 |
y_size = Y_SIZE) |
17 |
|
18 |
# Create a 2D text for the first viewport. |
19 |
t1 = Text2D(scene = s, text = "VTK ...", viewport = Viewport.SOUTH_WEST) |
20 |
t1.setPosition(LocalPosition(x_coor = 20, y_coor = 30)) |
21 |
t1.setColor(color = Color.BLUE) |
22 |
t1.setFontSize(size = 20) |
23 |
t1.boldOn() |
24 |
|
25 |
# Create a 2D text for the third viewport. |
26 |
t2 = Text2D(scene = s, text = "PYTHON ...\n MESH", |
27 |
viewport = Viewport.NORTH_EAST) |
28 |
t2.setPosition(LocalPosition(x_coor = 20, y_coor = 30)) |
29 |
t2.setColor(color = Color.PURPLE) |
30 |
t2.setFontSize(size = 50) |
31 |
t2.setFontToArial() |
32 |
t2.shadowOn() |
33 |
|
34 |
# Render the object. |
35 |
s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, IMAGE_NAME)) |
36 |
|