Help with SVG format for Wacom Inkling data

Discuss SVG code, accessible via the XML Editor.
roelj
Posts: 6
Joined: Sat Jul 28, 2012 3:25 am

Help with SVG format for Wacom Inkling data

Postby roelj » Wed Oct 02, 2013 3:08 am

I'm writing a conversion tool to convert Wacom Inkling (WPI) files to SVG files. I'm already on the right track, the tool is capable of extracting stroke data, pressure data, 'tilt' data and 'new layer' data (there's a button to "create a new layer" on the Inkling) from the WPI files.

I don't know how to create efficient SVGs for the data. I attached a sample of my SVG output, and I'm wondering how I can combine the data to create a good conversion.
Here's a sample of the SVG file I generated with the tool:

Code: Select all

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
  "http://www.w3.org/Graphics/SVG/2.2/DTD/svg11.dtd">
<svg width="210mm" height="297mm" version="1.1"  xmlns="http://www.w3.org/2000/svg">
<g inkscape:label="Layer 0" inkscape:groupmode="layer" id="layer0">
  <!-- Start of stroke -->
  <g id="group0">
    <rect x="64684pt" y="3979pt" width="1cm" height="1cm" />
    <!-- Pressure: 651 -->
    <!-- Tilt: (x = 0, y = 0) -->
    <rect x="64685pt" y="3981pt" width="1cm" height="1cm" />
    <!-- Pressure: 724 -->
    <!-- Tilt: (x = 0, y = 0) -->

  ...

  </g>
</g>
<g inkscape:label="Layer 3" inkscape:groupmode="layer" id="layer3">
  <!-- Start of stroke -->
  <g id="group10">

    ...

  </g>
</g>
</svg>


EDIT: I added <g> tags for grouping a "stroke".
EDIT 2: I added layer support for Inkscape.

The data explained:
In a <rect> there's x and y. The data from the Inkling is the number (without "pt"). I hardcoded the width and height attributes to be "1cm".
For all the other data, I put the exact number into the comment.

So, how should the ideal SVG look like having this data?

P.S. I'll release the software under the GPLv3+ license whenever it's useful (if you'd like to help developing the program I can share the code. It's written in C).

v1nce
Posts: 696
Joined: Wed Jan 13, 2010 4:36 am

Re: Help with SVG format for Wacom Inkling data

Postby v1nce » Wed Oct 02, 2013 7:39 am

(there's a button to "create a new layer" on the Inkling)


What's this supposed to do ? Start a new blank page ? Or (re)start a new stroke on same page ?

Anyways,

I'm not sure SVG is the way to go.
I think you'd rather look at

http://www.graffitimarkuplanguage.com/
http://svg-wow.org/graffitis/graffitis.xhtml

perhaps one day we'll be able to mix up gml with svg.

something like
svg
svg:defs
gml:stroke id="inputs"
/svg:defs

svg:path bind:x={#inputs:x} bind:y={#inputs:y} bind:radius={#inputs:pressure}

If you really want to store it in svg you should use path IMO

path id="foo" d="Mx,y x1,y1 ..."

see http://www.w3.org/TR/SVG/paths.html#Pat ... toCommands
that's what is don by the graffiti => svg viewer
http://svg-wow.org/blog/2010/09/06/graffitis/

This won't store pressure or tilt but you could store them in a custom attributes
path id="foo" d="Mx,y x1,y1 ..." foo:tilt="tx,ty tx11,ty1..." foo:pressure="p p1 p2..."

Maybe pressure could be stored in the svg2 variable-width stroke to come...

v1nce
Posts: 696
Joined: Wed Jan 13, 2010 4:36 am

Re: Help with SVG format for Wacom Inkling data

Postby v1nce » Wed Oct 02, 2013 8:27 am

Do you know about this one ? http://forum.wacom.eu/viewtopic.php?f=11&t=9501

edit : the pdf is down. you prbably could get it here http://download.microsoft.com/download/0/B/E/0BE8BDD7-E5E8-422A-ABFD-4342ED7AD886/InkSerializedFormat(ISF)Specification.pdf


this looks like a binary file for storing x,y,... I knew about graffiti but it seems like there's a w3c xml file format that does the same
http://www.w3.org/TR/InkML/

So maybe you could do it in 2 steps : wpi [=> normalisation ?] => xml of events log (inkxml or graffiti) => svg

The step 2 could be as simple as an xsl stylesheet (or as complex as the LPE powerstroke in inkscape) or you could ask http://svg-wow.org/blog/2010/09/06/graffitis author (vincent Hardy ?) if you could borrow portion of his code (which is under Creative Commons 0 FWIU)

roelj
Posts: 6
Joined: Sat Jul 28, 2012 3:25 am

Re: Help with SVG format for Wacom Inkling data

Postby roelj » Fri Oct 04, 2013 4:01 am

Thank you for the informative replies. I had to do a lot of reading to figure out what to do.

v1nce wrote:
(there's a button to "create a new layer" on the Inkling)


What's this supposed to do ? Start a new blank page ? Or (re)start a new stroke on same page ?


The "create new layer" button creates a new layer in Adobe Illustrator. My current implementation creates a new layer in Inkscape (which basically is a "special" group on the same page).

What I'm doing now is store all the data in a linked-list, so I can write multiple export formats.

Personally, I really want to be able to open the files in Inkscape, so I'm going to implement SVG first.

Using the path element seems the way to go. I also got help on IRC. The idea to implement pen pressure is to create an outline and fill it, make it wider
when the pressure is higher, and thinner when it's lower.

I still have to read more about InkML. It looks good from what I've read (which is not much).

The Graffiti Markup Language seems to be nice also. Working with this to convert it to SVG (which for me is the format I'd like to use) seems to be an extra step. I might implement
it at a later time though.

Lazur
Posts: 4717
Joined: Tue Jun 14, 2016 10:38 am

Re: Help with SVG format for Wacom Inkling data

Postby Lazur » Sun Oct 06, 2013 10:28 am

Interesting topic, to say at least.
I have no idea in the implementation or anything with coding, but I have some ideas.

I am thinking of a calligraphic stroke option someday, where
at each nodes a pen shape would be stored, and the stroke would be "calculated" upon.
Like, with each node you could have a different pen shape,
with different transformation data-s.

Wich data could be imported from a wacom tablet too:
The higher the pressure is, the more the pen shape's width will be.
Also, somehow the rotation should be stored too.
Many calligraphed letter styles use the pen shape's angle instead of pen pressure.


And as the input data from wacom would define the pen shapes,
you could set the program's interpolation method between the pen shapes along the stroke.

roelj
Posts: 6
Joined: Sat Jul 28, 2012 3:25 am

Re: Help with SVG format for Wacom Inkling data

Postby roelj » Fri Jan 17, 2014 2:40 am

Sorry to bring up an old topic. I decided to release the code on Github in the hope someone can help:
https://github.com/roelj/inklingreader

What I've done so far:
  • Created a WPI file parser that gets the stroke, tilt and pressure data from the file.
  • Created a cairo-based exporter that makes an SVG from the parsed data.
  • Created graphical user interface to open a file and display it

Don't get your hopes up though because it's pretty non-functional since something either in the parser, exporter or somewhere in between, something goes wrong.

I think it is a good base to improve on. I'm trying to port a other software that seems to be Windows-only, but seems to be succesful in displaying the data correctly.

If there's anyone interested in improving this software, please don't hesitate to contact me.


Return to “SVG / XML Code”