GlowScript: Difference between revisions

From Physics Book
Jump to navigation Jump to search
(Initial edit)
 
(Added object customizing)
Line 1: Line 1:
Claimed by hkim944 (Spring 2019)
Claimed by Hwuiwon Kim (Spring 2019)




GlowScript IDE is an environment where people can create 3D animations and share them on web.<br>
GlowScript IDE is an environment where people can create 3D animations and share them on web.<br>
Scripts can be written in VPython.
Scripts can be written in VPython.<br><br>


== Commands ==
== Commands ==
Line 33: Line 33:


<b>Sphere</b>
<b>Sphere</b>
  newSphere =sphere(pos=vec(x0, y0, z0), size=vec(x1, y1, z1) )
  newSphere = sphere(pos=vec(x0, y0, z0), size=vec(x1, y1, z1) )
This creates a box with a center <x0, y0, z0> and with size <x1, y1, z1><br><br>
This creates a box with a center <x0, y0, z0> and with size <x1, y1, z1><br><br>


You can learn more by clicking this. [https://www.glowscript.org/docs/GlowScriptDocs/index.html]
You can learn more by clicking this. [https://www.glowscript.org/docs/GlowScriptDocs/index.html]
=== Customizing Objects ===
----
<b>Color</b><br>
There are 10 default colors that can be used.
color.red, color.yellow, color.green, color.orange
color.blue, color.cyan, color.magenta, color.purple
color.black, color.white
Colors can be customized by user by using following code.
vec(1, 0.5, 0.3)
In this case, R is 1, G = 0.7, and B = 0.2, which has color of pastel orange.<br><br>
<b>Animation Speed</b><br>
rate(50)
This line will halt each computations to have interval of 1.0/50.0 second.


== Supported Environments ==
== Supported Environments ==

Revision as of 15:07, 13 April 2019

Claimed by Hwuiwon Kim (Spring 2019)


GlowScript IDE is an environment where people can create 3D animations and share them on web.
Scripts can be written in VPython.

Commands

Header


GlowScript 2.7 VPython is required in header to run Vpython.
GlowScript 2.7 JavaScript is required in header to run javascript.


Initialize new Variables


Use var and assign values.

var x, y
x = 2
y = 3

There is no need to put semi-colon in the end of a line.

3D Objects


Arrow

newArrow = arrow(pos=vec(x0, y0, z0), shaftwidth=1, axis_and_length=vec(x1, y1, z1))

This creates arrow that starts at point <x0, y0, z0> that points <x1, y1, z1>

Box

newBox = box(pos=vec(x0, y0, z0), size=vec(L, H, W))

This creates a box with a center <x0, y0, z0> and with size <L, H, W>

Sphere

newSphere = sphere(pos=vec(x0, y0, z0), size=vec(x1, y1, z1) )

This creates a box with a center <x0, y0, z0> and with size <x1, y1, z1>

You can learn more by clicking this. [1]

Customizing Objects


Color
There are 10 default colors that can be used.

color.red, color.yellow, color.green, color.orange
color.blue, color.cyan, color.magenta, color.purple
color.black, color.white

Colors can be customized by user by using following code.

vec(1, 0.5, 0.3)

In this case, R is 1, G = 0.7, and B = 0.2, which has color of pastel orange.

Animation Speed

rate(50)

This line will halt each computations to have interval of 1.0/50.0 second.

Supported Environments

Browsers: Chrome, Firefox, Safari, Internet Explorer, and Edge.
Devices: Most smart devices running Android or iOS.