aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKing Kévin <kingkevin@cuvoodoo.info>2019-05-13 21:08:53 +0200
committerKing Kévin <kingkevin@cuvoodoo.info>2019-05-13 21:08:53 +0200
commitbe72118ab2ecd79051cb48bedb691496e1239f3d (patch)
tree94c058a61b780c3d4ad43ff662d34dfdc476715f
parente09ffa950793f4f1972e3d664d499b849278fc0b (diff)
add spaces to improve readibility
-rw-r--r--cvlp_lib.js288
1 files changed, 144 insertions, 144 deletions
diff --git a/cvlp_lib.js b/cvlp_lib.js
index 4512ac9..3964125 100644
--- a/cvlp_lib.js
+++ b/cvlp_lib.js
@@ -71,12 +71,12 @@ function cvlp_pin(number, x, y, thickness, hole, round) {
// provide a list of [x,y] coordinates
function cvlp_polyline(points, thickness, closed) {
var polyline = []
- for (var i=0; i<points.length-1; i++) {
+ for (var i = 0; i < points.length - 1; i++) {
polyline = polyline.concat(cvlp_line(points[i][0], points[i][1], points[i+1][0], points[i+1][1], thickness))
}
if (closed || false) {
- if (points[0][0]!=points[points.length-1][0] && points[0][1]!=points[points.length-1][1]) {
- polyline = polyline.concat(cvlp_line(points[points.length-1][0], points[points.length-1][1], points[0][0], points[0][1], thickness))
+ if (points[0][0]!=points[points.length - 1][0] && points[0][1] != points[points.length - 1][1]) {
+ polyline = polyline.concat(cvlp_line(points[points.length - 1][0], points[points.length - 1][1], points[0][0], points[0][1], thickness))
}
}
return polyline
@@ -86,15 +86,15 @@ function cvlp_polyline(points, thickness, closed) {
// provide top corner, size, an radius of corner
function cvlp_rectangle(x, y, width, height, thickness, radius) {
var rectangle = []
- rectangle = rectangle.concat(cvlp_line(x+radius, y, x+width-radius, y, thickness))
- rectangle = rectangle.concat(cvlp_line(x+width, y+radius, x+width, y+height-radius, thickness))
- rectangle = rectangle.concat(cvlp_line(x+width-radius, y+height, x+radius, y+height, thickness))
- rectangle = rectangle.concat(cvlp_line(x, y+height-radius, x, y+radius, thickness))
- if (radius !== 'undefined' && radius!=0) {
- rectangle = rectangle.concat(cvlp_arc(x+radius, y+radius, radius, 180, 90, thickness))
- rectangle = rectangle.concat(cvlp_arc(x+width-radius, y+radius, radius, 270, 90, thickness))
- rectangle = rectangle.concat(cvlp_arc(x+width-radius, y+width-radius, radius, 0, 90, thickness))
- rectangle = rectangle.concat(cvlp_arc(x+radius, y+width-radius, radius, 90, 90, thickness))
+ rectangle = rectangle.concat(cvlp_line(x + radius, y, x + width - radius, y, thickness))
+ rectangle = rectangle.concat(cvlp_line(x + width, y + radius, x + width, y + height - radius, thickness))
+ rectangle = rectangle.concat(cvlp_line(x + width - radius, y + height, x + radius, y + height, thickness))
+ rectangle = rectangle.concat(cvlp_line(x, y + height - radius, x, y + radius, thickness))
+ if (radius !== 'undefined' && radius != 0) {
+ rectangle = rectangle.concat(cvlp_arc(x + radius, y + radius, radius, 180, 90, thickness))
+ rectangle = rectangle.concat(cvlp_arc(x + width - radius, y + radius, radius, 270, 90, thickness))
+ rectangle = rectangle.concat(cvlp_arc(x + width - radius, y + width - radius, radius, 0, 90, thickness))
+ rectangle = rectangle.concat(cvlp_arc(x + radius, y + width - radius, radius, 90, 90, thickness))
}
return rectangle
}
@@ -111,26 +111,26 @@ function convert_unit(value, from, to) {
var mum = 0;
switch (from) {
case 'mm':
- mum = value*1000;
+ mum = value * 1000;
break;
case 'in':
- mum = value*1000*25.40;
+ mum = value * 1000 * 25.40;
break;
case 'mil':
- mum = value*25.40;
+ mum = value * 25.40;
break;
default:
return null;
}
switch (to) {
case 'mm':
- mum = mum/1000;
+ mum = mum / 1000;
break;
case 'in':
- mum = mum/1000/25.40;
+ mum = mum / 1000 / 25.40;
break;
case 'mil':
- mum = mum/25.40;
+ mum = mum / 25.40;
break;
default:
return null;
@@ -142,21 +142,21 @@ function convert_unit(value, from, to) {
function json2svg(json) {
// create svg
var svgNS = "http://www.w3.org/2000/svg"
- svg = document.createElementNS(svgNS,'svg')
- svg.setAttribute('xmlns',svgNS)
- svg.setAttribute('version',1.1)
- svg.setAttribute('xmlns:inkscape','http://www.inkscape.org/namespaces/inkscape')
+ svg = document.createElementNS(svgNS, 'svg')
+ svg.setAttribute('xmlns', svgNS)
+ svg.setAttribute('version', 1.1)
+ svg.setAttribute('xmlns:inkscape', 'http://www.inkscape.org/namespaces/inkscape')
// set unit
- if (json.unit=="mil") { // mil units are not supported in SVG, convert to inch
- svg.setAttribute('height',(json.height/1000)+'in')
- svg.setAttribute('width',(json.width/1000)+'in')
+ if (json.unit == "mil") { // mil units are not supported in SVG, convert to inch
+ svg.setAttribute('height', (json.height / 1000) + 'in')
+ svg.setAttribute('width', (json.width/1000) + 'in')
} else {
- svg.setAttribute('height',json.height+''+json.unit)
- svg.setAttribute('width',json.width+''+json.unit)
+ svg.setAttribute('height', json.height + '' + json.unit)
+ svg.setAttribute('width', json.width + '' + json.unit)
}
- svg.setAttribute('viewBox','0 0 '+json.width+' '+json.height)
+ svg.setAttribute('viewBox', '0 0 ' + json.width + ' ' + json.height)
// add info
- var svg_title = document.createElementNS(svgNS,'title');
+ var svg_title = document.createElementNS(svgNS, 'title');
svg_title.textContent = json.name;
svg.appendChild(svg_title);
// add layers
@@ -167,11 +167,11 @@ function json2svg(json) {
layers = []
for (layer_i in layers_desc) {
var layer_desc = layers_desc[layer_i]
- var layer = document.createElementNS(svgNS,'g')
- layer.setAttribute('inkscape:groupmode','layer')
- layer.setAttribute('inkscape:label',layer_desc.name)
+ var layer = document.createElementNS(svgNS, 'g')
+ layer.setAttribute('inkscape:groupmode', 'layer')
+ layer.setAttribute('inkscape:label', layer_desc.name)
for (key in layer_desc) {
- layer.setAttribute(key,layer_desc[key])
+ layer.setAttribute(key, layer_desc[key])
}
svg.appendChild(layer)
layers[layer_desc.name] = layer
@@ -180,75 +180,75 @@ function json2svg(json) {
var element = json.elements[element_i]
switch (element.type) {
case 'line':
- var line = document.createElementNS(svgNS,'line')
- line.setAttribute('x1',element.x1)
- line.setAttribute('y1',element.y1)
- line.setAttribute('x2',element.x2)
- line.setAttribute('y2',element.y2)
- line.style.setProperty('stroke-width',element.thickness)
+ var line = document.createElementNS(svgNS, 'line')
+ line.setAttribute('x1', element.x1)
+ line.setAttribute('y1', element.y1)
+ line.setAttribute('x2', element.x2)
+ line.setAttribute('y2', element.y2)
+ line.style.setProperty('stroke-width', element.thickness)
layers['silkscreen'].appendChild(line)
break
case 'arc':
- element.start = (element.start+360) % 360
- element.stop = (element.stop+360) % 360
+ element.start = (element.start + 360) % 360
+ element.stop = (element.stop + 360) % 360
var arc = null
- if (element.start==element.stop) {
- arc = document.createElementNS(svgNS,'circle')
- arc.setAttribute('cx',element.x)
- arc.setAttribute('cy',element.y)
- arc.setAttribute('r',element.radius)
+ if (element.start == element.stop) {
+ arc = document.createElementNS(svgNS, 'circle')
+ arc.setAttribute('cx', element.x)
+ arc.setAttribute('cy', element.y)
+ arc.setAttribute('r', element.radius)
} else {
- var x1 = element.x+element.radius*Math.cos(((-1*element.start)%360)/360.0*Math.PI*2)
- var y1 = element.y-element.radius*Math.sin(((-1*element.start)%360)/360.0*Math.PI*2)
- var x2 = element.x+element.radius*Math.cos(((-1*(element.start+element.angle))%360)/360.0*Math.PI*2)
- var y2 = element.y-element.radius*Math.sin(((-1*(element.start+element.angle))%360)/360.0*Math.PI*2)
- arc = document.createElementNS(svgNS,'path')
- arc.setAttribute('d','M '+x1+' '+y1+' A '+element.radius+' '+element.radius+' 0 '+((element.angle)%360>180 ? '1' : '0')+' 1 '+x2+' '+y2+' ')
+ var x1 = element.x + element.radius * Math.cos(((-1 * element.start) % 360) / 360.0 * Math.PI * 2)
+ var y1 = element.y - element.radius * Math.sin(((-1 * element.start) % 360) / 360.0 * Math.PI * 2)
+ var x2 = element.x + element.radius * Math.cos(((-1 * (element.start + element.angle)) % 360) / 360.0 * Math.PI * 2)
+ var y2 = element.y - element.radius * Math.sin(((-1 * (element.start + element.angle)) % 360) / 360.0 * Math.PI * 2)
+ arc = document.createElementNS(svgNS, 'path')
+ arc.setAttribute('d', 'M ' + x1 + ' ' + y1 + ' A ' + element.radius + ' ' + element.radius + ' 0 ' + ((element.angle) % 360 > 180 ? '1' : '0') + ' 1 ' + x2 + ' ' + y2 + ' ')
}
- arc.style.setProperty('stroke-width',element.thickness)
+ arc.style.setProperty('stroke-width', element.thickness)
layers['silkscreen'].appendChild(arc)
break
case 'pad':
- var copper = document.createElementNS(svgNS,'rect')
- copper.style.setProperty('stroke-width',0)
- copper.setAttribute('x',element.x-element.width/2)
- copper.setAttribute('y',element.y-element.height/2)
- copper.setAttribute('width',element.width)
- copper.setAttribute('height',element.height)
+ var copper = document.createElementNS(svgNS, 'rect')
+ copper.style.setProperty('stroke-width', 0)
+ copper.setAttribute('x', element.x - element.width / 2)
+ copper.setAttribute('y', element.y - element.height / 2)
+ copper.setAttribute('width', element.width)
+ copper.setAttribute('height', element.height)
if (element.round) {
- copper.setAttribute('rx',Math.min(element.width,element.height)/2)
- copper.setAttribute('ry',Math.min(element.width,element.height)/2)
+ copper.setAttribute('rx', Math.min(element.width, element.height) / 2)
+ copper.setAttribute('ry', Math.min(element.width, element.height) / 2)
} else {
- copper.setAttribute('rx',0)
- copper.setAttribute('ry',0)
+ copper.setAttribute('rx', 0)
+ copper.setAttribute('ry', 0)
}
layers['copper'].appendChild(copper)
break
case 'pin':
break
- var copper = document.createElementNS(svgNS,'rect')
- copper.style.setProperty('stroke-width',0)
- copper.setAttribute('x',element.x-element.thickness/2)
- copper.setAttribute('y',element.y-element.thickness/2)
- copper.setAttribute('height',element.thickness)
+ var copper = document.createElementNS(svgNS, 'rect')
+ copper.style.setProperty('stroke-width', 0)
+ copper.setAttribute('x', element.x - element.thickness / 2)
+ copper.setAttribute('y', element.y - element.thickness / 2)
+ copper.setAttribute('height', element.thickness)
copper.setAttribute('width',element.thickness)
if (element.round) {
- copper.setAttribute('rx',element.thickness/2)
- copper.setAttribute('ry',element.thickness/2)
+ copper.setAttribute('rx', element.thickness / 2)
+ copper.setAttribute('ry', element.thickness / 2)
} else {
- copper.setAttribute('rx',0)
- copper.setAttribute('ry',0)
+ copper.setAttribute('rx', 0)
+ copper.setAttribute('ry', 0)
}
layers['copper'].appendChild(copper)
- var hole = document.createElementNS(svgNS,'circle')
- hole.style.setProperty('stroke-width',0)
- hole.setAttribute('cx',element.x)
- hole.setAttribute('cy',element.y)
- hole.setAttribute('r',element.hole/2)
+ var hole = document.createElementNS(svgNS, 'circle')
+ hole.style.setProperty('stroke-width', 0)
+ hole.setAttribute('cx', element.x)
+ hole.setAttribute('cy', element.y)
+ hole.setAttribute('r', element.hole / 2)
layers['hole'].appendChild(hole)
break
default:
- console.log('unknown element type: '+element.type)
+ console.log('unknown element type: ' + element.type)
}
}
return svg
@@ -259,51 +259,51 @@ function json2pcb(json) {
// create file and add info
var pcb = ''
pcb += '# footprint generated from CuVoodoo Land Pattern\n'
- pcb += '# author: '+json.author+'\n'
- pcb += '# version: '+json.version+'\n'
- pcb += '# date: '+json.date+'\n'
- pcb += 'Element["" "'+json.name+'" "" "" 0 0 0 0 0 100 ""]\n'
+ pcb += '# author: ' + json.author + '\n'
+ pcb += '# version: ' + json.version + '\n'
+ pcb += '# date: ' + json.date + '\n'
+ pcb += 'Element["" "' + json.name + '" "" "" 0 0 0 0 0 100 ""]\n'
pcb += '(\n'
// add element parts
for (var element_i in json.elements) {
var element = json.elements[element_i]
switch (element.type) {
case 'line':
- pcb += 'ElementLine['+element.x1+''+json.unit+' '+element.y1+''+json.unit+' '+element.x2+''+json.unit+' '+element.y2+''+json.unit+' '+element.thickness+''+json.unit+']\n'
+ pcb += 'ElementLine[' + element.x1 + '' + json.unit + ' ' + element.y1 + '' + json.unit + ' ' + element.x2 + '' + json.unit + ' ' + element.y2 + '' + json.unit + ' ' + element.thickness + '' + json.unit + ']\n'
break
case 'arc':
- pcb += 'ElementArc['+element.x+''+json.unit+' '+element.y+''+json.unit+' '+element.radius+''+json.unit+' '+element.radius+''+json.unit+' '+((((180-element.start)%360)+360)%360)+' '+(-1*(element.angle))+' '+element.thickness+''+json.unit+']\n'
+ pcb += 'ElementArc[' + element.x + '' + json.unit + ' ' + element.y + '' + json.unit + ' ' + element.radius + '' + json.unit + ' ' + element.radius + '' + json.unit + ' ' + ((((180 - element.start) % 360) + 360) % 360) + ' ' + (-1 * (element.angle)) + ' ' + element.thickness + '' + json.unit + ']\n'
break
case 'pad':
var x1, y1, x2, y2, thickness
- if (element.width>element.height) {
- x1 = element.x-element.width/2+element.height/2
+ if (element.width > element.height) {
+ x1 = element.x - element.width / 2 + element.height / 2
y1 = element.y
- x2 = element.x+element.width/2-element.height/2
+ x2 = element.x + element.width / 2 - element.height / 2
y2 = element.y
thickness = element.height
} else {
x1 = element.x
- y1 = element.y-element.height/2+element.width/2
+ y1 = element.y - element.height / 2 + element.width / 2
x2 = element.x
- y2 = element.y+element.height/2-element.width/2
+ y2 = element.y + element.height / 2 - element.width / 2
thickness = element.width
}
- pcb += 'Pad['+x1+''+json.unit+' '+y1+''+json.unit+' '+x2+''+json.unit+' '+y2+''+json.unit+' '+thickness+''+json.unit+' '+0+''+json.unit+' '+thickness+''+json.unit+' "" "'+element.number+'" "'
+ pcb += 'Pad[' + x1 + '' + json.unit + ' ' + y1 + '' + json.unit + ' ' + x2 + '' + json.unit + ' ' + y2 + '' + json.unit + ' ' + thickness + '' + json.unit + ' ' + 0 + '' + json.unit + ' ' + thickness + '' + json.unit + ' "" "' + element.number + '" "'
if (!element.round) {
pcb += 'square'
}
pcb += '"]\n'
break
case 'pin':
- pcb += 'Pin['+element.x+''+json.unit+' '+element.y+''+json.unit+' '+element.thickness+''+json.unit+' '+0+''+json.unit+' '+thickness+''+json.unit+' '+element.hole+''+json.unit+' "" "'+element.number+'" "'
+ pcb += 'Pin[' + element.x + '' + json.unit + ' ' + element.y + '' + json.unit + ' ' + element.thickness + '' + json.unit + ' ' + 0 + '' + json.unit + ' ' + thickness + '' + json.unit + ' ' + element.hole + '' + json.unit + ' "" "' + element.number + '" "'
if (!element.round) {
pcb += 'square'
}
pcb += '"]\n'
break
default:
- console.log('unknown element type: '+element.type)
+ console.log('unknown element type: ' + element.type)
}
}
pcb += ')\n'
@@ -315,51 +315,51 @@ function json2kicad(json) {
// create file and add info
var kicad = ''
kicad += '# footprint generated from CuVoodoo Land Pattern\n'
- kicad += '# author: '+json.author+'\n'
- kicad += '# version: '+json.version+'\n'
- kicad += '# date: '+json.date+'\n'
- kicad += '(module "'+json.name+'" (layer F.Cu)\n'
+ kicad += '# author: ' + json.author + '\n'
+ kicad += '# version: ' + json.version + '\n'
+ kicad += '# date: ' + json.date + '\n'
+ kicad += '(module "' + json.name + '" (layer F.Cu)\n'
// add element parts
for (var element_i in json.elements) {
var element = json.elements[element_i]
switch (element.type) {
case 'line':
- kicad += '(fp_line (start '+convert_unit(element.x1,json.unit,'mm')+' '+convert_unit(element.y1,json.unit,'mm')+') (end '+convert_unit(element.x2,json.unit,'mm')+' '+convert_unit(element.y2,json.unit,'mm')+') (layer F.SilkS) (width '+convert_unit(element.thickness,json.unit,'mm')+'))\n'
+ kicad += '(fp_line (start ' + convert_unit(element.x1, json.unit, 'mm') + ' ' + convert_unit(element.y1, json.unit, 'mm') + ') (end ' + convert_unit(element.x2, json.unit, 'mm') + ' ' + convert_unit(element.y2, json.unit , 'mm') + ') (layer F.SilkS) (width ' + convert_unit(element.thickness, json.unit, 'mm') + '))\n'
break
case 'arc':
- kicad += '(fp_arc (start '+convert_unit(element.x,json.unit,'mm')+' '+convert_unit(element.y,json.unit,'mm')+') (end '+convert_unit((element.x+element.radius*Math.cos(((-1*element.start)%360)/360.0*Math.PI*2)),json.unit,'mm')+' '+convert_unit((element.y-element.radius*Math.sin(((-1*element.start)%360)/360.0*Math.PI*2)),json.unit,'mm')+') (angle '+element.angle+') (layer F.SilkS) (width '+convert_unit(element.thickness,json.unit,'mm')+'))\n'
+ kicad += '(fp_arc (start ' + convert_unit(element.x, json.unit, 'mm') + ' ' + convert_unit(element.y, json.unit, 'mm') + ') (end ' + convert_unit((element.x + element.radius * Math.cos(((-1 * element.start) % 360) / 360.0 * Math.PI * 2)), json.unit, 'mm') + ' ' + convert_unit((element.y - element.radius * Math.sin(((-1 * element.start) % 360) / 360.0 * Math.PI * 2)), json.unit, 'mm') + ') (angle ' + element.angle + ') (layer F.SilkS) (width ' + convert_unit(element.thickness, json.unit, 'mm') + '))\n'
break
case 'pad':
- kicad += '(pad "'+element.number+'" smd '
+ kicad += '(pad "' + element.number + '" smd '
if (element.round) {
kicad += 'oval'
} else {
kicad += 'rect'
}
- kicad += ' (at '+convert_unit(element.x,json.unit,'mm')+' '+convert_unit(element.y,json.unit,'mm')+')'
- kicad += ' (size '+convert_unit(element.width,json.unit,'mm')+' '+convert_unit(element.height,json.unit,'mm')+')'
+ kicad += ' (at ' + convert_unit(element.x, json.unit, 'mm') + ' ' + convert_unit(element.y, json.unit, 'mm') + ')'
+ kicad += ' (size ' + convert_unit(element.width, json.unit, 'mm') + ' ' + convert_unit(element.height, json.unit, 'mm') + ')'
kicad += ' (layers F.Cu F.Paste F.Mask)'
kicad += ')\n'
break
case 'pin':
- var x = (element.x1+element.x2)/2
- var y = (element.y1+element.y2)/2
- var length = Math.sqrt(Math.pow(element.x2-element.x1,2)+Math.pow(element.y2-element.y1,2))
- var angle = Math.atan2(element.y2-element.y1,element.x2-element.x1)*180/Math.PI;
- kicad += '(pad "'+element.number+'" smd '
+ var x = (element.x1 + element.x2) / 2
+ var y = (element.y1 + element.y2) / 2
+ var length = Math.sqrt(Math.pow(element.x2 - element.x1, 2) + Math.pow(element.y2 - element.y1, 2))
+ var angle = Math.atan2(element.y2 - element.y1, element.x2 - element.x1) * 180 / Math.PI;
+ kicad += '(pad "' + element.number + '" smd '
if (element.round) {
kicad += 'oval'
} else {
kicad += 'rect'
}
- kicad += ' (at '+convert_unit(x,json.unit,'mm')+' '+convert_unit(y,json.unit,'mm')+' '+angle+')'
- kicad += ' (size '+convert_unit(length,json.unit,'mm')+' '+convert_unit(element.thickness,json.unit,'mm')+')'
- kicad += ' (drill '+convert_unit(element.hole,json.unit,'mm')
+ kicad += ' (at ' + convert_unit(x, json.unit, 'mm') + ' ' + convert_unit(y, json.unit, 'mm') + ' ' + angle + ')'
+ kicad += ' (size ' + convert_unit(length, json.unit, 'mm') + ' ' + convert_unit(element.thickness, json.unit, 'mm') + ')'
+ kicad += ' (drill ' + convert_unit(element.hole, json.unit, 'mm')
kicad += ' (layers F.Cu F.Paste F.Mask)'
kicad += ')\n'
break
default:
- console.log('unknown element type: '+element.type)
+ console.log('unknown element type: ' + element.type)
}
}
kicad += ')\n'
@@ -369,10 +369,10 @@ function json2kicad(json) {
// convert JSON to eagle library
function json2eagle(json) {
// create eagle xml library
- var docType = document.implementation.createDocumentType('eagle', 'SYSTEM', 'eagle.dtd');
- var xml = document.implementation.createDocument('', 'eagle', docType);
+ var docType = document.implementation.createDocumentType('eagle', 'SYSTEM', 'eagle.dtd')
+ var xml = document.implementation.createDocument('', 'eagle', docType)
xml.documentElement.setAttribute('version','6.0')
- var comment = xml.createComment('footprint generated from CuVoodoo Land Pattern, author: '+json.author+', version: '+json.version+', date: '+json.date)
+ var comment = xml.createComment('footprint generated from CuVoodoo Land Pattern, author: ' + json.author + ', version: ' + json.version + ', date: ' + json.date)
xml.documentElement.appendChild(comment)
var drawing = xml.createElement('drawing')
xml.documentElement.appendChild(drawing)
@@ -414,58 +414,58 @@ function json2eagle(json) {
switch (element.type) {
case 'line':
var line = xml.createElement('wire')
- line.setAttribute('x1',convert_unit(element.x1,json.unit,'mm'))
- line.setAttribute('y1',convert_unit(-1*element.y1,json.unit,'mm'))
- line.setAttribute('x2',convert_unit(element.x2,json.unit,'mm'))
- line.setAttribute('y2',convert_unit(-1*element.y2,json.unit,'mm'))
- line.setAttribute('width',convert_unit(element.thickness,json.unit,'mm'))
- line.setAttribute('layer','21')
+ line.setAttribute('x1', convert_unit(element.x1, json.unit, 'mm'))
+ line.setAttribute('y1', convert_unit(-1 * element.y1, json.unit, 'mm'))
+ line.setAttribute('x2', convert_unit(element.x2, json.unit, 'mm'))
+ line.setAttribute('y2', convert_unit(-1 * element.y2, json.unit, 'mm'))
+ line.setAttribute('width', convert_unit(element.thickness, json.unit, 'mm'))
+ line.setAttribute('layer', '21')
packag.appendChild(line)
break
case 'arc':
var wire = xml.createElement('wire')
- wire.setAttribute('x1',convert_unit(element.x+element.radius*Math.cos(((-1*element.start)%360)/360.0*Math.PI*2),json.unit,'mm'))
- wire.setAttribute('y1',convert_unit(-1*element.y+element.radius*Math.sin(((-1*element.start)%360)/360.0*Math.PI*2),json.unit,'mm'))
- wire.setAttribute('x2',convert_unit(element.x+element.radius*Math.cos(((-1*(element.start+element.angle))%360)/360.0*Math.PI*2),json.unit,'mm'))
- wire.setAttribute('y2',convert_unit(-1*element.y+element.radius*Math.sin(((-1*(element.start+element.angle))%360)/360.0*Math.PI*2),json.unit,'mm'))
- wire.setAttribute('curve',-1*element.angle)
- wire.setAttribute('width',convert_unit(element.thickness,json.unit,'mm'))
- wire.setAttribute('layer','21')
- wire.setAttribute('cap','round')
+ wire.setAttribute('x1', convert_unit(element.x + element.radius * Math.cos(((-1 * element.start) % 360) / 360.0 * Math.PI * 2), json.unit, 'mm'))
+ wire.setAttribute('y1', convert_unit(-1 * element.y + element.radius * Math.sin(((-1 * element.start) % 360) / 360.0 * Math.PI * 2), json.unit, 'mm'))
+ wire.setAttribute('x2', convert_unit(element.x + element.radius * Math.cos(((-1 * (element.start + element.angle)) % 360) / 360.0 * Math.PI * 2), json.unit, 'mm'))
+ wire.setAttribute('y2', convert_unit(-1 * element.y + element.radius * Math.sin(((-1 * (element.start + element.angle)) % 360) / 360.0 * Math.PI * 2), json.unit, 'mm'))
+ wire.setAttribute('curve',-1 * element.angle)
+ wire.setAttribute('width', convert_unit(element.thickness, json.unit,'mm'))
+ wire.setAttribute('layer', '21')
+ wire.setAttribute('cap', 'round')
packag.appendChild(wire)
break
case 'pad':
var pad = xml.createElement('smd')
- pad.setAttribute('name',element.number)
- pad.setAttribute('x',convert_unit(element.x,json.unit,'mm'))
- pad.setAttribute('y',convert_unit(-1*element.y,json.unit,'mm'))
- pad.setAttribute('dx',convert_unit(element.width,json.unit,'mm'))
- pad.setAttribute('dy',convert_unit(element.height,json.unit,'mm'))
- pad.setAttribute('layer','1')
+ pad.setAttribute('name', element.number)
+ pad.setAttribute('x', convert_unit(element.x, json.unit, 'mm'))
+ pad.setAttribute('y', convert_unit(-1 * element.y, json.unit, 'mm'))
+ pad.setAttribute('dx', convert_unit(element.width, json.unit, 'mm'))
+ pad.setAttribute('dy', convert_unit(element.height, json.unit, 'mm'))
+ pad.setAttribute('layer', '1')
if (element.round) {
- pad.setAttribute('roundness',100)
+ pad.setAttribute('roundness', 100)
} else {
- pad.setAttribute('roundness',0)
+ pad.setAttribute('roundness', 0)
}
packag.appendChild(pad)
break
case 'pin':
var pin = xml.createElement('pad')
- pin.setAttribute('name',element.number)
- pin.setAttribute('x',convert_unit(element.x,json.unit,'mm'))
- pin.setAttribute('y',convert_unit(-1*element.y,json.unit,'mm'))
- pin.setAttribute('drill',convert_unit(element.hole,json.unit,'mm'))
- pin.setAttribute('diameter',convert_unit(element.thickness,json.unit,'mm'))
- pin.setAttribute('layer','17')
+ pin.setAttribute('name', element.number)
+ pin.setAttribute('x', convert_unit(element.x, json.unit, 'mm'))
+ pin.setAttribute('y', convert_unit(-1 * element.y, json.unit, 'mm'))
+ pin.setAttribute('drill', convert_unit(element.hole, json.unit, 'mm'))
+ pin.setAttribute('diameter', convert_unit(element.thickness, json.unit, 'mm'))
+ pin.setAttribute('layer', '17')
if (element.round) {
- pin.setAttribute('shape','round')
+ pin.setAttribute('shape', 'round')
} else {
- pin.setAttribute('shape','square')
+ pin.setAttribute('shape', 'square')
}
packag.appendChild(pin)
break
default:
- console.log('unknown element type: '+element.type)
+ console.log('unknown element type: ' + element.type)
}
}
return xml