GlowScript 2.6

90 views
Skip to first unread message

Bruce Sherwood

unread,
Aug 1, 2017, 10:35:40 AM8/1/17
to Glowscript Users
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):
        self.name = 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())

Bruce Sherwood

unread,
Aug 3, 2017, 1:57:07 PM8/3/17
to Glowscript Users
Stimulated by Andrew Morrison's improvement in graph titles, I noticed that the font size for graph labels was rather small and not very readable, so GlowScript 2.6 now uses a slightly larger font that is more readable.

Bruce Sherwood

unread,
Aug 4, 2017, 10:19:14 AM8/4/17
to Glowscript Users
Further improvements to graphs in GlowScript 2.6: Setting title, xtitle, and ytitle has been improved, with improved documentation, and deleting a graph also deletes the title, which was not true in the past.

Note that in a graph title, as in scene.title or scene.caption, you can use html coding, such as "This is a <b>test</b>", in which "test" is bold. This is not currently possible with xtitle or ytitle.
Reply all
Reply to author
Forward
0 new messages