From 091fde0d82064ded9a6fc0f50f00f014451c292d Mon Sep 17 00:00:00 2001 From: Neil Gershenfeld <gersh@cba.mit.edu> Date: Fri, 20 Aug 2021 07:38:02 -0400 Subject: [PATCH] outline working --- modules/path/formats/gerber | 71 +++++++++++++++++++++++-------------- 1 file changed, 45 insertions(+), 26 deletions(-) diff --git a/modules/path/formats/gerber b/modules/path/formats/gerber index 3361d27..fae3010 100644 --- a/modules/path/formats/gerber +++ b/modules/path/formats/gerber @@ -77,7 +77,6 @@ var interface = function(div){ input.type = 'radio' input.name = mod.div.id+'format' input.id = mod.div.id+'outline' - input.disabled = true formats.appendChild(input) mod.outline = input formats.appendChild(document.createTextNode('outline')) @@ -104,42 +103,62 @@ function format(x) { function plot() { var imgwidth = mod.imageInfo.width/parseFloat(mod.imageInfo.dpi) var imgheight = mod.imageInfo.height/parseFloat(mod.imageInfo.dpi) + var x,y // str = '' str += "%MOIN*%\n" // inch units str += "%LPD*%\n" // layer dark str += "%FSLAX66Y66*%\n" // format absolute 6.6 + str += "G01*\n" // linear interpolation // - var x,y - for (var seg = 0; seg < mod.path.length; ++seg) { - str += "G36*\n" - x = imgwidth*mod.path[seg][0][0]/(mod.imageInfo.width-1) - y = imgheight*mod.path[seg][0][1]/(mod.imageInfo.height-1) - str += 'X'+format(x)+'Y'+format(y)+'D02*\n' - for (var pt = 1; pt < mod.path[seg].length; ++pt) { - var x = imgwidth*mod.path[seg][pt][0]/(mod.imageInfo.width-1) - var y = imgheight*mod.path[seg][pt][1]/(mod.imageInfo.height-1) + if (mod.fill.checked == true) { + for (var seg = 0; seg < mod.path.length; ++seg) { + str += "G36*\n" + x = imgwidth*mod.path[seg][0][0]/(mod.imageInfo.width-1) + y = imgheight*mod.path[seg][0][1]/(mod.imageInfo.height-1) + str += 'X'+format(x)+'Y'+format(y)+'D02*\n' + for (var pt = 1; pt < mod.path[seg].length; ++pt) { + var x = imgwidth*mod.path[seg][pt][0]/(mod.imageInfo.width-1) + var y = imgheight*mod.path[seg][pt][1]/(mod.imageInfo.height-1) + str += 'X'+format(x)+'Y'+format(y)+'D01*\n' + } + x = imgwidth*mod.path[seg][0][0]/(mod.imageInfo.width-1) + y = imgheight*mod.path[seg][0][1]/(mod.imageInfo.height-1) str += 'X'+format(x)+'Y'+format(y)+'D01*\n' + str += "G37*\n" } - x = imgwidth*mod.path[seg][0][0]/(mod.imageInfo.width-1) - y = imgheight*mod.path[seg][0][1]/(mod.imageInfo.height-1) - str += 'X'+format(x)+'Y'+format(y)+'D01*\n' - str += "G37*\n" + str += "M02*\n" + var obj = {} + obj.type = 'file' + obj.name = mod.imageInfo.name+'.gtl' + obj.contents = str + outputs.Gerber.event(obj) + } + else if (mod.outline.checked == true) { + str += "%ADD10C,0.001*%\n" + str += "D10*\n" + for (var seg = 0; seg < mod.path.length; ++seg) { + x = imgwidth*mod.path[seg][0][0]/(mod.imageInfo.width-1) + y = imgheight*mod.path[seg][0][1]/(mod.imageInfo.height-1) + str += 'X'+format(x)+'Y'+format(y)+'D02*\n' + for (var pt = 1; pt < mod.path[seg].length; ++pt) { + var x = imgwidth*mod.path[seg][pt][0]/(mod.imageInfo.width-1) + var y = imgheight*mod.path[seg][pt][1]/(mod.imageInfo.height-1) + str += 'X'+format(x)+'Y'+format(y)+'D01*\n' + } + x = imgwidth*mod.path[seg][0][0]/(mod.imageInfo.width-1) + y = imgheight*mod.path[seg][0][1]/(mod.imageInfo.height-1) + str += 'X'+format(x)+'Y'+format(y)+'D01*\n' + } + str += "M02*\n" + var obj = {} + obj.type = 'file' + obj.name = mod.imageInfo.name+'.gko' + obj.contents = str + outputs.Gerber.event(obj) } - str += "M02*\n" - // - var obj = {} - obj.type = 'file' - obj.name = mod.imageInfo.name+'.gbr' - //var xml = new XMLSerializer().serializeToString(str) - //obj.contents = xml - obj.contents = str - outputs.Gerber.event(obj) } /* -%ADD11C,0.1*% -%LPC*% -G01* D11* X1000Y1000D02* X1000Y2000D01* -- GitLab