Skip to content

Commit e3a4402

Browse files
committed
Improved doc on scene.camera.follow()
1 parent 1ee55a3 commit e3a4402

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

docs/VPythonDocs/canvas.html

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,12 @@ <h1 class="Heading-1"> <font color="#0000A0">Controlling One or More VPython
8888
<p class="attributes"><span class="attribute">capture(filename) </span>Sends to your Download folder a png screen shot of the canvas. If filename is the string &quot;boxes&quot; or &quot;boxes.png&quot; the file will be named &quot;boxes.png&quot;. If you execute scene.capture(&quot;boxes&quot;) repeatedly, the additional files will be named &quot;boxes(1).png&quot;, &quot;boxes(2).png&quot;, etc. If you do not want to capture "label" objects, execute scene.capture(filename, False)</p>
8989
<p class="attributes"><span class="attribute"><font color="#000000">To obtain the current location of the camera, <a href="#camera"><strong>see </strong></a></font></span><strong><a href="#camera">below</a></strong> for details of <span class="attribute">scene.camera.pos</span><font color="#000000">.</font></p>
9090
<p class="attributes"><span class="attribute">camera.follow</span> If you say <span class="attribute">scene.camera.follow(ball)</span>, the center of the scene will continually be reset to the current position of the ball object. To stop following the object, execute <span class="attribute">scene.camera.follow(None)</span>.</p>
91-
<p class="attributes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Instead of specifying an object to follow, you can provide a function of your own:</p>
91+
<p class="attributes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Instead of specifying an object to follow, you can provide a function of your own (not yet available in VPython 7):</p>
9292
<p class="program"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;def f():<br />
9393
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return 2*ball.pos<br />
9494
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;scene.camera.follow(f)</p>
9595
<p class="attributes"></p>
96-
<p class="attributes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Alternatively, in Web VPython you can specify an &quot;anonymous&quot; (unnamed) function, though this does not work in true Python:</p>
97-
<p class="program">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;scene.camera.follow(def ():<br />
98-
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 2*ball.pos<br />
99-
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )</p>
100-
<p class="attributes"><span class="attribute">pixel_to_world</span> Gives the width of a pixel in &quot;world&quot; coordinates (that is, the coordinates you use to position objects). This is read-only; you cannot set it. It is determined from the current value of scene.range. An example of its use is that if you want the radius of a curve object to be 5 pixels, set the radius to 5*scene.pixel_to_world.</p>
96+
<p class="attributes"><span class="attribute">pixel_to_world</span> Gives the width of a pixel in &quot;world&quot; coordinates (that is, the coordinates you use to position objects). This is read-only; you cannot set it. It is determined from the current value of scene.range. An example of its use is that if you want the radius of a curve object to be 5 pixels, set the radius to 5*scene.pixel_to_world.</p>
10197
<p class="Normal">Here are canvas options to wait for canvas updates:</p>
10298
<p class="attributes"><span class="attribute">scene.waitfor(&quot;redraw&quot;) </span>Wait for the start of the next update of the canvas by the web browser</p>
10399
<p class="attributes"><span class="attribute">scene.waitfor(&quot;draw_complete&quot;) </span>Wait for the end of the next update of the canvas by the web browser</p>

0 commit comments

Comments
 (0)