trying out the new alpha mixing

master
Bartosz Kostrzewa 2010-11-17 14:50:21 +01:00
parent b5af4d6a86
commit 3af9f105d6
3 changed files with 85 additions and 10 deletions

View File

@ -24,12 +24,17 @@ UDPSock.bind((outgoing_if, local_port))
segments = open('segments','r') segments = open('segments','r')
alpha = 1 alpha = chr(155)
z_buffer = chr(1) + "\n" z_buffer = chr(1) + "\n"
width = 7 width = 7
height = 12 height = 12
segments = 8
segwidth = 12
segchannels = 4
# Send messages # Send messages
sleeptime = 0.03 sleeptime = 0.03
t = 0 t = 0
@ -42,8 +47,13 @@ while (1):
for i in range(0,width): for i in range(0,width):
for j in range(0,height): for j in range(0,height):
pixel = fabs(sin(2*pi*(float(i)/width)+t*frequency)*sin(2*pi*(float(j)/height)+t*frequency)) pixel = fabs(sin(2*pi*(float(i)/width)+t*frequency)*sin(2*pi*(float(j)/height)+t*frequency))
data = data + chr(int(254*pixel)) + chr(alpha) data = data + chr(int(254*pixel)) + alpha
data = data + "\n" data = data + "\n"
for i in range(0,segwidth):
for j in range(0,segments):
for a in range(0,segchannels):
data += chr(254)
data += "\n"
t+=1 t+=1
#print( data ) #print( data )
#data += segments.read() #data += segments.read()

View File

@ -193,7 +193,7 @@ void Server::mix()
frame.segments[w][n][a] = 0; frame.segments[w][n][a] = 0;
} }
} }
} } // zero out frame
for(int x = 0; x < size; x++) for(int x = 0; x < size; x++)
{ {
@ -203,10 +203,10 @@ void Server::mix()
{ {
for(int j = 0; j < WIDTH; j++) for(int j = 0; j < WIDTH; j++)
{ {
for(int a = 0; a < CHANNELS; a++) for(int a = 0; a < CHANNELS-1; a++)
{ {
// do something interesting here // do something interesting here
frame.windows[i][j][a] = temp_frame.windows[i][j][a]; frame.windows[i][j][a] = frame.windows[i][j][a] + (float)temp_frame.windows[i][j][CHANNELS-1]/254*temp_frame.windows[i][j][a];
} }
} }
} }
@ -215,9 +215,9 @@ void Server::mix()
{ {
for(int n = 0;n < SEGNUM; n++) for(int n = 0;n < SEGNUM; n++)
{ {
for(int a = 0; a < SEGCHANNELS; a++) for(int a = 0; a < SEGCHANNELS-1; a++)
{ {
frame.segments[w][n][a] = temp_frame.segments[w][n][a]; frame.segments[w][n][a] = frame.segments[w][n][a] + (float)temp_frame.segments[w][n][SEGCHANNELS-1]/254*temp_frame.segments[w][n][a];
} }
} }
} }
@ -257,6 +257,10 @@ void Server::console()
keypad(stdscr,TRUE); keypad(stdscr,TRUE);
cbreak(); cbreak();
noecho(); noecho();
start_color();
init_pair(1,COLOR_RED,COLOR_BLACK);
init_pair(2,COLOR_GREEN,COLOR_BLACK);
init_pair(3,COLOR_BLUE,COLOR_BLACK);
{ {
Glib::Mutex::Lock lock(mutex_); Glib::Mutex::Lock lock(mutex_);
consoleinit = true; consoleinit = true;
@ -319,6 +323,7 @@ void Server::input()
* implement their own locking and they need ncurses to be initialised */ * implement their own locking and they need ncurses to be initialised */
void Server::console_printframe(frame_t _frame) void Server::console_printframe(frame_t _frame)
{ {
int x1,y1,x2,y2;
// output the current screen contents // output the current screen contents
for(int i = 0; i < HEIGHT; i++) for(int i = 0; i < HEIGHT; i++)
{ {
@ -333,9 +338,69 @@ void Server::console_printframe(frame_t _frame)
{ {
for(int n = 0; n < SEGNUM; n++) for(int n = 0; n < SEGNUM; n++)
{ {
for(int a = 0; a < SEGCHANNELS; a++) switch(n)
{
case 0:
x1 = 2;
x2 = 3;
y1 = 7;
y2 = 7;
break;
case 1:
x1 = 0;
x2 = 0;
y1 = 5;
y2 = 6;
break;
case 2:
x1 = 2;
x2 = 3;
y1 = 4;
y2 = 4;
break;
case 3:
x1 = 0;
x2 = 0;
y1 = 2;
y2 = 3;
break;
case 4:
x1 = 2;
x2 = 3;
y1 = 1;
y2 = 1;
break;
case 5:
x1 = 4;
x2 = 4;
y1 = 2;
y2 = 3;
break;
case 6:
x1 = 4;
x2 = 4;
y1 = 5;
y2 = 6;
break;
case 7:
x1 = 5;
x2 = 5;
y1 = 7;
y2 = 7;
break;
} // switch
for(int a = 0; a < SEGCHANNELS-1; a++)
{ {
mvprintw(HEIGHT+3+w,(n*SEGCHANNELS)+a,"%c", _frame.segments[w][n][a]); attron(COLOR_PAIR(a+1));
mvprintw( HEIGHT+2+a*8+y1,
w*7+x1,
"%c",brtoc(_frame.segments[w][n][a]));
mvprintw( HEIGHT+2+a*8+y2,
w*7+x2,
"%c",brtoc(_frame.segments[w][n][a]));
attroff(COLOR_PAIR(a+1));
} }
} }
} }

View File

@ -22,7 +22,7 @@ UDPSock.bind((outgoing_if, local_port))
#UDPSock.connect((remote_host, remote_port)) #UDPSock.connect((remote_host, remote_port))
display = open('display', 'r') display = open('display', 'r')
z_buffer = "1" + "\n" z_buffer = chr(1) + "\n"
data = z_buffer + display.read() data = z_buffer + display.read()