# Path: inter/inter.py
# def cleanup_js(inter):
#   def _remove_constructor(item):
# def add_names(inter):
#   def generate_ints():
#   def _c(x):
# def get_meta(inter):
# def prepare_for_display(inter, filter_out):
#   def _sort(x1, x2):
#   def convert(x):
# def bounding_box(inter):
#   def oget(m, k, d):
#   def fget(m, k, d = 0.0):
#   def circle(shape):
#   def disc(shape):
#   def label(shape):
#   def vertex(shape):
#   def polygon(shape):
#   def octagon(shape):
#   def rect(shape):
#   def unknown(shape):
# def size(inter):
# def sort_by_type(inter):
#   def _sort(x1, x2):
# def _count_num_values(pads, param):
# def _equidistant(pads, direction):
# def _all_equal(pads, direction):
# def _sort_by_field(pads, field, reverse=False):
#   def _sort_by(a, b):
# def _clone_pad(pad_in, remove):
# def _make_mods(skip, pad, pads):
# def _check_single(orig_pads, horizontal):
# def _split_dual(pads, direction):
# def _one_by_one_equal(r1, r2, direction):
# def _check_dual_alt(r1, r2):
# def _check_dual(orig_pads, horizontal):
# def _split_quad(pads):
# def _check_quad(orig_pads):
# def _check_sequential(pads):
# def _find_pad_patterns(pads):
# def find_pad_patterns(inter):
# def import_footprint(importer, footprint_name):


import os.path
import shlex
import math
import time
import re
import mutil.mutil as mutil
from inter import inter

    # DS Xstart Ystart Xend Yend Width Layer
    # DS 6000 1500 6000 -1500 120 21
    # DA Xcentre Ycentre Xstart_point Ystart_point angle width layer
    def vertex(shape, layer):
      l = []
      x1 = fget(shape, 'x1')
      y1 = fget(shape, 'y1')
      x2 = fget(shape, 'x2')
      y2 = fget(shape, 'y2')
      w = fget(shape, 'w')
      if not 'curve' in shape or shape['curve'] == 0.0:
        line = "DS %s %s %s %s %s %s" % (x1, fc(-y1), x2, fc(-y2), w, layer)
        l.append(line)
      else:
        curve =  fget(shape, 'curve')
        angle = curve*math.pi/180.0
        ((x0, y0), r, a1, a2) = mutil.calc_center_r_a1_a2((x1,y1),(x2,y2),angle)
        arc = "DA %f %f %f %f %s %s %s" % (x0, fc(-y0), x1, fc(-y1), int(round((-10.0)*(a2-a1))), w, layer)
        l.append(arc)
      return l

    # DC Xcentre Ycentre Xpoint Ypoint Width Layer
    def circle(shape, layer):
      l = []
      x = fget(shape, 'x')
      y = fget(shape, 'y')
      r = fget(shape, 'r')
      w = fget(shape, 'w')
      if not 'a1' in shape and not 'a2' in shape:

# Path: inter/inter.py
# def cleanup_js(inter):
#   def _remove_constructor(item):
# def add_names(inter):
#   def generate_ints():
#   def _c(x):
# def get_meta(inter):
# def prepare_for_display(inter, filter_out):
#   def _sort(x1, x2):
#   def convert(x):
# def bounding_box(inter):
#   def oget(m, k, d):
#   def fget(m, k, d = 0.0):
#   def circle(shape):
#   def disc(shape):
#   def label(shape):
#   def vertex(shape):
#   def polygon(shape):
#   def octagon(shape):
#   def rect(shape):
#   def unknown(shape):
# def size(inter):
# def sort_by_type(inter):
#   def _sort(x1, x2):
# def _count_num_values(pads, param):
# def _equidistant(pads, direction):
# def _all_equal(pads, direction):
# def _sort_by_field(pads, field, reverse=False):
#   def _sort_by(a, b):
# def _clone_pad(pad_in, remove):
# def _make_mods(skip, pad, pads):
# def _check_single(orig_pads, horizontal):
# def _split_dual(pads, direction):
# def _one_by_one_equal(r1, r2, direction):
# def _check_dual_alt(r1, r2):
# def _check_dual(orig_pads, horizontal):
# def _split_quad(pads):
# def _check_quad(orig_pads):
# def _check_sequential(pads):
# def _find_pad_patterns(pads):
# def find_pad_patterns(inter):
# def import_footprint(importer, footprint_name):


# Path: export/kicad_old.py
import os.path
import shlex
import math
import time
import re
import mutil.mutil as mutil
from inter import inter


    # DS Xstart Ystart Xend Yend Width Layer
    # DS 6000 1500 6000 -1500 120 21
    # DA Xcentre Ycentre Xstart_point Ystart_point angle width layer
    def vertex(shape, layer):
      l = []
      x1 = fget(shape, 'x1')
      y1 = fget(shape, 'y1')
      x2 = fget(shape, 'x2')
      y2 = fget(shape, 'y2')
      w = fget(shape, 'w')
      if not 'curve' in shape or shape['curve'] == 0.0:
        line = "DS %s %s %s %s %s %s" % (x1, fc(-y1), x2, fc(-y2), w, layer)
        l.append(line)
      else:
        curve =  fget(shape, 'curve')
        angle = curve*math.pi/180.0
        ((x0, y0), r, a1, a2) = mutil.calc_center_r_a1_a2((x1,y1),(x2,y2),angle)
        arc = "DA %f %f %f %f %s %s %s" % (x0, fc(-y0), x1, fc(-y1), int(round((-10.0)*(a2-a1))), w, layer)
        l.append(arc)
      return l

    # DC Xcentre Ycentre Xpoint Ypoint Width Layer
    def circle(shape, layer):
      l = []
      x = fget(shape, 'x')
      y = fget(shape, 'y')
      r = fget(shape, 'r')
      w = fget(shape, 'w')
      if not 'a1' in shape and not 'a2' in shape:

        circle = "DC %s %s %s %s %s %s" % (x, fc(-y), fc(x+(r/math.sqrt(2))), fc(-y+(r/math.sqrt(2))), w, layer)