SVGImport.wiki
changeset 232 a0ce457b93f2
parent 231 b5780c560285
child 233 1f18b0e7a80f
equal deleted inserted replaced
231:b5780c560285 232:a0ce457b93f2
    22 
    22 
    23 3) Go to File->Document Properties and specify 4096 for W and 2048 for H.  You may want to then reposition the art to be more centred vertically or horizontally.
    23 3) Go to File->Document Properties and specify 4096 for W and 2048 for H.  You may want to then reposition the art to be more centred vertically or horizontally.
    24 
    24 
    25 4) Save and Quit
    25 4) Save and Quit
    26 
    26 
    27 6) Open in an editor and verify there is one path. change the path ID attribute to id="base" - this is to work around a bug in the current stable Inkscape extensions tool which was crashing it.  Make sure all those groups are removed.
    27 5) Open in an editor and verify there is one path. change the path ID attribute to id="base" - this is to work around a bug in the current stable Inkscape extensions tool which was crashing it.  Make sure all those groups are removed.
    28 
    28 
    29 7) open the file in Inkscape again, Click on the path again, then go to Extensions->Modify Path->Flatten Beziers and flatten out the curves to your taste. Default of 10 seems fine. 
    29 6) open the file in Inkscape again, Click on the path again, then go to Extensions->Modify Path->Flatten Beziers and flatten out the curves to your taste. Default of 10 seems fine. 
    30 
    30 
    31 8) Save and Quit again
    31 7) Save and Quit again
    32 
    32 
    33 9) Edit the file, and delete everything but the path data.  You should have a one-line file starting with something like  M1234.3 456.78L3298.3 9023.34 and so on.  The coordinates should now be rounded unless you plan to handle that yourself in some way.  Here is a vim one-liner to do it.
    33 8) Edit the file, and delete everything but the path data.  You should have a one-line file starting with something like  M1234.3 456.78L3298.3 9023.34 and so on.  The coordinates should now be rounded unless you plan to handle that yourself in some way.  Here is a vim one-liner to do it.
    34 {{{:s/[0-9][0-9.]*/\=float2nr(floor(submatch(0)*1))/g}}}
    34 {{{:s/[0-9][0-9.]*/\=float2nr(floor(submatch(0)*1))/g}}}
    35 If instead you have a format like M 1234.678,9875.323 2345.0,123.45  - you'll want to convert if you want to try the crude script in (10) - otherwise a smarter script would be needed.  Here's a Vim one-liner for that syntax {{{s/\(\d\) \(\d\)/\1 L\2/g}}}  and {{{s/,/ /g}}}
    35 If instead you have a format like M 1234.678,9875.323 2345.0,123.45  - you'll want to convert if you want to try the crude script in (10) - otherwise a smarter script would be needed.  Here's a Vim one-liner for that syntax {{{s/\(\d\) \(\d\)/\1 L\2/g}}}  and {{{s/,/ /g}}}
    36 
    36 
    37 10) Convert the path data.  Here is a crude script to do that.  Note this one uses a line size of 1 (that's the 0x01 business).
    37 9) Convert the path data.  Here is a crude script to do that.  Note this one uses a line size of 1 (that's the 0x01 business).
    38 If you want larger lines you can pick anything between 0x01 and 0x3F.  That's 16-636.  See the map format wiki page.
    38 If you want larger lines you can pick anything between 0x01 and 0x3F.  That's 16-636.  See the map format wiki page.
    39 {{{
    39 {{{
    40 #!/usr/bin/perl
    40 #!/usr/bin/perl
    41 # just a one-line list of points. at least, it had better be one-line
    41 # just a one-line list of points. at least, it had better be one-line
    42 open FILE, $ARGV[0];
    42 open FILE, $ARGV[0];
    55     return;
    55     return;
    56 }
    56 }
    57 }}}
    57 }}}
    58 {{{script pointdata > hwpointdata}}}
    58 {{{script pointdata > hwpointdata}}}
    59 
    59 
    60 11) qCompress the data.
    60 10) qCompress the data.
    61 {{{g++ -I /usr/include/qt4 -I /usr/include/qt4/QtCore qcompress.cpp -lQtCore}}}
    61 {{{g++ -I /usr/include/qt4 -I /usr/include/qt4/QtCore qcompress.cpp -lQtCore}}}
    62 {{{
    62 {{{
    63 #include <QFile>
    63 #include <QFile>
    64 #include <QByteArray>
    64 #include <QByteArray>
    65 using namespace std;
    65 using namespace std;
    73     }
    73     }
    74 }
    74 }
    75 }}}
    75 }}}
    76 {{{./a.out hwpointdata hwpointdata.Z}}}
    76 {{{./a.out hwpointdata hwpointdata.Z}}}
    77 
    77 
    78 12) Convert to base64 and you're done!
    78 11) Convert to base64 and you're done!
    79 
    79 
    80 {{{base64 -w0 hwpointdata.Z > mynewhedgewars.hwmap}}}
    80 {{{base64 -w0 hwpointdata.Z > mynewhedgewars.hwmap}}}
    81 
    81 
    82 Enjoy.
    82 Enjoy.
    83 
    83