Skip to content

Commit

Permalink
added limits checking in acabsl
Browse files Browse the repository at this point in the history
  • Loading branch information
schneider42 committed May 31, 2013
1 parent d9b503b commit 33e1d3a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 28 deletions.
17 changes: 9 additions & 8 deletions acabsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,18 @@ def set_target(host, port):
UDPPORT = port

def send(x,y,r,g,b,t=0,w=WALL):
w=int(w)
x=int(x)
y=int(y)
r=int(r)
g=int(g)
b=int(b)
ms = int(t * 1000)
w = max(0,int(w))
x = max(0,int(x))
y = max(0,int(y))

r = min(max(0,int(r)),255)
g = min(max(0,int(g)),255)
b = min(max(0,int(b)),255)
ms = min(max(0, int(t * 1000)),65536)

# recalculate x and y based on input x,y and wall no w
x=((w*WALLSIZEX)+x)

print x,y,r,g,b,ms>>8,ms&0xFF
msg = "%c%cC%c%c%c%c%c"%(x,y,r,g,b,ms>>8,ms&0xFF)
sock.sendto(msg, (UDPHOST, UDPPORT))

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from acabsl_legacy import send
from acabsl_legacy import update
import acabsl
from acabsl import send
from acabsl import update

import colorsys
import random
import time
Expand All @@ -14,11 +16,12 @@ def setcol(col, r, g, b, time):
h = 0
col = 0

midcol = 8
midrow = 2
midcol = acabsl.WALLSIZEX/2
midrow = acabsl.WALLSIZEY/2

maxdist = 0
for row in range(0,8):
for col in range(0,20):
for row in range(0,acabsl.WALLSIZEY):
for col in range(0,acabsl.WALLSIZEX):
dc = col - midcol
dr = row - midrow
dist = math.sqrt(dc**2+dr**2)
Expand All @@ -28,16 +31,16 @@ def setcol(col, r, g, b, time):
hoffset = 0
update()
while 1:
midcol = min(14,max(1, midcol + random.gauss(0,0.1)))
midrow = min(4,max(1, midrow + random.gauss(0,0.1)))
midcol = min(acabsl.WALLSIZEX-2,max(1, midcol + random.gauss(0,0.1)))
midrow = min(acabsl.WALLSIZEY-2,max(1, midrow + random.gauss(0,0.1)))

#hoffset += random.gauss(0.01,0.02)
hoffset += 0.03
hoffset = hoffset % 1.
#t = time.time()

for row in range(0,6):
for col in range(0,16):
for row in range(0,acabsl.WALLSIZEY):
for col in range(0,acabsl.WALLSIZEX):
dc = col - midcol
dr = row - midrow
dist = math.sqrt(dc**2+dr**2)/maxdist
Expand Down
23 changes: 13 additions & 10 deletions animations/legacy/s-color4.py → animations/s-color4.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from acabsl_legacy import send
from acabsl_legacy import update
import acabsl
from acabsl import send
from acabsl import update

import colorsys
import random
import time
Expand All @@ -14,11 +16,12 @@ def setcol(col, r, g, b, time):
h = 0
col = 0

midcol = 8
midrow = 2
midcol = acabsl.WALLSIZEX/2
midrow = acabsl.WALLSIZEY/2

maxdist = 0
for row in range(0,8):
for col in range(0,20):
for row in range(0,acabsl.WALLSIZEY):
for col in range(0,acabsl.WALLSIZEX):
dc = col - midcol
dr = row - midrow
dist = math.sqrt(dc**2+dr**2)
Expand All @@ -28,16 +31,16 @@ def setcol(col, r, g, b, time):
hoffset = 0
update()
while 1:
midcol = min(14,max(1, midcol + random.gauss(0,0.1)))
midrow = min(4,max(1, midrow + random.gauss(0,0.1)))
midcol = min(acabsl.WALLSIZEX-2,max(1, midcol + random.gauss(0,0.1)))
midrow = min(acabsl.WALLSIZEY-2,max(1, midrow + random.gauss(0,0.1)))

#hoffset += random.gauss(0.01,0.02)
hoffset += 0.03
hoffset = hoffset % 1.
#t = time.time()

for row in range(0,6):
for col in range(0,16):
for row in range(0,acabsl.WALLSIZEY):
for col in range(0,acabsl.WALLSIZEX):
dc = col - midcol
dr = row - midrow
dist = math.sqrt(dc**2+dr**2)/maxdist
Expand Down

0 comments on commit 33e1d3a

Please sign in to comment.