How does Shoebot 1 decide to render a single image or run an animation ?

Stu's Avatar


03 May, 2020 11:35 AM

How does Nodebox 1 decide whether a bot is an animation or a still image.

In our Shoebot, I think we toggle on whether there is a "draw" function, but I've seen other info that it might be calling speed() with a number > 0 that enables it.

This should help me remove some of the less sane code in Shoebot :)

  1. 1 Posted by karstenwo on 03 May, 2020 12:37 PM

    karstenwo's Avatar

    In file, in class NodeboxRunner method _check_animation() is self-explanatory.

    See also usages of this method.

  2. 2 Posted by Stu on 03 May, 2020 05:27 PM

    Stu's Avatar

    Ah, great - I was thinking that having speed with a default of None might be a way of implementing this.

    Reassuring to see I was thinking along similar lines.

    This is definitely enough to write some unit tests for Shoebot so our implementation is compatible.

  3. 3 Posted by Stu on 03 May, 2020 05:32 PM

    Stu's Avatar

    While you're here: the canvas vs context distinction always confused me, is it that the graphics "context" is the current state, of graphics, while canvas is the thing it paints on ?

  4. 4 Posted by karstenwo on 03 May, 2020 06:31 PM

    karstenwo's Avatar

    Hey, I only keep it alive ;-) and write some new stuff; occasionally. "context" is the current state

    Yes. It's in nodebox/graphics/ and should be adaptable to Shoe with minimal changes

    ...while canvas is the thing it paints on...
    Yes. And it has connections to the Cocoa framework

    If you look in my fork here

    you'l see all the Cocoa functions that are used.

  5. 5 Posted by Stu on 03 May, 2020 08:31 PM

    Stu's Avatar


    I'll probably implement the same logic, but with tests, the code is pretty different + I'm working to gradually remove the weirder code (that I added about 7 years ago!).

    BTW, for Shoebot I've started to add unit tests, including some assertions around image correctness, there stuff you can find useful

    BTW, is _ctx when running a nodebox script, the same context ?

    For the longest time, I've been working on this + not really understanding the nodebox codebase :) (I may be main dev, but I didn't start this project).

    I feel like if I worker on it for long enough the codebase would end up looking like Nodeboxes exactly, but for now I'm happy to fix up the bugs and weirdness + maybe get it to the next release.

  6. 6 Posted by karstenwo on 03 May, 2020 09:30 PM

    karstenwo's Avatar

    _ctx is the connection to the canvas for ximported libs. It's the Context() that is created when a nodebox script is run.

    class NodeBoxRunner(object):
        def __init__(self):
            self.canvas = graphics.Canvas()
            self.context = graphics.Context(self.canvas, self.namespace)

        def _initNamespace(self, frame=1):
            # Add everything from the namespace
            for name in graphics.__all__:
                self.namespace[name] = getattr(graphics, name)
            for name in util.__all__:
                self.namespace[name] = getattr(util, name)
            # Add everything from the context object
            self.namespace["_ctx"] = self.context

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

16 May, 2024 02:11 AM
16 May, 2024 01:58 AM
14 May, 2024 01:29 AM
13 May, 2024 12:36 AM
12 May, 2024 07:46 PM


05 May, 2024 04:38 PM
03 May, 2024 06:50 AM
03 May, 2024 12:30 AM
03 May, 2024 12:09 AM
19 Apr, 2024 04:41 AM
16 Apr, 2024 06:18 PM