Fix cpu/speed, beta-version

main
none 1 year ago
parent 1faf6301b6
commit 19eadd9d81

@ -10,34 +10,35 @@ global server
#server = 'http://127.0.0.1:3333' #server = 'http://127.0.0.1:3333'
server = 'http://pb.gulyaipole.fun' server = 'http://pb.gulyaipole.fun'
# 0,0, 10,10, [0,0,0] # fill(0,0, 10,10, [0,0,0])
def fill(x1,y1, x2,y2, color): def fill(x1,y1, x2,y2, color):
pxls = [] pxls = []
r = color[0] ; g = color[1] ; b = color[2] r = color[0] ; g = color[1] ; b = color[2]
for x in range(x1, x2+1): for x in range(x1, x2+1):
for y in range(y1, y2+1): for y in range(y1, y2+1):
pxls.append([x, y, r, g, b]) pxls.append([x, y, r, g, b])
#packed = {"main": pack(pxls)}
return pxls return pxls
# draw( fill(...) ) # draw( fill(...) )
def draw(pxls): def draw(pxls):
global server global server
# Pack to 50 elements
push = [] push = [] # Push %limit% items
while len(pxls) > 100: limit = 300
packs = [] while len(pxls) > limit:
for i in range(100): packs = [] # Merge elements to %limit% size list
for i in range(limit):
# Take first element
packs.append(pxls[0]) packs.append(pxls[0])
pxls.pop(0) pxls.pop(0)
push.append(pack(packs)) push.append({"main": pack(packs)})
push.append(pack(pxls)) # pack last push.append({"main": pack(pxls)}) # Pack last
for i in tqdm(push): for i in tqdm(push):
response = requests.post(server, {"main": i}) response = requests.post(server, i)
while not response.text: while not response.status_code == 200:
print("Error, retrying...") print("Error, retrying...")
response = requests.post(server, {"main": i}) response = requests.post(server, i)
# cfill(0,0, 10,10) # cfill(0,0, 10,10)
def cfill(x1,y1, x2,y2): def cfill(x1,y1, x2,y2):
@ -56,7 +57,7 @@ def ccheck(packed):
return out return out
from random import randint as ri from random import randint as ri
print( draw( fill(0,0, 10,10, [ri(0,255),ri(0,255),ri(0,255)]) ) ) draw( fill(0,0, 100,100, [ri(0,255),ri(0,255),ri(0,255)]) )
#print(ccheck(pack([[0,0]]) )) #print(ccheck(pack([[0,0]]) ))
#print(ccheck(cfill(0,0, 10,10))) #print(ccheck(cfill(0,0, 10,10)))

Loading…
Cancel
Save