因此,经过反复试验,我想我的数学终于正确计算了。最初,我将其作为一组复杂的列表开始,但后来发现数组函数更适合我的需要。
现在我已经建立了数组,我得到了这个新错误:
编辑:
Traceback (most recent call last):
File "(stdin)", line 1, in (module)
File "backandforth3.py", line 118, in (module)
frames.insert((x+f), (archstartred[x]))
TypeError: list index out of range
当我沮丧地对着电脑大喊所有的数据已经是一个整数时,我放弃了我的电脑显示器,并认为我会在这里尝试。到目前为止,这里的所有帮助都非常棒。
以下是我为数组生成数组和数据的方法: 编辑:将列表生成器添加到程序代码中,因为它似乎正在生成非整数值。
#List Generator
archstartred = []
archstartgrn = []
archstartblu = []
##Red List
for x in range (0, cursorsize):
if len(archstartred) < cursorsize:archstartred.insert(0,cursred)
for x in range (0, (archnodes-cursorsize)):
if len(archstartred) < archnodes:archstartred.append(backred)
##Green List
for x in range (0, cursorsize):
if len(archstartgrn) < cursorsize:archstartgrn.insert(0,cursgrn)
for x in range (0, (archnodes-cursorsize)):
if len(archstartgrn) < archnodes:archstartgrn.append(backgrn)
##Blue List
for x in range (0, cursorsize):
if len(archstartblu) < cursorsize:archstartblu.insert(0,cursblu)
for x in range (0, (archnodes-cursorsize)):
if len(archstartblu) < archnodes:archstartblu.append(backblu)
archstartred = [int(value) for value in archstartred]
archstartgrn = [int(value) for value in archstartgrn]
archstartblu = [int(value) for value in archstartblu]
#Frame Creation
from array import *
frames=array('i', (0 for i in range (0,workingframes*archnodes*3)))
#Frame Population
for f in range (0, workingframes):
if f<=(workingframes/2):
for x in range (0, (archnodes*3)):
frames.pop(x+f)
frames.insert((x+f), (archstartred[x]))
frames.pop((x+f)+workingframes)
frames.insert((x+f+workingframes), (archstartgrn[x]))
frames.pop((x+f)+workingframes*2)
frames.insert((x+f+workingframes*2), (archstartblu[x]))
for y in range (0, nodesperframe):
archstartred.pop()
archstartgrn.pop()
archstartblu.pop()
archstartred.insert(0, backred)
archstartgrn.insert(0, backgrn)
archstartblu.insert(0, backblu)
else:
for y in range (0, nodesperframe):
archstartred.pop(0)
archstartgrn.pop(0)
archstartblu.pop(0)
archstartred.append(backred)
archstartgrn.append(backgrn)
archstartblu.append(backblu)
for x in range (0, (archnodes*3)):
frames.pop(x+f)
frames.insert((x+f), (archstartred[x]))
frames.pop((x+f)+workingframes)
frames.insert((x+f+workingframes), (archstartgrn[x]))
frames.pop((x+f)+workingframes*2)
frames.insert((x+f+workingframes*2), (archstartblu[x]))
这与我在其他帖子中处理的程序相同。基本上,它是生成用于 RGB 照明系统的数据。这个“简单”的程序将使用 2 种颜色生成来回效果。其他变量包括效果所需的时间长度、帧大小(我们使用“序列器”生成显示,您可以在序列器中改变帧大小)、“光标”大小等。
当然,一旦我弄清楚了这个效果,我就可以根据数学公式做出更复杂的效果。