본문 바로가기
Python Library/VPython

[VPython] Miscellaneous (3)

by goatlab 2022. 1. 18.
728x90
반응형
SMALL

Canvas

 

canvas는 3D 개체를 표시하는 창이며 사용자 지정할 수 있다.

 

canvas(width=700,height=500,background=color.white)
sphere()

 

Multiple Canvases

 

둘 이상의 canvas가 있을 수 있으며, 각 canvas를 변수에 할당한다. canvas를 여러 개 사용하는 경우 각 객체를 canvas 변수에 할당하려면 모든 객체에 (canvas=) parameter가 있어야 한다.

 

canvas1 = canvas() # canvas 1
canvas2 = canvas() # canvas 2
box(canvas=canvas1) # assign box to canvas 1
sphere(canvas=canvas2) # assign sphere to canvas 2

 

Scene Text

 

3D 창 위에 텍스트를 추가하려면 scene.append_to_title("text here”)을 사용한다.
3D 창 아래에 텍스트를 추가하려면 scene.append_to_caption("text here”)을 사용한다.

3D 창 위에 위젯을 추가하려면, pos 특성인 pos = scene.title_anchor를 사용한다.
3D 창 아래에 위젯을 추가하려면, pos 특성인 pos = scene.caption_anchor를 사용한다.

widget을 웹 페이지 하단의 인쇄 상자 영역에 추가하려면 pos = print_anchor를 사용한다.

 

Delete Object

 

my_box = box()
my_box.visible = False # makes invisible
del my_box # deletes from program memory

 

Bounding Box

 

Bounding Box는 객체의 8개 모서리 모두에 대한 좌표를 목록으로 반환한다. 각 벡터 좌표는 my_box.bounding_box()[#]를 사용하여 액세스할 수 있으며 좌표의 각 값은 my_box.bounding_box()[#]x/y/z를 사용하여 액세스할 수 있다.

 

my_box = box()
my_box.bounding_box()
# returns:[<0,0,-1.5>, <0,0,0>, <0,2,-1.5>, <0,2,0>, <1,0,-1.5>, <1,0,0>,
# <1,2,-1.5>, <1,2,0>]
my_box.bounding_box()[0] # returns 1 st coordinate: <0, 0, -1.5>
my_box.bounding_box()[0].x # returns x value: 0

 

https://www.glowscript.org/docs/VPythonDocs/options.html

 

VPython Help

Additional Attributes The following attributes apply to all VPython objects: visible If False, object is not displayed; e.g. ball.visible = False Use ball.visible = True to make the ball visible again. rotate() An object B can be rotated with B.rotate(angl

www.glowscript.org

 

728x90
반응형
LIST

'Python Library > VPython' 카테고리의 다른 글

[VPython] Trajectory  (0) 2022.01.20
[VPython] Sharing / Backup  (0) 2022.01.18
[VPython] Miscellaneous (2)  (0) 2022.01.18
[VPython] Miscellaneous (1)  (0) 2022.01.18
[VPython] Mouse and Keyboard Events  (0) 2022.01.18