GlowScript: Difference between revisions
No edit summary |
|||
Line 1: | Line 1: | ||
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.<br><br> | Scripts can be written in VPython.<br><br> |
Revision as of 23:51, 24 November 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
Unlike Java, with Python 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.