[feat in progress]: drawing improvment

I understand the previous way to add Point.
I have read the paper who describe the way to add point.
I'm doing the the visual witch are used in the paper to test the
optimisation.
This commit is contained in:
lapin 2020-12-06 12:45:25 +01:00
parent 45c263d3d2
commit 74ba0e828b
4 changed files with 205 additions and 11 deletions

2
.gitignore vendored
View File

@ -1,3 +1,3 @@
.*swp* .*sw*
*__pycache__ *__pycache__
www/config.js www/config.js

View File

@ -0,0 +1,94 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# -*- mode: Python -*-
'''
This generator print different engle 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 = 0xFFFF
blank = 0
radius = 70
offset_circles = 12
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(0, 180 + 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, white])
angles_lines.append([ cx, 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, white])
angles_lines.append([ cx, 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))

View File

@ -0,0 +1,77 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# -*- mode: Python -*-
'''
This generator print 3 static vertical line.
The aim is to show The aim is to show the laser beam ignition time.
beam when ther is no optimisation
v0.1.0
LICENCE : CC
by lapin (aka nipal)
'''
from __future__ import print_function
import time
import argparse
import sys
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))
white = 0xFFFFFF
blank = 0
offset_y = 100
offset_x = 50
begin_x = 200
begin_y = 200
shape_factor = [
[0, 0, white],
[0, 1, blank],
[1, 1, white],
[1, 0, blank],
[2, 0, white],
[2, 1, blank],
[2, 1, blank],
]
shape = []
for point in shape_factor:
shape.append([begin_x + offset_x * point[0],
begin_y + offset_y * point[1],
point[2]])
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))

View File

@ -223,12 +223,23 @@ class DAC(object):
while True: while True:
#pdb.set_trace() print("\n\n\n\t\t^^^^")
### here self.pl has all the point in one frame
#pdb.set_trace()
### print(self.pl)
### <<<< On peut introduire ici l'autre optimisation
for indexpoint,currentpoint in enumerate(self.pl): for indexpoint,currentpoint in enumerate(self.pl):
#print indexpoint, currentpoint print(indexpoint, currentpoint)
xyc = [currentpoint[0],currentpoint[1],currentpoint[2]] xyc = [currentpoint[0],currentpoint[1],currentpoint[2]]
self.xyrgb = self.EtherPoint(xyc) self.xyrgb = self.EtherPoint(xyc)
#print(self.xyrgb[2:])
### ### print("1-\nxyrgb[2:]")
### ### print(self.xyrgb[2:])
### print("VVxyrgb")
### print(self.xyrgb)
### print("\n")
rgb = (round(self.xyrgb[2:][0] *self.intred/100), round(self.xyrgb[2:][1] *self.intgreen/100), round(self.xyrgb[2:][2] *self.intblue/100)) rgb = (round(self.xyrgb[2:][0] *self.intred/100), round(self.xyrgb[2:][1] *self.intgreen/100), round(self.xyrgb[2:][2] *self.intblue/100))
#print("rgb :", rgb) #print("rgb :", rgb)
@ -239,27 +250,39 @@ class DAC(object):
delta_x, delta_y = self.xyrgb[0] - self.xyrgb_prev[0], self.xyrgb[1] - self.xyrgb_prev[1] delta_x, delta_y = self.xyrgb[0] - self.xyrgb_prev[0], self.xyrgb[1] - self.xyrgb_prev[1]
#test adaptation selon longueur ligne #test adaptation selon longueur ligne
print("delta_x: "+str(delta_x) + "\t\tdelta_y: "+str(delta_y))
print("norme delta:\t" + str(math.hypot(delta_x, delta_y)))
if math.hypot(delta_x, delta_y) < 4000: if math.hypot(delta_x, delta_y) < 4000:
# For glitch art : decrease lsteps # For glitch art : decrease lsteps
#l_steps = [ (1.0, 8)] #l_steps = [ (1.0, 8)]
print("little line")
l_steps = gstt.stepshortline l_steps = gstt.stepshortline
else: else:
# For glitch art : decrease lsteps # For glitch art : decrease lsteps
#l_steps = [ (0.25, 3), (0.75, 3), (1.0, 10)] #l_steps = [ (0.25, 3), (0.75, 3), (1.0, 10)]
l_steps = gstt.stepslongline l_steps = gstt.stepslongline
print("big line")
print(l_steps)
for e in l_steps: ### print("\n\nl_step:")
step = e[0] ### print(l_steps)
pAdd = 0
### *** ###for e in l_steps:
### *** ### step = e[0]
for i in range(0,e[1]): ### *** ### for i in range(0,e[1]):
### *** ### pAdd +=1
self.xyrgb_step = (self.xyrgb_prev[0] + step*delta_x, self.xyrgb_prev[1] + step*delta_y) + rgb # + self.xyrgb_prev[2:]# + rgb ### *** ### self.xyrgb_step = (self.xyrgb_prev[0] + step*delta_x, self.xyrgb_prev[1] + step*delta_y) + rgb # + self.xyrgb_prev[2:]# + rgb
#print(self.xyrgb_step) ### *** ### #print(self.xyrgb_step)
yield self.xyrgb_step ### *** ### yield self.xyrgb_step
yield (self.xyrgb[0], self.xyrgb[1]) + rgb
self.xyrgb_prev = self.xyrgb self.xyrgb_prev = self.xyrgb
print("point added:\t" + str(pAdd))
print("\n")
def GetPoints(self, n): def GetPoints(self, n):