# Path: cuburn/genome/convert.py
# class XMLGenomeParser(object):
# class XMLPaletteParser(object):
#     def __init__(self):
#     def start_element(self, name, attrs):
#     def end_element(self, name):
#     def parse(cls, src):
#     def __init__(self, src):
#     def start_element(self, name, attrs):
#     def end_element(self, name):
#     def _load(cls):
#     def lookup(cls, key, isname=False):
# def convert_affine(aff, animate=False):
# def convert_vars(xf):
# def convert_xform(xf):
# def make_symm_xforms(kind, offset):
# def convert_xforms(flame):
# def apply_structure(struct, src):
# def flam3_to_node(flame):
# def nodes_from_xml_path(path):


import unittest
import binascii
import numpy as np
from cuburn.genome import convert



def _make_palette_src():
    values = np.zeros((256,4), 'u1')
    values[:,0] = range(256)
    values[:,1] = 1
    values[:,2] = 2
    values[:,3] = 3
    # leave a newline in to make sure those get stripped
    return """<palettes><palette number="0" name="synthetic" data="%s
"/></palettes>""" % binascii.b2a_hex(values.tostring())

def _make_genome_src(palette=False):
    src = """
<flame time="0" size="1280 960" center="0.01 0.02" scale="40" oversample="2"
    filter="1" quality="500" batches="50" brightness="4" gamma="4"
    url="test.com" nick="strobe" {paletteidx}>
    {color}
    <xform weight="0.1" color="0" hyperbolic="0.1"
        coefs="01 0.2 -0.3 0.4 -0.5 0.6"/>
</flame>"""
    args = {'paletteidx': '', 'color': ''}
    if palette:
        args['paletteidx'] = 'palette="0"'
    else:
        args['color'] = '<color index="0" rgb="1 2 3"/>'

# Path: cuburn/genome/convert.py
# class XMLGenomeParser(object):
# class XMLPaletteParser(object):
#     def __init__(self):
#     def start_element(self, name, attrs):
#     def end_element(self, name):
#     def parse(cls, src):
#     def __init__(self, src):
#     def start_element(self, name, attrs):
#     def end_element(self, name):
#     def _load(cls):
#     def lookup(cls, key, isname=False):
# def convert_affine(aff, animate=False):
# def convert_vars(xf):
# def convert_xform(xf):
# def make_symm_xforms(kind, offset):
# def convert_xforms(flame):
# def apply_structure(struct, src):
# def flam3_to_node(flame):
# def nodes_from_xml_path(path):


# Path: cuburn/genome/tests/test_convert.py
import unittest
import binascii
import numpy as np
from cuburn.genome import convert




def _make_palette_src():
    values = np.zeros((256,4), 'u1')
    values[:,0] = range(256)
    values[:,1] = 1
    values[:,2] = 2
    values[:,3] = 3
    # leave a newline in to make sure those get stripped
    return """<palettes><palette number="0" name="synthetic" data="%s
"/></palettes>""" % binascii.b2a_hex(values.tostring())

def _make_genome_src(palette=False):
    src = """
<flame time="0" size="1280 960" center="0.01 0.02" scale="40" oversample="2"
    filter="1" quality="500" batches="50" brightness="4" gamma="4"
    url="test.com" nick="strobe" {paletteidx}>
    {color}
    <xform weight="0.1" color="0" hyperbolic="0.1"
        coefs="01 0.2 -0.3 0.4 -0.5 0.6"/>
</flame>"""
    args = {'paletteidx': '', 'color': ''}
    if palette:
        args['paletteidx'] = 'palette="0"'
    else:
        args['color'] = '<color index="0" rgb="1 2 3"/>'

    return src.format(**args)