Skip to content

Instantly share code, notes, and snippets.

@m0ppers
Last active December 17, 2016 11:39
Show Gist options
  • Save m0ppers/1b5411194b68d593d36a8d91adb4cd93 to your computer and use it in GitHub Desktop.
Save m0ppers/1b5411194b68d593d36a8d91adb4cd93 to your computer and use it in GitHub Desktop.
quickly create a fritzing schematic
'use strict';
// quick and dirty fritzing ic schematic generator
let numPins = 80;
let name = 'FT907L';
let pinsPerSide = Math.ceil(numPins/2);
let pins = '';
let heightPerPin = 2.5;
for (var i=1;i<=pinsPerSide;i++) {
pins += `<line class='pin' x1='0.123472' y1='${i * heightPerPin}' x2='5.20347' y2='${i * heightPerPin}' fill='none' stroke='#787878' stroke-width='0.246944' stroke-linecap='round' id='connector${i-1}pin' />
<text class='text' font-family="'Droid Sans'" stroke='none' stroke-width='0' fill='#8c8c8c' font-size='0.881944' x='2.66347' y='${i * heightPerPin-0.37}' text-anchor='middle'>${i}</text>
<text class='text' font-family="'Droid Sans'" stroke='none' stroke-width='0' fill='#8c8c8c' font-size='1.23472' x='5.69736' y='${i * heightPerPin+0.4}' text-anchor='start'>${i}</text>
<rect class='terminal' x='-0.123472' y='${i * heightPerPin - 0.125}' width='0.246944' height='0.246944' fill='none' stroke='none' stroke-width='0' id='connector${i-1}terminal' />`;
pins += `<line class='pin' x1='15.1165' y1='${i * heightPerPin}' x2='20.1965' y2='${i * heightPerPin}' fill='none' stroke='#787878' stroke-width='0.246944' stroke-linecap='round' id='connector${pinsPerSide + i-1}pin' />
<text class='text' font-family="'Droid Sans'" stroke='none' stroke-width='0' fill='#8c8c8c' font-size='0.881944' x='17.6565' y='${i * heightPerPin-0.37}' text-anchor='middle'>${pinsPerSide + i}</text>
<text class='text' font-family="'Droid Sans'" stroke='none' stroke-width='0' fill='#8c8c8c' font-size='1.23472' x='14.6226' y='${i * heightPerPin+0.4}' text-anchor='end'>${pinsPerSide + i}</text>
<rect class='terminal' x='20.1965' y='${i * heightPerPin - 0.125}' width='0.246944' height='0.246944' fill='none' stroke='none' stroke-width='0' id='connector${pinsPerSide + i-1}terminal' />`;
}
let totalHeight = heightPerPin*(pinsPerSide+1);
let svg = `<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<!-- Created with mop script -->
<svg xmlns:svg='http://www.w3.org/2000/svg' xmlns='http://www.w3.org/2000/svg' version='1.2' baseProfile='tiny' x='0' y='0' width='0.8in' height='${pinsPerSide * 0.1}in' viewBox='0 0 20.32 ${totalHeight}'>
<g id='schematic'>
<rect class='interior rect' x='5.23875' y='0.15875' width='9.8425' height='${totalHeight-0.15875*2}' fill='#FFFFFF' stroke='#000000' stroke-width='0.3175' stroke-linecap='round' />
${pins}
<text class='text' id='label' font-family="'Droid Sans'" stroke='none' stroke-width='0' fill='#000000' font-size='1.49931' x='10.3188' y='${totalHeight/2}' text-anchor='middle'>${name}</text>
</g>
</svg>
`;
console.log(svg);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment