Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement print function can work in draw method #76

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ckski
Copy link
Contributor

@ckski ckski commented Nov 16, 2020

The print output for each frame is accumulated and drawn only once per frame overriding the output from the previous frame. If the output is identical to the previous frame then no update happens (this prevents flickering).

The print output for each frame is accumulated and drawn only once per frame overriding the output from the previous frame. If the output is identical to the previous frame then no update happens (this prevents flickering).
@AlphaRLee
Copy link
Member

I found one weird edge case - if a user defines their own variable frame_count and tries to re-assign it, then the print buffer will revert to its old behaviour. I stumbled into this because I forgot that frame_count was a private variable and I was tryign to set a value on it as a public variable.

%%ignite

# Reset frame_count to 0 when it reaches 50

frame_count = 0

def setup():
    size(300, 300)
    background("aqua")
    
def draw():
    global frame_count
    
    if frame_count > 50:
        frame_count = 50
    print(frame_count)

image

@AlphaRLee
Copy link
Member

I think the bug I found (see above) doesn't need to be fixed right now, but we still need docs on the frame_count variable before this PR can be merged in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants