Beispiel #1
0
def split_anim(source_filename):
    print('Split %s' % (source_filename))
    with open(source_filename, 'rb') as h:
        source_indices, source_anims = libsotadisk.read_packed_animation(
            libsotadisk.ByteReader(h))

    anim = GrowableAnimation()

    # Keep adding stuff until the anim gets too large.
    source_idx_idx = 0
    while source_idx_idx < len(source_indices):
        source_index = source_indices[source_idx_idx]

        try:
            anim.add(source_anims, source_index)
        except Rewind as e:
            yield anim
            anim = GrowableAnimation()
            source_idx_idx -= e.rewind_amount
        else:
            source_idx_idx += 1

        assert len(anim) <= MAX_ANIM_SIZE

    if not anim.empty():
        yield anim
Beispiel #2
0
def compress_animation(filename):
	# Divide all extends by 2, so we go 0-127 rather than 0-255.

	with open(filename, 'rb') as h:
		reader = libsotadisk.ByteReader(h)
		indices, anims = libsotadisk.read_packed_animation(reader)

	#for drawcommand in anims.values():
	#	for command in drawcommand:
	#		if isinstance(command, libsotadisk.Vector):
	#			command.for_each_point(lambda x, y: (x // 2, y // 2))

	return libsotadisk.serialise_packed_animation(indices, anims)