forked from protonphoton/LJ
Lapin
f3314441d3
the feature implement a paper: https://art-science.org/journal/v7n4/v7n4pp155/artsci-v7n4pp155.pdf there is some generator to test the optimisation in: ./clitools/generators/drawingTests/ Now, all the optimisation will be in ./libs3/plotOptimizer.py in ./libs3/tracer3.py the adding of point is avoid an will be replace by the optimisation from the paper
99 lines
2.4 KiB
Python
99 lines
2.4 KiB
Python
#!/usr/bin/python3
|
|
# -*- coding: utf-8 -*-
|
|
# -*- mode: Python -*-
|
|
|
|
|
|
'''
|
|
|
|
This generator print different angle form 0 to 180 degres
|
|
|
|
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
|
|
|
|
white = 0xFFFFFF
|
|
blank = 0
|
|
|
|
radius = 100
|
|
offset_circles = 10
|
|
beg_angle = 0
|
|
end_angle = 90
|
|
offset_angle = 10
|
|
|
|
angles_lines = []
|
|
shape = []
|
|
|
|
def set_angles_lines():
|
|
margin = radius + offset_circles
|
|
spacing_betwen = 2 * radius + offset_circles
|
|
circles_per_line = math.floor((width - margin) / spacing_betwen)
|
|
|
|
for ang in range(beg_angle, end_angle + offset_angle, offset_angle):
|
|
nb = int(ang / offset_angle)
|
|
cx = margin + (nb % circles_per_line) * spacing_betwen
|
|
cy = margin + int(nb / circles_per_line) * spacing_betwen
|
|
|
|
px = radius * math.cos(math.radians(ang))
|
|
py = radius * math.sin(math.radians(ang))
|
|
|
|
# line up
|
|
angles_lines.append([-px + cx, py + cy, blank])
|
|
angles_lines.append([-px + cx, py + cy, white])
|
|
angles_lines.append([ cx, 2 + cy, white])
|
|
angles_lines.append([ px + cx, py + cy, white])
|
|
#angles_lines.append([ px + cx, py + cy, blank])
|
|
|
|
# line down
|
|
angles_lines.append([-px + cx, -py + cy, blank])
|
|
angles_lines.append([-px + cx, -py + cy, white])
|
|
angles_lines.append([ cx, -2 + cy, white])
|
|
angles_lines.append([ px + cx, -py + cy, white])
|
|
#angles_lines.append([ px + cx, -py + cy, blank])
|
|
|
|
|
|
set_angles_lines()
|
|
|
|
shape = angles_lines
|
|
# print(angles_lines)
|
|
|
|
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))
|
|
|