# Path: vocto/transitions.py
# V = 2  # distance (velocity) index
# class Transitions:
# class Transition:
#     def __init__(self, targets=[], fps=25):
#     def __str__(self):
#     def __len__(self):
#     def count(self):
#     def add(self,transition,frames):
#     def configure(cfg, composites, targets=None, fps=25):
#         def index(composite):
#     def solve(self, begin, end, flip):
#     def travel(composites, previous=None):
#     def __init__(self, name, a=None, b=None):
#     def __str__(self):
#         def hidden( x, hidden ):
#     def phi(self):
#     def name(self):
#     def append(self, composite):
#     def frames(self): return len(self.composites)
#     def A(self, n=None):
#     def B(self, n=None):
#     def Az(self, z0, z1):
#     def Bz(self, z0, z1):
#     def begin(self): return self.composites[0]
#     def end(self): return self.composites[-1]
#     def reversed(self):
#     def swapped(self):
#     def calculate_flip(self):
#             def overlap(a, b):
#     def calculate(self, frames, a_corner=(R, T), b_corner=(L, T)):
#     def keys(self):
# def parse_asterisk(sequence, composites):
# def frange(x, y, jump):
# def bspline(points):
# def find_nearest(spline, points):
# def measure(points):
# def smooth(x):
# def distribute(points, positions, begin, end, x0, x1, n):
# def fade(begin, end, factor):
# def morph(begin, end, pt, corner, factor):
# def interpolate(key_frames, num_frames, corner):
# def is_in(sequence, part):
# def fade_alpha(frame,alpha,frames):


from configparser import SafeConfigParser
from vocto.transitions import Composites, Transitions, L, T, R, B, X, Y
from PIL import Image, ImageDraw, ImageFont
from subprocess import call
import sys
import copy
import re
import logging
import argparse
    # read transitions from configuration
    log.info("reading transitions from configuration...")
    transitions = Transitions.configure(
        config.items('transitions'), composites, targets, fps)
    log.info("read %d transition(s)" % transitions.count())
    if Args.map:
        print("transition table:\n%s" % transitions)
    # maybe overwirte targets by arguments
    if Args.composite:
        # check for composites in arguments
        sequence = Args.composite
    else:
        # generate sequence of targets
        sequence = Transitions.travel([t.name for t in targets])
    log.debug("using %d target composite(s):\n\t%s\t" %
              (len(targets), '\n\t'.join([t.name for t in targets])))

    # return config
    return size, fps, sequence, transitions, composites


def draw_text(draw, size, line_or_pos, text, fill=(255, 255, 255, 255), align=0):
    # get a font
    font = ImageFont.truetype("FreeSans.ttf",
                              11 if size[X] < 400 else
                              (13 if size[X] < 800 else
                               20))
    if type(line_or_pos) == int:
        assert not align
        line_factor = 1.3

# Path: vocto/transitions.py
# V = 2  # distance (velocity) index
# class Transitions:
# class Transition:
#     def __init__(self, targets=[], fps=25):
#     def __str__(self):
#     def __len__(self):
#     def count(self):
#     def add(self,transition,frames):
#     def configure(cfg, composites, targets=None, fps=25):
#         def index(composite):
#     def solve(self, begin, end, flip):
#     def travel(composites, previous=None):
#     def __init__(self, name, a=None, b=None):
#     def __str__(self):
#         def hidden( x, hidden ):
#     def phi(self):
#     def name(self):
#     def append(self, composite):
#     def frames(self): return len(self.composites)
#     def A(self, n=None):
#     def B(self, n=None):
#     def Az(self, z0, z1):
#     def Bz(self, z0, z1):
#     def begin(self): return self.composites[0]
#     def end(self): return self.composites[-1]
#     def reversed(self):
#     def swapped(self):
#     def calculate_flip(self):
#             def overlap(a, b):
#     def calculate(self, frames, a_corner=(R, T), b_corner=(L, T)):
#     def keys(self):
# def parse_asterisk(sequence, composites):
# def frange(x, y, jump):
# def bspline(points):
# def find_nearest(spline, points):
# def measure(points):
# def smooth(x):
# def distribute(points, positions, begin, end, x0, x1, n):
# def fade(begin, end, factor):
# def morph(begin, end, pt, corner, factor):
# def interpolate(key_frames, num_frames, corner):
# def is_in(sequence, part):
# def fade_alpha(frame,alpha,frames):


# Path: voctocore/test-transition.py
from configparser import SafeConfigParser
from vocto.transitions import Composites, Transitions, L, T, R, B, X, Y
from PIL import Image, ImageDraw, ImageFont
from subprocess import call
import sys
import copy
import re
import logging
import argparse

    # read transitions from configuration
    log.info("reading transitions from configuration...")
    transitions = Transitions.configure(
        config.items('transitions'), composites, targets, fps)
    log.info("read %d transition(s)" % transitions.count())
    if Args.map:
        print("transition table:\n%s" % transitions)
    # maybe overwirte targets by arguments
    if Args.composite:
        # check for composites in arguments
        sequence = Args.composite
    else:
        # generate sequence of targets
        sequence = Transitions.travel([t.name for t in targets])
    log.debug("using %d target composite(s):\n\t%s\t" %
              (len(targets), '\n\t'.join([t.name for t in targets])))

    # return config
    return size, fps, sequence, transitions, composites


def draw_text(draw, size, line_or_pos, text, fill=(255, 255, 255, 255), align=0):
    # get a font
    font = ImageFont.truetype("FreeSans.ttf",
                              11 if size[X] < 400 else
                              (13 if size[X] < 800 else
                               20))
    if type(line_or_pos) == int:
        assert not align
        line_factor = 1.3

        line_height = font.getsize("|")[Y] * line_factor