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

screensaver #409

Merged
merged 2 commits into from
Oct 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified tulip/fs/ex/g/tulipbw.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
69 changes: 69 additions & 0 deletions tulip/fs/ex/screensaver.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import tulip, random, time

every = 2500
last = tulip.ticks_ms()-every
play = True

def r(u):
return random.randint(0,u)

def draw():
tulip.bg_clear(36)
x = r(1024-128)
y = r(600-128)
tulip.bg_png(tulip.root_dir()+"sys/ex/g/tulipbw.png", x,y)
c0, c1, c2 = r(255)+1, r(255)+1, r(255)+1
if(c0 == 36): c0 = 35
if(c1 == 36): c1 = 35
if(c2 == 36): c2 = 35
tulip.bg_fill(x+50, y+60, c0)
tulip.bg_fill(x+30, y+60, c1)
tulip.bg_fill(x+95, y+60, c2)


def cb(x):
global last, every
if(tulip.ticks_ms()-last > every):
draw()
last = tulip.ticks_ms()

def touchcb(up):
global play
if(not up):
play = False

def keycb(key):
global play
play = False

tulip.tfb_stop()

tulip.frame_callback(cb)

tulip.keyboard_callback(keycb)
tulip.touch_callback(touchcb)

while play:
pass

tulip.frame_callback()
tulip.keyboard_callback()
tulip.touch_callback()

tulip.bg_clear()

tulip.tfb_start()














Loading