GlowScript 2.6 provides significant fixes to cloning and to the 3D text object. Some of these fixes might cause existing version 2.5 programs to fail, which is why there is a new version 2.6. Version 2.6 also corrects the failure of label positions to be updated when changing scene.center.
Adam Thompson implemented being able to resize a canvas, either by resetting width and/or height, or by user dragging. This is the default behavior. If you don't want the user to be able to resize a canvas named scene, execute scene.resizable = False. Also, your program can now change scene.width and/or scene.height and the display will appear correctly in the resized canvas, which was not the case in GlowScript 2.5.
If a canvas is resizable, you can specify a function to be executed whenever the user changes the width and/or height of the canvas (the function is not executed if your program rather than the user resizes the canvas):
GlowScript 2.6 VPython
b = box()
def R(ev):
# ev.event is 'resize', ev.canvas is the resized canvas:
print(ev.event, scene.width, scene.height)
scene.bind('resize', R)
Andrew Morrison improved graph xtitle and ytitle to appear below and to the left of the graph rather than above the graph.
GlowScript 2.6 incorporates an update by Kovid Goyal to RapydScript-NG, the Python-to-JavaScript transpiler used by GlowScript, to support class variables (that is, variables that are shared by all instances of the class). Here is an example of what is now possible in GlowScript, which has always worked in standard Python:
class f:
names = []
def __init__(self, name):
f.names.append(name)
@staticmethod
def report():
s = 'REPORT\n'
for i,name in enumerate(f.names):
s += ' {}): {}\n'.format(i+1,name)
return s
a = f('Alice')
b = f('Bob')
print(f.names)
print(f.report())