#!/usr/bin/python3 # -*- coding: utf-8 -*- # -*- mode: Python -*- ''' This generator print a shape with 3 discinected component, 2 non eulerian and one eulerian. 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) def debug2(*args, **kwargs): 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 white = 0xFFFFFF blank = 0 def shape_scale(shape, scale_factor): new_shape = [] for p in shape: new_shape.append([p[0] * scale_factor, p[1] * scale_factor, p[2]]) return new_shape def shape_incr(shape, x, y): new_shape = [] for p in shape: new_shape.append([p[0] + x, p[1] + y, p[2]]) return new_shape comp_a = [] comp_b = [] comp_c = [] comp_b.append([ 0, 3, blank]) comp_b.append([ 0, 4, white]) comp_b.append([ 0, 0, white]) comp_b.append([ 3, 0, white]) comp_b.append([ 3, 6, white]) comp_b.append([ 3, 6, white]) comp_b.append([ 3, 0, white]) comp_b.append([ 3, 0, blank]) comp_b.append([ 3, 0, white]) comp_b.append([ 5, 4, white]) comp_b.append([ 5, 4, blank]) comp_a.append([ 5, 17, blank]) comp_a.append([ 5, 17, white]) comp_a.append([ 0, 5, white]) comp_a.append([12, 0, white]) comp_a.append([17, 12, white]) comp_a.append([ 5, 17, white]) comp_a.append([ 5, 17, blank]) comp_c.append([-3, 5, blank]) comp_c.append([-3, 5, white]) comp_c.append([ 0, 4, white]) comp_c.append([ 0, 0, white]) comp_c.append([ 4, 0, white]) comp_c.append([ 4, 4, white]) comp_c.append([ 7, 5, white]) comp_c.append([ 7, 5, blank]) comp_a = shape_scale(comp_a, 11) comp_a = shape_incr(comp_a, 300, 75) comp_b = shape_scale(comp_b, 45) comp_b = shape_incr(comp_b, 0, 300) comp_c = shape_scale(comp_c, 30) comp_c = shape_incr(comp_c, 600, 300) shape = comp_a + comp_b + comp_c 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))