corrected mistake and added some comments

master
Bartek Kostrzewa 2010-11-22 17:47:32 +01:00
parent f3fdb74d03
commit 8b92844eb9
1 changed files with 5 additions and 9 deletions

View File

@ -3,7 +3,6 @@
from socket import * from socket import *
import sys import sys
import time import time
import random
from math import * from math import *
# Set the socket parameters # Set the socket parameters
@ -16,6 +15,9 @@ remote_host = "127.0.0.1"
# udp is the default for DGRAM # udp is the default for DGRAM
UDPSock = socket(AF_INET, SOCK_DGRAM) UDPSock = socket(AF_INET, SOCK_DGRAM)
# we MUST bind, otherwise python will choose a different port for each
# connection
UDPSock.bind((outgoing_if, local_port)) UDPSock.bind((outgoing_if, local_port))
# we will not use connections so we can keep working even if the server # we will not use connections so we can keep working even if the server
@ -35,14 +37,11 @@ segments = 8
segwidth = 12 segwidth = 12
segchannels = 4 segchannels = 4
# Send messages
sleeptime = 0.03 sleeptime = 0.03
t = 0 t = 0
#timer will hold the elapsed time in seconds #timer will hold the elapsed time in seconds
timer = 0
frequency = 2*pi/200 frequency = 2*pi/200
max = 0.0
while (1): while (1):
#zero out the data buffer #zero out the data buffer
@ -50,17 +49,14 @@ 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)) + alpha data = data + chr(int(255*pixel)) + alpha
data = data + "\n" data = data + "\n"
for i in range(0,segwidth): for i in range(0,segwidth):
for j in range(0,segments): for j in range(0,segments):
for a in range(0,segchannels): for a in range(0,segchannels):
data += chr(254) data += chr(255)
data += "\n" data += "\n"
t+=1 t+=1
timer = t*sleeptime
#print( data )
#data += segments.read()
if not data: if not data:
break break
else: else: