LJ/clitools/generators/dummy.py

86 lines
2.0 KiB
Python
Executable File

#!/usr/bin/python3
# -*- coding: utf-8 -*-
# -*- mode: Python -*-
'''
This is the most basic generator you can imagine: straight up static!
v0.1.0
Use it to test your filters and outputs
LICENCE : CC
by cocoa
'''
from __future__ import print_function
import time
import argparse
import sys
name="generator::dummy"
def debug(*args, **kwargs):
if( verbose == False ):
return
print(*args, file=sys.stderr, **kwargs)
argsparser = argparse.ArgumentParser(description="dummy generator")
argsparser.add_argument("-f","--fps",help="Frame Per Second",default=30,type=int)
argsparser.add_argument("-s","--speed",help="point per frame progress",default=3,type=int)
argsparser.add_argument("-v","--verbose",action="store_true",help="Verbose output")
args = argsparser.parse_args()
fps=args.fps
verbose=args.verbose
optimal_looptime = 1 / fps
debug(name+" optimal looptime "+str(optimal_looptime))
color = 16777215
square = [[100.0, 100.0, color], [100.0, 500.0, color], [500.0, 500.0, color], [500.0, 100.0, color], [100.0, 100.0, color]]
line =[]
for i in range(00,800,int(800/120)):
line.append([i, 400, color])
square = [[100.0, 100.0, color], [100.0, 500.0, color], [500.0, 500.0, color], [500.0, 100.0, color], [100.0, 100.0, color]]
mire = [
[600,600,0],
[600,600,color],
[700,600,color],
[700,700,color],
[600,700,color],
[600,600,color],
[100,100,0],
[100,100,color],
[200,100,color],
[200,200,color],
[100,200,color],
[100,100,color],
[0,0,0],
[0,0,color],
[800,0,color],
[800,800,color],
[0,800,color],
[0,0,color],
[350,400,0],
[350,400,color],
[450,400,color],
[400,350,0],
[400,350,color],
[400,450,color],
]
shape = mire
while True:
start = time.time()
print(shape, flush=True);
looptime = time.time() - start
if( looptime < optimal_looptime ):
time.sleep( optimal_looptime - looptime)
debug(name+" micro sleep:"+str( optimal_looptime - looptime))