Mercurial > hg > mood-conductor
changeset 24:7de24ee1dbe0
merge
author | mgeorgi |
---|---|
date | Fri, 22 Jun 2012 17:48:22 +0100 |
parents | 9d57fcc848c0 (current diff) 858fc44a17c1 (diff) |
children | 1ca2b2822af1 |
files | |
diffstat | 2 files changed, 312 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/visualclient/colors.txt Fri Jun 22 17:48:22 2012 +0100 @@ -0,0 +1,257 @@ +x,y,r,g,b +0,1,200,0,0 +0.0625,1,200,9,0 +0.125,1,200,18,0 +0.1875,1,200,28,0 +0.25,1,200,37,0 +0.3125,1,200,46,0 +0.375,1,200,56,0 +0.4375,1,200,65,0 +0.5,1,200,75,0 +0.5625,1,200,84,0 +0.625,1,200,93,0 +0.6875,1,200,103,0 +0.75,1,200,112,0 +0.8125,1,200,121,0 +0.875,1,200,131,0 +0.9375,1,200,140,0 +0,0.9375,187,3,6 +0.0625,0.9375,187,12,5 +0.125,0.9375,188,22,5 +0.1875,0.9375,189,31,5 +0.25,0.9375,190,41,5 +0.3125,0.9375,191,50,5 +0.375,0.9375,191,60,5 +0.4375,0.9375,192,69,5 +0.5,0.9375,193,79,5 +0.5625,0.9375,194,88,5 +0.625,0.9375,195,98,5 +0.6875,0.9375,195,107,5 +0.75,0.9375,196,117,5 +0.8125,0.9375,197,126,5 +0.875,0.9375,198,136,5 +0.9375,0.9375,199,145,5 +0,0.875,175,6,12 +0.0625,0.875,176,15,11 +0.125,0.875,178,25,11 +0.1875,0.875,179,34,11 +0.25,0.875,181,44,11 +0.3125,0.875,182,54,11 +0.375,0.875,184,63,11 +0.4375,0.875,185,73,11 +0.5,0.875,187,83,11 +0.5625,0.875,189,92,10 +0.625,0.875,190,102,10 +0.6875,0.875,192,111,10 +0.75,0.875,193,121,10 +0.8125,0.875,195,131,10 +0.875,0.875,196,140,10 +0.9375,0.875,198,150,10 +0,0.8125,162,9,18 +0.0625,0.8125,164,18,17 +0.125,0.8125,166,28,17 +0.1875,0.8125,169,38,17 +0.25,0.8125,171,48,17 +0.3125,0.8125,173,57,17 +0.375,0.8125,176,67,16 +0.4375,0.8125,178,77,16 +0.5,0.8125,181,87,16 +0.5625,0.8125,183,96,16 +0.625,0.8125,185,106,16 +0.6875,0.8125,188,116,15 +0.75,0.8125,190,126,15 +0.8125,0.8125,192,135,15 +0.875,0.8125,195,145,15 +0.9375,0.8125,197,155,15 +0,0.75,150,12,25 +0.0625,0.75,153,21,24 +0.125,0.75,156,31,24 +0.1875,0.75,159,41,24 +0.25,0.75,162,51,23 +0.3125,0.75,165,61,23 +0.375,0.75,168,71,23 +0.4375,0.75,171,81,22 +0.5,0.75,175,91,22 +0.5625,0.75,178,100,22 +0.625,0.75,181,110,21 +0.6875,0.75,184,120,21 +0.75,0.75,187,130,21 +0.8125,0.75,190,140,20 +0.875,0.75,193,150,20 +0.9375,0.75,196,160,20 +0,0.6875,137,15,31 +0.0625,0.6875,140,25,30 +0.125,0.6875,144,35,30 +0.1875,0.6875,148,45,29 +0.25,0.6875,152,55,29 +0.3125,0.6875,156,65,29 +0.375,0.6875,160,75,28 +0.4375,0.6875,164,85,28 +0.5,0.6875,168,95,28 +0.5625,0.6875,172,105,27 +0.625,0.6875,176,115,27 +0.6875,0.6875,180,125,26 +0.75,0.6875,184,135,26 +0.8125,0.6875,188,145,26 +0.875,0.6875,192,155,25 +0.9375,0.6875,196,165,25 +0,0.625,125,18,37 +0.0625,0.625,129,28,36 +0.125,0.625,134,38,36 +0.1875,0.625,139,48,35 +0.25,0.625,143,58,35 +0.3125,0.625,148,68,34 +0.375,0.625,153,78,34 +0.4375,0.625,157,88,33 +0.5,0.625,162,99,33 +0.5625,0.625,167,109,33 +0.625,0.625,171,119,32 +0.6875,0.625,176,129,32 +0.75,0.625,181,139,31 +0.8125,0.625,185,149,31 +0.875,0.625,190,159,30 +0.9375,0.625,195,169,30 +0,0.5625,112,21,43 +0.0625,0.5625,117,31,42 +0.125,0.5625,123,41,42 +0.1875,0.5625,128,51,41 +0.25,0.5625,134,62,41 +0.3125,0.5625,139,72,40 +0.375,0.5625,145,82,40 +0.4375,0.5625,150,92,39 +0.5,0.5625,156,103,39 +0.5625,0.5625,161,113,38 +0.625,0.5625,167,123,38 +0.6875,0.5625,172,133,37 +0.75,0.5625,178,144,37 +0.8125,0.5625,183,154,36 +0.875,0.5625,189,164,36 +0.9375,0.5625,194,174,35 +0,0.5,100,25,50 +0.0625,0.5,106,35,49 +0.125,0.5,112,45,48 +0.1875,0.5,118,55,48 +0.25,0.5,125,66,47 +0.3125,0.5,131,76,46 +0.375,0.5,137,86,46 +0.4375,0.5,143,97,45 +0.5,0.5,150,107,45 +0.5625,0.5,156,117,44 +0.625,0.5,162,128,43 +0.6875,0.5,168,138,43 +0.75,0.5,175,148,42 +0.8125,0.5,181,159,41 +0.875,0.5,187,169,41 +0.9375,0.5,193,179,40 +0,0.4375,87,28,56 +0.0625,0.4375,94,38,55 +0.125,0.4375,101,48,54 +0.1875,0.4375,108,59,53 +0.25,0.4375,115,69,53 +0.3125,0.4375,122,80,52 +0.375,0.4375,129,90,51 +0.4375,0.4375,136,101,51 +0.5,0.4375,143,111,50 +0.5625,0.4375,150,121,49 +0.625,0.4375,157,132,49 +0.6875,0.4375,164,142,48 +0.75,0.4375,171,153,47 +0.8125,0.4375,178,163,47 +0.875,0.4375,185,174,46 +0.9375,0.4375,192,184,45 +0,0.375,75,31,62 +0.0625,0.375,82,41,61 +0.125,0.375,90,52,60 +0.1875,0.375,98,62,59 +0.25,0.375,106,73,59 +0.3125,0.375,114,83,58 +0.375,0.375,121,94,57 +0.4375,0.375,129,104,56 +0.5,0.375,137,115,56 +0.5625,0.375,145,126,55 +0.625,0.375,153,136,54 +0.6875,0.375,160,147,53 +0.75,0.375,168,157,53 +0.8125,0.375,176,168,52 +0.875,0.375,184,178,51 +0.9375,0.375,192,189,50 +0,0.3125,62,34,68 +0.0625,0.3125,70,44,67 +0.125,0.3125,79,55,66 +0.1875,0.3125,87,66,65 +0.25,0.3125,96,76,64 +0.3125,0.3125,105,87,63 +0.375,0.3125,113,98,63 +0.4375,0.3125,122,108,62 +0.5,0.3125,131,119,61 +0.5625,0.3125,139,130,60 +0.625,0.3125,148,140,59 +0.6875,0.3125,156,151,59 +0.75,0.3125,165,162,58 +0.8125,0.3125,174,172,57 +0.875,0.3125,182,183,56 +0.9375,0.3125,191,194,55 +0,0.25,50,37,75 +0.0625,0.25,59,47,74 +0.125,0.25,68,58,73 +0.1875,0.25,78,69,72 +0.25,0.25,87,80,71 +0.3125,0.25,96,91,70 +0.375,0.25,106,101,69 +0.4375,0.25,115,112,68 +0.5,0.25,125,123,67 +0.5625,0.25,134,134,66 +0.625,0.25,143,145,65 +0.6875,0.25,153,155,64 +0.75,0.25,162,166,63 +0.8125,0.25,171,177,62 +0.875,0.25,181,188,61 +0.9375,0.25,190,199,60 +0,0.1875,37,40,81 +0.0625,0.1875,47,50,80 +0.125,0.1875,57,61,79 +0.1875,0.1875,67,72,78 +0.25,0.1875,77,83,77 +0.3125,0.1875,87,94,76 +0.375,0.1875,98,105,75 +0.4375,0.1875,108,116,74 +0.5,0.1875,118,127,73 +0.5625,0.1875,128,138,72 +0.625,0.1875,138,149,71 +0.6875,0.1875,149,160,70 +0.75,0.1875,159,171,69 +0.8125,0.1875,169,182,68 +0.875,0.1875,179,193,67 +0.9375,0.1875,189,204,66 +0,0.125,25,43,87 +0.0625,0.125,35,54,85 +0.125,0.125,46,65,84 +0.1875,0.125,57,76,83 +0.25,0.125,68,87,82 +0.3125,0.125,79,98,81 +0.375,0.125,90,109,80 +0.4375,0.125,101,120,79 +0.5,0.125,112,131,78 +0.5625,0.125,123,142,77 +0.625,0.125,134,153,76 +0.6875,0.125,145,164,75 +0.75,0.125,156,175,74 +0.8125,0.125,167,186,73 +0.875,0.125,178,197,72 +0.9375,0.125,189,208,71 +0,0.0625,12,46,93 +0.0625,0.0625,23,57,91 +0.125,0.0625,35,68,90 +0.1875,0.0625,47,79,89 +0.25,0.0625,59,90,88 +0.3125,0.0625,70,101,87 +0.375,0.0625,82,113,86 +0.4375,0.0625,94,124,85 +0.5,0.0625,106,135,84 +0.5625,0.0625,117,146,82 +0.625,0.0625,129,157,81 +0.6875,0.0625,141,169,80 +0.75,0.0625,153,180,79 +0.8125,0.0625,164,191,78 +0.875,0.0625,176,202,77 +0.9375,0.0625,188,213,76
--- a/visualclient/visclient.py Fri Jun 22 17:47:09 2012 +0100 +++ b/visualclient/visclient.py Fri Jun 22 17:48:22 2012 +0100 @@ -30,12 +30,14 @@ # X,Y=1140,900 X,Y = 600,400 -BLOBSIZE = 20 +NBLOBS = 15 +BLOBSIZE = 25 G=110 +FADE = 15 class Blob(object): - def __init__(self,bg,x,y,color=(255,255,255),mood=None): + def __init__(self,bg,x,y,color=(255,255,255),mood=None,fade=FADE): self.x = x self.y = y self.xs = x * X @@ -47,6 +49,7 @@ self.c = color self.count = 1 self.visible = True + self.FADE = fade if mood and mood.color : self.c = mood.color @@ -60,7 +63,7 @@ def draw(self): d=int(self.size) self.bg.blit(gradients.radial(self.size, (self.c[0],self.c[1],self.c[2],self.alpha), (0,0,0,self.alpha)), (self.xs-d,self.ys-d)) - self.alpha = 255 - int(self.age()*15) + self.alpha = 255 - int(self.age()*self.FADE) if self.alpha < 5 : self.alpha = 1 self.visible = False @@ -69,11 +72,19 @@ return time.time() - self.time def increment(self,count): + self.time = time.time() self.count = count self.size = int(BLOBSIZE * int(self.count/1.5)) def get_distance(self,x,y): return math.sqrt( math.pow((self.x-x),2) + math.pow((self.y-y),2) ) + + def fade(self,fade): + if not fade : self.alpha = 255 + self.FADE = fade + + def reset_time(self): + self.time = time.time() @@ -120,6 +131,8 @@ # pg.quit() # sys.exit(-1) + self.FADE = FADE + pass def read_mood_data(self): @@ -130,19 +143,29 @@ l = line.split(',') mood = Mood(l[0],l[1],l[2]) self.moods.append(mood) - with open('feelings.txt') as ff: - data = ff.readlines() - data = map(lambda x: x.split('\t'),data) + # with open('feelings.txt') as ff: + # data = ff.readlines() + # data = map(lambda x: x.split('\t'),data) + # for mood in self.moods : + # for colors in data : + # if mood.word == colors[0] : + # mood.color = colors[2] + with open('colors.txt') as ff: + data = ff.readlines()[1:] + data = map(lambda x: x.split(','),data) for mood in self.moods : + d = cd = sys.float_info.max for colors in data : - if mood.word == colors[0] : - mood.color = colors[2] - pass - for mood in self.moods: - if mood.color : - mood.color = map(lambda x: '0x'+str(x).strip(),[mood.color[0:2],mood.color[2:4],mood.color[4:]]) - mood.color = tuple(map(lambda x: int(eval(x)),mood.color)) - # print mood.color + d = mood.get_distance(float(colors[0]),float(colors[1])) + if d < cd : + cd = d + mood.color = tuple(map(lambda x: int(pow(math.atan((float(x)/7.0)),12.5)),(colors[2],colors[3],colors[4]))) + + # for mood in self.moods: + # if mood.color : + # # mood.color = map(lambda x: '0x'+str(x).strip(),[mood.color[0:2],mood.color[2:4],mood.color[4:]]) + # mood.color = tuple(map(lambda x: int(x),mood.color)) + # print mood.color def update(self): @@ -174,14 +197,14 @@ cd = d cmood = mood - new = Blob(self.bg,x,y,mood=cmood) + new = Blob(self.bg,x,y,mood=cmood,fade=self.FADE) if not new in self.blobs : self.blobs.insert(0,new) elif c > self.blobs[self.blobs.index(new)].count: self.blobs[self.blobs.index(new)].increment(c) self.conn.close() - self.blobs = self.blobs[:5] + self.blobs = self.blobs[:NBLOBS] return True @@ -219,6 +242,22 @@ elif event.type == KEYDOWN : if event.key == K_ESCAPE : pg.event.post(pg.event.Event(QUIT)) + elif event.key == K_SPACE : + self.blobs = [] + elif event.key == K_s : + if self.FADE : + print "fade off" + self.FADE = 0 + for blob in self.blobs : + blob.fade(0) + else: + print "fade on" + self.FADE = 15 + for blob in self.blobs : + blob.fade(15) + blob.reset_time() + + # Draw