Thursday, September 9, 2010

SVG Behavior - Size makes a difference

I've been playing with files that people have sent me and it's been quite interesting to try to ferret out why the eCraft reacts so differently to seemingly similar paths.  But, there are a couple of things I'd like to point out that I have found.

First, the best way to study the behavior of the eCraft with imported SVG is to change the output from CUT to Pen.  Click on the shape and select the PEN radio button.  The lines will turn red.  However, you cannot rely on color alone to determine if a shape will cut or draw.  If you copy and paste an image that was selected for PEN, the copy will show in red; but, it will revert to CUT.  You must click on the object to see which radio button is selected for each object.

The pen allows you to observe the detail of the rendering WAY better than a cut permits.  And, you can send the eCraft a file that could not actually be cut, such as the Penguin, by Ruthie Gedalovitch (UK) that you will see later.

But first, let's examine some drawings that were made to experiment with a file sent to me by Carolina Mejia of Tienda de Scrapbookin in Columbia, South America.  In fact, she sent me three different SVG files and we'll examine the others later.  But first left's look at Corazon.SVG that was created in CorelDraw and exported as an SVG.  The first thing I do when testing a new SVG is to look at the XML style code inside the file.  Here is what the CorelDraw SVG looked like.

As you can see, there are spaces between the letters.  At first, I thought this was a CorelDraw issue.  But, I believe it has to do with having been created on a machine having a CodePage for South America,  But, it threw me at first.  I then imported the SVG file, converted it to a PEN drawing rather than a cut and came up with this.

Kind of ragged, isn't it?  But, this is a perfect example of why using the PEN is better than using the CUT when first testing an SVG shape in eCraftShop Pro.  We can instantly see that this will not cut.  And, because we were drawing rather than cutting we could use nice cheap printer paper for our tests!

Of course I wanted to see if the CorelDraw format was the problem.  So, I imported the CorelDraw SVG into Inkscape and saved it in PLAIN format SVG.  Here is the drawing that resulted from this test.

At first glance, that's quite an improvement.  But, there are those pesky misalignments between the starting and the ending.  And, there is some artifacting near the bottom.  So, I wondered if I could make it smoother. So, I brought it back into Inkscape and examined the number of NODES that CorelDraw had used to form the heart.  There were just four NODES and it looked like this.

So, I added some NODES to see if that helped at all.  I hen saved this one in Inkscape's special format SVG that includes more information about the SVG than the PLAIN version.

Then I decided to use the three different SVG files together in various combinations to test them against each other.  First there was the CorelDraw vs. Inkscape Plain.  Whoaaa!  What happened?  The CorelDraw version seems cleaned up and the Inkscape version looks horrible!

This didn't make any sense, so I decided to compare the CorelDraw version against the new Inkscape version with the higher number of NODES.

Once again, I am shocked!  Now the CorelDraw version appears to be PERFECT and while the Inkscape formatted SVG was better, it didn't match the CorelDraw shape.  Now, I am REALLY confused.  But, my motto is "When in doubt, do more!"  So, I decided to put all three versions to the test.

The results were still puzzling until I realized that each of these looked like they were the same size.  But, they were not.  Each time I had manually resized each of them in eCraftShop Pro.  So, each of them was a slightly different size.  So, I tried one more test.

I removed the Inkscape versions an then copy and pasted the CorelDraw version two more times, changing the size each time.  As you can see, the SIZE of an SVG shape makes a difference in how accurately it will be cut or drawn in the current version of eCraftShop Pro.  This is why we saw a horrendous drawing when I first tried the CorelDraw version and then saw a perfectly clean rendering from that very same file in other tests.

So, if you are having problems with alignment or smooth path issues, try resizing the shape just slightly and see if it improves.  Obviously, this will have to be fixed in future versions of the software; but, for now we might be successul with problem shapes simply by tweaking the size a bit.

 Now, about Ruthie's Penquin.  When I first attempted to render the penquin two of the paths in the SVG would fail and halt the process.  In order to debud this file, I first moved all the PATHS around in Inkscape so that I could more easily see how each individual PATH printed.

 It turned out that the offending PATHS were the Iris of his left eye and the white front piece.  Looking at the code, it was impossible to see why it failed. The code looked perfectly OK and it rendered on the eCraftShop Pro virtual mat just fine.  But, they hung up the machine.  I replaced those two PATHS by copying one of the working eyes and resizing it.  Once I'd found and fixed the bad PATHS, I recombined them.

Now, this would NOT be a valid layout to CUT as you see it below,  But, it WAS useful to see how the eCraft and/or the eCraftSho Pro software thinks.  Consider how the reconstituted and combined penguin was drawn.
The first thing to note is that there is a circle (GREEN ARROW) at the top of one eye that the eCraft seemingly created out of thin air.  Rather than the deliberate stepping kind of cut, it zipped around smoothly to make that circle.  The second thing to notice is that the eCraft or eCraftShop Pro does NOT always select individual PATHS to cut.  It seems to combine the PATHS and then try to figure out how the COMBINED PATHS shoul be rendered.  Notice the the area at the bottom of one eye is disconnected from both the body and the eye. (BLUE ARROW)  And, in that same area, notice the little drop down just over the beak.  The PATH of the 'White' part of a penquin seems to be connected and rendered with the eye as one drawing.

The feet and body overlap (RED ARROW) is handled in a VERY interesting way.  When the foot was drawn, the pen created a little indentation or dip that corresponded with the body's PATH at the point.  And, then, when the body was drawn, the pen went UP to follow along the top of the foot that overlapped the body.  In other words, the foot wasn't rendered as the foot.  And, the body wasn't rendered as the body along.  Each of the lines that the pen drew contained elemonts of TWO different paths.

Obviously, this would NOT have cut well.  But, it was a lot of fun trying to figure out how the eCraft handles PATHS.  And, in particular, paths that intersect.  I don't know how interesting this has been to you; but, I hope there was something helpful that you were able to glean from my curiosity.

By the way, I believe that the misalignment between the beginning and ending points that shows up in larger paths may be due to mathematical rounding errors in the software.  It may be that the developers are not using enough decimal places in the conversion of the SVG paths to the rendering engine.  The SVG files seem to prefer at least 5 decimal places.  But, there is also the reality that rounding errors are common in application software.


Ruthie said...

This is all kinda freaking me out! I am finding myself reading through your posts....all the way through...not skipping bits! And I seem to be understanding them! Must be your teacherish coming out - I would NEVER have bothered reading this sort of technical stuff before! Just love how life throws you opportunities to grow!

Thanks Tom!


Tom Meeks said...

Or, it could be that we both think like eight year olds!

Our brains are on the same wave length. LOL!!

Carolina said...

So tom.... Do we have to wait until Craftwell improves the software?, does this takes long? I really want to cut many shapes that I have designed on Corel....
Do you know if Craftwell is working in fixing this problem?
I also have problems with the drivers.... I think they must design a new version of the drivers and of the software soon beacuse there will be many upset clients.
I am good with computers an fluent with design platforms, but a regular craft costumer, does not understands all this issues and will not be albe to use the eCraftShop Pro with all it potential.

Tom Meeks said...

Hopefully, Digital Avenues will recognize that they cannot hide behind Craftwell and that it is in their best interest to go all out fixing the most critical problems IMMEDIATELY. Their reputation is on the line as well as eCraft's.

So, we do have to wait for a week or so for the patch. I would just continue to learn the eCraft by experimenting with materials and the SD card until we get that patch.