|
|
|
@ -71,9 +71,20 @@ class Rocket:
@@ -71,9 +71,20 @@ class Rocket:
|
|
|
|
|
def getRandomColor(maxval): |
|
|
|
|
return list(map(lambda x: int(round(x*maxval)), colorsys.hsv_to_rgb(random.random(), 1, 1))) |
|
|
|
|
|
|
|
|
|
def gen_rockets(num, now=0): |
|
|
|
|
for i in range(num): |
|
|
|
|
yield Rocket( |
|
|
|
|
np.array([random.randint(0, dim.width-1), dim.height-1]), |
|
|
|
|
np.array([random.randint(-8, 8), -20 + random.randint(-2, 2)]), |
|
|
|
|
4 + random.randint(-2, 2), |
|
|
|
|
now + random.randint(0, 40) / 10, |
|
|
|
|
np.array([dim.depth-1] * 3) |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
|
|
parser = argparse.ArgumentParser(description='Generate plasma animations') |
|
|
|
|
parser.add_argument('-d', '--delay', type=int, default=50) |
|
|
|
|
parser.add_argument('-t', '--time', type=int, default=0) |
|
|
|
|
parser.add_argument('-n', '--num-rockets', type=int, default=3) |
|
|
|
|
parser.add_argument('output_file') |
|
|
|
|
args = parser.parse_args() |
|
|
|
@ -82,17 +93,7 @@ if __name__ == '__main__':
@@ -82,17 +93,7 @@ if __name__ == '__main__':
|
|
|
|
|
anim = blup.animation.Animation(dim) |
|
|
|
|
anim.tags['description'] = ' '.join(sys.argv) |
|
|
|
|
|
|
|
|
|
rockets = [] |
|
|
|
|
for i in range(args.num_rockets): |
|
|
|
|
rockets.append( |
|
|
|
|
Rocket( |
|
|
|
|
np.array([random.randint(0, dim.width-1), dim.height-1]), |
|
|
|
|
np.array([random.randint(-8, 8), -20 + random.randint(-2, 2)]), |
|
|
|
|
4 + random.randint(-2, 2), |
|
|
|
|
random.randint(0, 40) / 10, |
|
|
|
|
np.array([dim.depth-1] * 3) |
|
|
|
|
) |
|
|
|
|
) |
|
|
|
|
rockets = list(gen_rockets(args.num_rockets)) |
|
|
|
|
|
|
|
|
|
fbs = [] |
|
|
|
|
t = 0 |
|
|
|
@ -126,7 +127,12 @@ if __name__ == '__main__':
@@ -126,7 +127,12 @@ if __name__ == '__main__':
|
|
|
|
|
anim.addFrame(frame) |
|
|
|
|
|
|
|
|
|
if len(rockets) == 0 and len(fbs) == 0: |
|
|
|
|
break |
|
|
|
|
if t < args.time: |
|
|
|
|
frame = blup.animation.AnimationFrame(dim, 700) |
|
|
|
|
anim.addFrame(frame) |
|
|
|
|
rockets = list(gen_rockets(args.num_rockets, t)) |
|
|
|
|
else: |
|
|
|
|
break |
|
|
|
|
t += args.delay / 1000 |
|
|
|
|
|
|
|
|
|
blup.writebml.writeBml(anim, args.output_file) |
|
|
|
|