forked from protonphoton/LJ
74 lines
1.8 KiB
Python
74 lines
1.8 KiB
Python
|
|
||
|
#!/usr/bin/python3
|
||
|
# -*- coding: utf-8 -*-
|
||
|
# -*- mode: Python -*-
|
||
|
|
||
|
|
||
|
'''
|
||
|
|
||
|
This generator print different squar from big to small.
|
||
|
The purepose is to see the difference of brightness with the length
|
||
|
|
||
|
v0.1.0
|
||
|
|
||
|
LICENCE : CC
|
||
|
|
||
|
by lapin (aka nipal)
|
||
|
|
||
|
'''
|
||
|
|
||
|
from __future__ import print_function
|
||
|
import time
|
||
|
import argparse
|
||
|
import sys
|
||
|
import math
|
||
|
|
||
|
name="generator::endingPoint"
|
||
|
|
||
|
|
||
|
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))
|
||
|
|
||
|
width = 800
|
||
|
height = 800
|
||
|
offset = 50
|
||
|
|
||
|
white = 0xFFFFFF
|
||
|
blank = 0x0
|
||
|
|
||
|
shape = []
|
||
|
|
||
|
def set_shape():
|
||
|
nb_spire = int(width / (2 * offset)) - 1
|
||
|
for i in range(1, nb_spire + 1):
|
||
|
shape.append([ i * offset, i * offset, blank])
|
||
|
shape.append([ i * offset, i * offset, white])
|
||
|
shape.append([ i * offset, height - i * offset, white])
|
||
|
shape.append([width - i * offset, height - i * offset, white])
|
||
|
shape.append([width - i * offset, i * offset, white])
|
||
|
shape.append([ i * offset, i * offset, white])
|
||
|
shape.append([ i * offset, i * offset, blank])
|
||
|
|
||
|
set_shape()
|
||
|
|
||
|
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))
|