File: label.html

package info (click to toggle)
python-visual 1%3A5.12-1.6
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch
  • size: 7,708 kB
  • ctags: 7,635
  • sloc: cpp: 15,593; sh: 9,615; ansic: 6,631; python: 4,737; makefile: 384
file content (185 lines) | stat: -rw-r--r-- 10,514 bytes parent folder | download | duplicates (3)
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/visual/Templates/template.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>label</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 -->
<script type="text/javascript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
//-->
</script>
<link href="VisualRef.css" rel="stylesheet" type="text/css" />
</head>

<body>
<table width="800" border="0" cellpadding="0" cellspacing="0">
  <!--DWLayoutDefaultTable-->
  <tr>
    <td width="10" valign="top" bgcolor="#FFFFFF"><!--DWLayoutEmptyCell-->&nbsp;</td>
    <td width="10" height="272" valign="top" bgcolor="#DDDDDD"><p>&nbsp;</p>    </td>
    <td width="173" valign="top" bgcolor="#DDDDDD"><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="primitives.html">Pictures</a> of 3D objects</p>
      <p class="Normal">Choose a 3D object:</p>
        <select name="jumpMenu4" id="jumpMenu4" onchange="MM_jumpMenu('parent',this,0)">
          <option>Choose an object</option>
          <option value="cylinder.html">Overview</option>
          <option value="arrow.html">arrow</option>
          <option value="box.html">box</option>
          <option value="cone.html">cone</option>
          <option value="convex.html">convex</option>
          <option value="curve.html">curve</option>
          <option value="cylinder.html">cylinder</option>
          <option value="ellipsoid.html">ellipsoid</option>
          <option value="faces.html">faces</option>
          <option value="frame.html">frame</option>
          <option value="helix.html">helix</option>
          <option value="label.html">label</option>
          <option value="lights.html">lights</option>
          <option value="points.html">points</option>
          <option value="pyramid.html">pyramid</option>
          <option value="ring.html">ring</option>
          <option value="sphere.html">sphere</option>
        </select>
        
      <p class="Normal">Work with 3D objects:</p>
        <select name="jumpMenu4" id="jumpMenu5" onchange="MM_jumpMenu('parent',this,0)">
          <option>Choose an option</option>
          <option value="color.html">Color &amp; Opacity</option>
          <option value="lights.html">Lighting</option>
          <option value="materials.html">Materials &amp; Textures</option>
          <option value="defaults.html">Defaults</option>
          <option value="rate.html">Animation Speed</option>
          <option value="rotation.html">Rotations</option>
          <option value="options.html">Additional Options</option>
          <option value="delete.html">Delete an Object</option>
          <option value="float.html">3/4 = 0?</option>
        </select>
        
      <p class="Normal">Windows, Events, &amp; Files:</p>
        <select name="jumpMenu4" id="jumpMenu6" onchange="MM_jumpMenu('parent',this,0)">
          <option>Choose a topic</option>
          <option value="display.html">Windows</option>
          <option value="lights.html">Lighting</option>
          <option value="mouse.html">Mouse Events</option>
          <option value="mouse_click.html">&nbsp;&nbsp;&nbsp;Mouse Click</option>
          <option value="mouse_drag.html">&nbsp;&nbsp;&nbsp;Mouse Drag</option>
          <option value="keyboard.html">Keyboard Events</option>
          <option value="controls.html">Buttons and Sliders</option>
          <option value="files.html">Reading/Writing Files</option>
        </select>
        
      <p class="Normal"><a href="vector.html">Vector operations </a></p>
      <p class="Normal"><a href="graph.html">Graphs</a></p>
    <p class="Normal"><a href="factorial.html">factorial/combin</a></p>
    <p class="Normal">What's new in <a href="new_features.html">Visual 5</a></p>
    <p class="Normal"><a href="http://vpython.org" target="_blank">VPython web site</a><br />
      <a href="license.txt" target="_blank">Visual license</a><br />
      <a href="http://www.python.org" target="_blank">Python web site</a> <br />
      <a href="http://www.python.org/doc/2.5.2/lib/module-math.html" target="_blank">Math module</a> (sqrt etc.)<br />
    <a href="http://www.scipy.org/Documentation" target="_blank">Numpy module</a> (arrays)    </p></td>
    <td width="21" valign="top" bgcolor="#FFFFFF"><!--DWLayoutEmptyCell-->&nbsp;</td>
    <td width="586" rowspan="2" valign="top"><!-- 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" alt="label" width="131" height="127" /><a href="arrow.html"></a></div></td>
            </tr>
          </table>
          <p class="Normal"> With the label object you can display text in a box. Here 
            are simple examples (in the second label statement, note the standard Python 
            scheme for formatting numerical values, where 1.5f means 1 figure before the 
            decimal point and 5 after):</p>

            <p class="program"> box(pos=(0,0,0), color=color.red)<br />
            label(pos=(0,0.25,0), text='This is a box')<br />
            label(pos=(0,-0.25,0), text='pi = %1.5f' % pi)
            <p class="Normal"><img src="VisualRef-7.gif" alt="label" align="right" /> There are many additional 
            label options. In the accompanying diagram, a sphere representing the Earth 
            (whose center is at <span class="attribute"> earth.pos</span>) has an associated 
            label with the text &quot;Earth&quot; in a box, connected to the sphere 
            by a line which stops at the surface of the sphere:</p>

            <p class="program"> earthlabel = label(pos=earth.pos,<br />
&nbsp;&nbsp;&nbsp;              text='Earth', xoffset=20,<br />
&nbsp;&nbsp;&nbsp; yoffset=12, space=earth.radius,<br />
&nbsp;&nbsp;&nbsp; height=10, border=6,<br />
&nbsp;&nbsp;&nbsp; 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 &quot;world-space&quot; 
              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>; <span class="attribute">x</span>,<span class="attribute">y</span>,<span class="attribute">z</span> The
              point in world space being labeled. If there are no offsets (see
              diagram), the center of the text is at <span class="attribute">pos</span></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). You can <span class="style1">left
        justify </span>text
        by setting xoffset = 1 and line = 0 (so the 1-pixel line doesn't show),
        or <strong><span class="attribute">right-justify</span></strong> text
        by setting xoffset = -1 and line = 0.</p>
      <p class="attributes"> <span class="attribute">text</span> The text to be 
              displayed, such as 'Earth'<br />
              (Line breaks can be included as \n, as in label.text = &quot;Three\nlines\nof 
              text&quot;)</p>
            <p class="attributes"> <span class="attribute">font</span> Name of the desired 
              font; for example, 'sans', or 'serif', or 'monospace' (fixed-width)<br />
            Python Unicode strings are supported.</p>
            <p class="attributes"> <span class="attribute">height</span> Height
              of the font  in pixels; default is 13 pixels</p>
            <p class="attributes"> <span class="attribute">color</span>, <span class="attribute">red</span>, <span class="attribute">green</span>, <span class="attribute">blue</span> Color of the text</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 the line from 
              the box to pos 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">space</span> World-space radius 
              of a sphere surrounding pos,<br />
      into which the connecting line does not go</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 --></td>
  </tr>
  <tr>
    <td height="16" colspan="4"></td>
  </tr>
</table>
</body>
<!-- InstanceEnd --></html>