Skip to content
Browse files

rainbow2d: Simplify

  • Loading branch information...
pasky committed Dec 30, 2013
1 parent da77b81 commit 27f2540dcc1b9ff4783f9cf2a6fa530fe9121583
Showing with 6 additions and 16 deletions.
  1. +6 −16 host_python/
@@ -35,23 +35,13 @@ def lint(x, points, values):
def set_pixel_2d(bar, x, y, r, g, b):
bar.set_pixel(WIDTH - x - 1 + y*WIDTH, r, g, b)

def combine(*fncs):
return lambda *args: reduce(
lambda acc,fnc:(fnc(*acc),),

def flip(f):
return lambda *a: f(*reversed(a))

def cdist(center, point, scale):
from operator import add,sub
from math import sqrt
from functools import partial
return scale*sqrt(reduce(add, map(combine(partial(flip(pow),2),sub),center,point)))
dist = math.sqrt(reduce(
lambda a,b: a+b,
map(lambda (x,y): (x-y)**2, zip(center,point))
dist = dist*scale
return dist

l = Ledbar(PIXELS)

0 comments on commit 27f2540

Please sign in to comment.
You can’t perform that action at this time.