grayscale & divergenza in Y
This commit is contained in:
parent
46a065d3d4
commit
dfb9aef6f7
2 changed files with 56 additions and 42 deletions
20
cfg.ini
20
cfg.ini
|
@ -2,14 +2,16 @@
|
||||||
FG_R_COLOR = 0.0
|
FG_R_COLOR = 0.0
|
||||||
FG_G_COLOR = 0.0
|
FG_G_COLOR = 0.0
|
||||||
FG_B_COLOR = 0.0
|
FG_B_COLOR = 0.0
|
||||||
ServerAliveInterval = 45
|
PAGE_W = 3508
|
||||||
Compression = yes
|
PAGE_H = 2480
|
||||||
CompressionLevel = 9
|
OFFSET_X = 100
|
||||||
ForwardX11 = yes
|
OFFSET_Y = 500
|
||||||
|
GRID_W = 24
|
||||||
|
GRID_H = 13
|
||||||
|
SQUARE_SIZE=100
|
||||||
|
|
||||||
[bitbucket.org]
|
|
||||||
User = hg
|
|
||||||
|
|
||||||
[topsecret.server.com]
|
RANDOM_STEP = 0.01
|
||||||
Port = 50022
|
DAMPEN = 2.25
|
||||||
ForwardX11 = no
|
LINE_WIDTH = 5
|
||||||
|
|
||||||
|
|
|
@ -16,31 +16,44 @@ def plotSquares(ctx):
|
||||||
for i in range(0,w-1):
|
for i in range(0,w-1):
|
||||||
rsum += i*rs # add to the random value
|
rsum += i*rs # add to the random value
|
||||||
ctx.save()
|
ctx.save()
|
||||||
ctx.translate(s*i+1.1**i*dp, 0)
|
ctx.translate(s*i + deltaX(i), 0)
|
||||||
for j in range(0,h-1):
|
for j in range(0,h):
|
||||||
|
#
|
||||||
rv = random.uniform(-rsum, rsum)
|
rv = random.uniform(-rsum, rsum)
|
||||||
# here comes the box :-)
|
print str(abs(rv))
|
||||||
#box = shapes.square(s)
|
#grey = translate(abs(rv),0,2,0,0.7)
|
||||||
|
#ctx.set_source_rgb(grey,grey,grey)
|
||||||
# box position
|
|
||||||
#curr_cx = - w*s/2 + i*s + rv*dp ; curr_cy = - h*s/2 + j*s + rv*dp
|
|
||||||
# transforms.center_at(box, [curr_cx, curr_cy])
|
|
||||||
#
|
|
||||||
# # rotate the box of rv degrees around its center
|
|
||||||
# transforms.rotate(box, rv, pivot=(curr_cx, curr_cy))
|
|
||||||
# draw the damn box
|
|
||||||
# plotter.write(box)
|
|
||||||
#
|
|
||||||
#ctx.rotate(math.pi * 1 / 4)
|
|
||||||
ctx.translate(0, s)
|
|
||||||
ctx.save()
|
ctx.save()
|
||||||
|
#remove 0 or relace it with 1 if ypu want Y devercence
|
||||||
|
ctx.translate(0, s*j + deltaY(i,j) * 0.8 )
|
||||||
ctx.rotate(rv)
|
ctx.rotate(rv)
|
||||||
ctx.rectangle(0,0, s, s)
|
ctx.rectangle(s/2,s/2, s, s)
|
||||||
ctx.restore()
|
ctx.restore()
|
||||||
ctx.stroke()
|
ctx.stroke()
|
||||||
|
#ctx.fill()
|
||||||
ctx.restore()
|
ctx.restore()
|
||||||
|
|
||||||
|
def deltaY(i,j):
|
||||||
|
# return float(1.1*translate(j,0,h-1,-i*0.3,i*0.3)**2)
|
||||||
|
# print "nterpolazione di "+ str(j) + " : " + str(translate(j,-h/2,h/2,-math.pi/2,math.pi/2))
|
||||||
|
# return float(math.tan(translate(j,0,h-1,-math.pi/2,math.pi/2)))
|
||||||
|
return float(math.tan(translate(j,0,h,-1.37,1.56))*i)
|
||||||
|
|
||||||
|
def deltaX(i):
|
||||||
|
return float(1.31**i*dp)
|
||||||
|
|
||||||
|
def translate(value, leftMin, leftMax, rightMin, rightMax):
|
||||||
|
# Figure out how 'wide' each range is
|
||||||
|
leftSpan = leftMax - leftMin
|
||||||
|
rightSpan = rightMax - rightMin
|
||||||
|
|
||||||
|
# Convert the left range into a 0-1 range (float)
|
||||||
|
valueScaled = float(value - leftMin) / float(leftSpan)
|
||||||
|
|
||||||
|
# Convert the 0-1 range into a value in the right range.
|
||||||
|
if(value==h/2):
|
||||||
|
return 0
|
||||||
|
return rightMin + (valueScaled * rightSpan)
|
||||||
|
|
||||||
if len(sys.argv) < 2:
|
if len(sys.argv) < 2:
|
||||||
print("Plz specify output file as argument")
|
print("Plz specify output file as argument")
|
||||||
|
@ -49,27 +62,26 @@ if len(sys.argv) < 2:
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
config.read('cfg.ini')
|
config.read('cfg.ini')
|
||||||
#float RGB touple
|
#float RGB touple
|
||||||
FG_RGB_COLOR=(config['DEFAULT']['FG_R_COLOR'],config['DEFAULT']['FG_G_COLOR'],config['DEFAULT']['FG_B_COLOR'])
|
FG_RGB_COLOR=(float(config['DEFAULT']['FG_R_COLOR']),float(config['DEFAULT']['FG_G_COLOR']),float(config['DEFAULT']['FG_B_COLOR']))
|
||||||
print type(config['DEFAULT']['FG_R_COLOR'])
|
|
||||||
#A4 in 300 DPI
|
#A4 in 300 DPI
|
||||||
width, height = 3508,2480
|
width, height = int(config['DEFAULT']['PAGE_W']),int(config['DEFAULT']['PAGE_H'])
|
||||||
offsetX, offsetY = 100,500
|
offsetX, offsetY = int(config['DEFAULT']['OFFSET_X']),int(config['DEFAULT']['OFFSET_Y'])
|
||||||
|
|
||||||
w = 22 # width (how many squares - es. 22)
|
w = int(config['DEFAULT']['GRID_W']) # width (how many squares - es. 22)
|
||||||
h = 12 # height (how many squares - es. 12)
|
h = int(config['DEFAULT']['GRID_H']) # height (how many squares - es. 12)
|
||||||
s = 100 # square size (es. 15)
|
s = int(config['DEFAULT']['SQUARE_SIZE'])# square size (es. 15)
|
||||||
|
|
||||||
rs = 0.01 # random step (rotation increment in degrees)
|
rs = float(config['DEFAULT']['RANDOM_STEP']) # random step (rotation increment in degrees)
|
||||||
dp = 2.25 # dampen (soften random effect for position)
|
dp = float(config['DEFAULT']['DAMPEN']) # dampen (soften random effect for position)
|
||||||
rsum = 0 # dummy initial value for rsum
|
rsum = 0 # dummy initial value for rsum
|
||||||
|
|
||||||
line_width = 2
|
line_width = int(config['DEFAULT']['LINE_WIDTH'])
|
||||||
|
|
||||||
|
|
||||||
surface = cairo.PDFSurface (sys.argv[1],width,height)
|
surface = cairo.PDFSurface (sys.argv[1],width,height)
|
||||||
ctx = cairo.Context (surface)
|
ctx = cairo.Context (surface)
|
||||||
|
|
||||||
ctx.set_source_rgb(config['DEFAULT']['FG_R_COLOR'],config['DEFAULT']['FG_G_COLOR'],config['DEFAULT']['FG_B_COLOR'])
|
ctx.set_source_rgb(FG_RGB_COLOR[0],FG_RGB_COLOR[1],FG_RGB_COLOR[2],)
|
||||||
ctx.set_line_width(line_width)
|
ctx.set_line_width(line_width)
|
||||||
ctx.translate(offsetX, offsetY)
|
ctx.translate(offsetX, offsetY)
|
||||||
plotSquares(ctx)
|
plotSquares(ctx)
|
||||||
|
|
Loading…
Reference in a new issue