-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathlabel.html
More file actions
123 lines (119 loc) · 8.04 KB
/
Copy pathlabel.html
File metadata and controls
123 lines (119 loc) · 8.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<!-- InstanceBegin template="/Templates/template.dwt" codeOutsideHTMLIsLocked="false" --><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>VPython Help</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<link href="VisualRef.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style1 {
color: #FF0000;
font-weight: bold;
}
-->
</style>
<style type="text/css">
<!--
.style2 {
font-size: x-large;
font-weight: bold;
}
.style2 {font-size: xx-large}
-->
</style>
<!-- InstanceEndEditable -->
</head>
<body>
<div id="wrapper">
<div id="leftmenu">
<p class="Normal"><a href="index.html"> Home</a></p>
<p class="Normal"> If you're new to Python <br />
and VPython: <a href="VisualIntro.html">Introduction</a></p>
<p class="Normal"> A VPython <a href="VPython_Intro.pdf" target="_blank">tutorial</a></p>
<p class="Normal"><a href="videos.html"> Introductory Videos</a></p>
<p class="Normal"><a href="primitives.html"> Pictures</a> of 3D objects</p>
<p> <select id="menu1" onChange="jumpMenu(this)"></select></p>
<p> <select id="menu2" onChange="jumpMenu(this)"></select></p>
<p> <select id="menu3" onChange="jumpMenu(this)"></select></p>
<p class="Normal"><a href="https://vpython.org" target="_blank"> VPython 7 web site</a><br />
<a href="license.txt" target="_blank"> VPython license</a><br />
<br />
</p>
</td>
</div>
<div id="content">
<!-- InstanceBeginEditable name="content" -->
<table width="100%" border="1">
<tr>
<td width="77%"><div align="center"><span class="style2"><font color="#0000A0">label</font></span></div></td>
<td width="23%"><div align="center"><img src="images/label.jpg" width="192" height="159" alt="label" /><a href="arrow.html"></a></div></td>
</tr>
</table>
<p class="Normal"> With the label object you can display text in
a box, and the label always faces forward, even if you rotate the
scene (for 3D text, see the <a href="text.html"><strong>text</strong></a> object). Here is a simple example:</p>
<p class="program"> label( pos=vec(0,0.25,0), text='Hello!' ) </p>
<p class="Normal"><img src="images/label2.png" alt="label" width="162" height="225" align="right" /> There are many additional
label options. In the diagram to the right, an object located at "obj.pos" has an associated
label with the text "Early" in a box, connected to the object.</p>
<p class="program"> L = label(pos=obj.pos,<br />
text='Early', xoffset=20,<br />
yoffset=50, space=30,<br />
height=16, border=4,<br />
font='sans')</p>
<p class="Normal"> A unique feature of the label object is that several attributes
are given in terms of screen pixels instead of the usual "world-space"
coordinates. For example, the height of the text is given in pixels, with
the result that the text remains readable even when the sphere object is
moved far away. Other pixel-oriented attributes include <span class="attribute">xoffset</span>, <span class="attribute">yoffset</span>, and <span class="attribute">border</span>.
Here are the label attributes:</p>
<p class="attributes"> <span class="attribute">pos</span> The
point in world space being labeled.</p>
<p class="attributes"> <span class="attribute">pixel_pos</span><span class="attribute"></span> If True, <span class="attribute">pos</span> is the position in terms of pixels, with vec(0,0,0) in the lower left corner.</p>
<p class="attributes"> <span class="attribute">align</span><span class="attribute"></span> Specify 'left', 'right', or 'center'. When you specify 'center', which is the default, the center of the topmost line of text is at the location given by pos. When you specify 'left', the start of the topmost line of text is at the location given by pos. When you specify 'right', the right end of the topmost line of text is at the location given by pos.</p>
<p class="attributes"> <span class="attribute">xoffset</span>, <span class="attribute">yoffset</span> The
x and y components of the line, in pixels (see diagram). Unless you specify a value for align, text above or below pos is centered, text to the left of pos is right-adjusted, and text to the right of pos is left-adjusted.</p>
<p class="attributes"> <span class="attribute">text</span> The text to be
displayed, such as 'Earth'.
You can give a number or numerical expression; it will be converted to a string.You can include the HTML styles for italic (<i> or <em>), bold (<b> or <strong>), superscript (<sup>), or subscript (<sub>). For example, the string<br />
<strong>'The <b>mass <i>M</i></b><sub>sys</sub> = 10<sup>3</sup> kg.</strong><br />
displays as<br />
'The <b>mass <i>M</i></b><sub>sys</sub> = 10<sup>3</sup> kg.
<br />
<br />
Multiple lines can be displayed by inserting line breaks (\n), as in "Three\nlines\nof
text" and you can insert <br> or <br/> instead of \n. You can also create multiple lines by using triple quotes:</p>
<p class="program"> L = label()<br />
L.text = """The quick brown fox<br />
jumps over the lazy dog."""</p>
<p class="attributes"> <span class="attribute">font</span> Name of the desired
font; 'sans' or 'serif'' or 'monospace' (fixed-width), or a specific font name; the default is "sans"</p>
<p class="attributes"> <span class="attribute">height</span> Height
of the font in pixels; default is 15 pixels</p>
<p class="attributes"> <span class="attribute">color</span> Color of the text; default is scene.foreground</p>
<p class="attributes"> <span class="attribute">background</span> Color of the background of the box; default is scene.background</p>
<p class="attributes"> <span class="attribute">opacity</span> Opacity of the
background of the box, default 0.66<br />
(0 transparent, 1 opaque, for objects behind the box)</p>
<p class="attributes"> <span class="attribute">border</span> Distance
in pixels from the text to the surrounding box; default is 5 pixels</p>
<p class="attributes"> <span class="attribute">box</span> True if the box should
be drawn (default), else False</p>
<p class="attributes"> <span class="attribute">line</span> True if a line from
the pos to the box should be drawn (default), else False</p>
<p class="attributes"> <span class="attribute">linecolor</span> Color of the line
and box</p>
<p class="attributes"> <span class="attribute">linewidth</span> Thickness of the line drawn from the pos to the box, and the edges of the box (default is 1 pixel)</p>
<p class="attributes"> <span class="attribute">space</span> Radius
in pixels of a sphere surrounding pos, into which the connecting line does not go</p>
<p class="attributes"> <span class="attribute">visible</span> Label is not displayed if False</p>
<p class="Normal"></p>
<p class="Normal">See description of <a href="options.html">Additional
Attributes</a> available for all 3D display objects.</p>
<!-- InstanceEndEditable -->
</div>
</div>
</body>
<script type="text/javascript" language="javascript" src="navigation.js"></script>
<!-- InstanceEnd --></html>