eepyBoard/ergogen/footprints/text.js

39 lines
1004 B
JavaScript

// Graphical text box to render text (e.g. project name, copyright) onto the board
//
// The text can be multi-line. Linebreaks and quotes are automatically escaped.
// Backslashes are *not* escaped to allow for other escape sequences.
//
// Params
// side: Side of the PCB ("F" or "B")
// text: Text to be rendered
module.exports = {
params: {
layer: 'F.SilkS',
text: 'Example text!',
},
body: p => {
function escape_str(text) {
return text
.replace('"', '\\"')
.replace('\n', '\\n')
.replace('\r', '')
}
return `
(gr_text "${escape_str(p.text)}"
${p.at /* parametric position */}
(layer ${p.layer})
(effects
(font
(size 1.5 1.5)
(thickness 0.3)
(bold yes)
)
)
)
`;
}
}