Commit 61728050 authored by Neil Gershenfeld's avatar Neil Gershenfeld
Browse files

starting Gerber program

parent 2b6c86f4
......@@ -155,6 +155,8 @@
<i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;formats</i><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='./modules/path/formats/dxf'>dxf</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='./modules/path/formats/g-code'>g-code</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='./modules/path/formats/gerber'>gerber</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='./modules/path/formats/hpgl'>hpgl</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='./modules/path/formats/svg'>svg</a><br>
<i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;machines</i><br>
<i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Roland</i><br>
......@@ -226,6 +228,8 @@
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='./programs/machines/G-code/mill%202D%20PCB%20svg'>mill 2D PCB svg</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='./programs/machines/G-code/mill%202D%20png'>mill 2D png</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='./programs/machines/G-code/mill%202D%20svg'>mill 2D svg</a><br>
<i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Gerber</i><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='./programs/machines/Gerber/plot%20png'>plot png</a><br>
<i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RNDMC</i><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='./programs/machines/RNDMC/honeycomb%20connect'>honeycomb connect</a><br>
<i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Roland</i><br>
......
......@@ -125,6 +125,8 @@ module_label('path')
module_label('   formats')
module_menu('      dxf','modules/path/formats/dxf')
module_menu('      g-code','modules/path/formats/g-code')
module_menu('      gerber','modules/path/formats/gerber')
module_menu('      hpgl','modules/path/formats/hpgl')
module_menu('      svg','modules/path/formats/svg')
module_label('   machines')
module_label('      Roland')
......
//
// path to Gerber
//
// Neil Gershenfeld
// (c) Massachusetts Institute of Technology 2021
//
// This work may be reproduced, modified, distributed, performed, and
// displayed for any purpose, but must acknowledge the mods
// project. Copyright is retained and must be preserved. The work is
// provided as is; no warranty is provided, and users accept all
// liability.
//
// closure
//
(function(){
//
// module globals
//
var mod = {}
//
// name
//
var name = 'path to Gerber'
//
// initialization
//
var init = function() {
mod.fill.checked = true
}
//
// inputs
//
var inputs = {
imageInfo:{type:'',
event:function(evt){
mod.imageInfo = evt.detail
}},
path:{type:'',
event:function(evt){
mod.path = evt.detail
}}}
//
// outputs
//
var outputs = {
Gerber:{type:'',
event:function(evt){
mods.output(mod,'Gerber',evt)
}}}
//
// interface
//
var interface = function(div){
mod.div = div
var btn = document.createElement('button')
btn.style.padding = mods.ui.padding
btn.style.margin = 1
btn.appendChild(document.createTextNode('plot'))
btn.addEventListener('click',function(){
plot()
})
div.appendChild(btn)
div.appendChild(document.createElement('br'))
div.appendChild(document.createTextNode('format:'))
div.appendChild(document.createElement('br'))
var formats = document.createElement('div');
formats.style.textAlign = 'left'
var input = document.createElement('input')
input.type = 'radio'
input.name = mod.div.id+'format'
input.id = mod.div.id+'fill'
formats.appendChild(input)
mod.fill = input
formats.appendChild(document.createTextNode('fill'))
formats.appendChild(document.createElement('br'))
var input = document.createElement('input')
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'))
formats.appendChild(document.createElement('br'))
var input = document.createElement('input')
input.type = 'radio'
input.name = mod.div.id+'format'
input.id = mod.div.id+'outline'
input.disabled = true
formats.appendChild(input)
mod.drill = input
formats.appendChild(document.createTextNode('drill'))
div.appendChild(formats)
}
//
// local functions
//
// plot
//
function plot() {
var imgwidth = mod.imageInfo.width/parseFloat(mod.imageInfo.dpi)
var imgheight = mod.imageInfo.height/parseFloat(mod.imageInfo.dpi)
str = ''
str += "%MOIN*%\n" // inch units
str += "%ASAXBY*%\n" // axes
str += "%IPPOS*%\n" // positive image
str += "%LPD*%\n" // dark layer
str += "%FSLAX33Y33*%\n" // format absolute 3.3
for (var seg = 0; seg < mod.path.length; ++seg) {
for (var pt = 0; pt < mod.path[seg].length; ++pt) {
var x = imgwidth*mod.path[seg][pt][0]/(mod.imageInfo.width-1)
var y = imgheight*(1-mod.path[seg][pt][1]/(mod.imageInfo.height-1))
}
var x = imgwidth*mod.path[seg][0][0]/(mod.imageInfo.width-1)
var y = imgheight*(1-mod.path[seg][0][1]/(mod.imageInfo.height-1))
console.log(parseFloat(x.toFixed(3)))
}
}
/*
%MOIN*%
%ASAXBY*%
%IPPOS*%
%FSLAX33Y33*%
%ADD11C,0.1*%
%LPD*%
G36*
X1000Y1000D02*
X2000Y2000D01*
X2000Y1000D01*
X1000Y1000D01*
G37*
%LPC*%
G01*
D11*
X1000Y1000D02*
X1000Y2000D01*
X2000Y2000D01*
X1500Y1000D01*
M02*
//
// convert
//
function convert(path) {
//
// draw path
//
if (mod.fill.checked == true) {
var polyline = document.createElementNS(svgNS,'polyline')
polyline.setAttribute('stroke','none')
polyline.setAttribute('fill','black')
polyline.setAttribute('fill-rule','evenodd')
polyline.setAttribute('points',points)
g.appendChild(polyline)
}
else {
var polyline = document.createElementNS(svgNS,'polyline')
polyline.setAttribute('stroke','black')
polyline.setAttribute('stroke-width','0.01')
polyline.setAttribute('stroke-linecap','round')
polyline.setAttribute('fill','none')
polyline.setAttribute('points',points)
g.appendChild(polyline)
}
}
//
// save file
//
var obj = {}
obj.type = 'file'
obj.name = mod.imageInfo.name+'.svg'
var xml = new XMLSerializer().serializeToString(svg)
obj.contents = xml
outputs.SVG.event(obj)
}
*/
//
// return values
//
return ({
mod:mod,
name:name,
init:init,
inputs:inputs,
outputs:outputs,
interface:interface
})
}())
......@@ -22,6 +22,8 @@ program_menu('      mill 2D PCB png','programs/machines/G-code/mill%202D%2
program_menu('      mill 2D PCB svg','programs/machines/G-code/mill%202D%20PCB%20svg')
program_menu('      mill 2D png','programs/machines/G-code/mill%202D%20png')
program_menu('      mill 2D svg','programs/machines/G-code/mill%202D%20svg')
program_label('   Gerber')
program_menu('      plot png','programs/machines/Gerber/plot%20png')
program_label('   RNDMC')
program_menu('      honeycomb connect','programs/machines/RNDMC/honeycomb%20connect')
program_label('   Roland')
......
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment