Re: [kicad-users] Adding a Logo or Art to Silkscreen

2009-10-09 Thread Robert
Raoul, you're a star!   I've wanted to do this for a long time; like you 
I found that pstoedit didn't do the trick, but I couldn't justify the 
time to investigate further.

I used awk running under Cygwin (on WinXP) to convert a logo, and it 
worked perfectly.   The only snag on Windows is one needs to use an 
editor that supports Unix line endings (or perhaps set Cygwin to use 
Windows/DOS line endings on installation?), but there are plenty of open 
source editors around that will do this, as will MS Visual Studio.

Thanks again,

Robert.



No virus found in this outgoing message.
Checked by AVG - www.avg.com 
Version: 8.5.421 / Virus Database: 270.14.8/2423 - Release Date: 10/08/09 
18:33:00


[kicad-users] Adding a Logo or Art to Silkscreen

2009-10-08 Thread raoulduke_esq
Pardon me if I am just being obtuse, but I could find no easy way to add an 
image or artwork to a layout.  I've tried pstoedit but that utility (in 
addition to being broken if you are in a directory path that has a space in it) 
only works for text.

Because I am under the gun, I had to gin up something to get a project out the 
door.  So I came up with a quick and dirty solution.

Step 1: Generate an ASCII PBM file - I use GIMP.  A monochrome (black and 
white) image will be represented by a file full of "0" and "1". Call it 
something like "art.pbm".

Step 2: Run the ASCII PBM file "art.pbm" through the following awk script and 
put the output into a file, call it "art.out".

Step 3: Create a module library with a single component, call it something like 
"Logo".  The library will be called "Logo.mod".

Step 4: Edit the module library "Logo.mod", look for the $EndMODULE line, and 
copy the contents of "art.out" immediately before it.  Save the file.

Step 5: Edit the module library and move things around, add the module name, 
etc.

Step 6: In PCBnew, add the module from the library and place it where you want.

I hope this makes sense and helps someone other than me.  And I hope that I 
have not reinvented the wheel.  I'm sorry that I use awk as a script language 
of choice, I suppose I could clean it up as a Perl script if there is any 
interest.

raoul


--Cut Here--
# This script will take an ASCII PBM B&W file and convert it to a series
# of "DS" (Draw Segment) statements in PCBNEW syntax.  The deltaX and deltaY
# is defined in "step" which is in uints of 1/10 mil.  The layer is currently
# set to 21, the component layer silkscreen.  Swap bg & fg based on whether
# black or white is the foreground.
#
# State 0 : look for magic number - must be P1 (can be P4 for raw file)
# State 1 : look for height & width
# State 2 : process data
# State 3 : done with data - skip the rest
#
BEGIN { state = 0; step = 40; layer = 21; fg = "1"; bg = "0"; }
{if (NR == 1) {
state = 1;
if ($1 != "P1") {
printf("Must supply an ASCII PBM image file\n");
exit 1
}
next;
}
}
/^#/{ next }  # Comment line, skip it
{if (state == 1) {
width = $1;
height = $2;
buff = "";
state = 2;
Y = - ((step * height) / 2);
initX = - ((step * width) / 2);
next;
}
}
{if (state == 2)  {
buff = buff $1;
if (length( buff ) >= width) {
scanline = substr( buff, 1, width );
buff = substr( buff, width + 1 );
Y += step;
X = initX;
while ( Z1 = index( scanline, fg )) {
scanline = substr( scanline, Z1 );
Z2 = index( scanline, bg );
scanline = substr( scanline, Z2 );
Z1 = step * Z1 + X;
Z2 = step * Z2 + Z1 - 2 * step;
X = Z2;
printf( "DS %d %d %d %d %d %d\n", Z1, Y, Z2, Y, step, layer );
}
height--;
if (height == 0)
state = 3;
}
}
}
{if (state == 3) { nextfile; }}
--Cut Here--