PDF 2 AI question
Posted by Giorgio on Mar 20, 2007
Hello,
This is not strictly related to Nodebox but it could be interesting to see if anybody on the forum already run into the same kind of problem.
Running the code pasted below... If I export the path to PDF and then open the PDF with Preview/Acrobat/Photoshop everything shows up 100% fine.
But If I open it using Illustrator only a smaller portion of the path shows up. Since it seems that a path in AI can contain up to 32,000 anchor points and this path counts only 1,002 points I'm curios to know if somebody on the forum has a clue on this problem...
size(600,600)
background(0.1,0,0)
cornu = ximport("cornu")
supershape = ximport("supershape")
nofill()
stroke(1)
strokewidth(0.5)
x = y = 300
w = h = 200
p = supershape.path(x, y, w, h, 4, 1, 0.1, 0.1)
#drawpath(p)
num_nodes = 0
points = []
for pu in p:
pu.x = (pu.x/(WIDTH))
pu.y = (pu.y/(HEIGHT))
points.append((pu.x, pu.y))
#print pu.x, pu.y
num_nodes += 1
print "This image has " + str(num_nodes) + " nodes"
stroke(1,random(0.5,1),0,random(0.7,1))
strokewidth(0.5)
cornu.drawpath(points,tweaks=5, points=False, close=True)
Posted by Mark on Mar 20, 2007
Giorgio,
The number of points in the paths that cornu creates in my experience is considerably greater than the number of points you give it. In your example you hand it 1002 points, but the cornu path it returns has 100200 points. You can test this by changing the last line in your script to:
print len(cornu.path(points,tweaks=5, close=True))
Also, in Illustrator if you select the path, go to simplify path (Menu->Object->Path->Simplify), and check the preview box, it will tell you how many control points your path has (after a little delay). In this case, the segment of the path that illustrator opened has 32005 points. I'm not sure if there is way to easily get a more efficient path from conru, but it would be nice. Good luck.
Posted by Giorgio on Mar 20, 2007
Mark,
Thanks for your post. Your explanation makes a lot of sense. So... I feel I will have to find an alternate solution (like splitting the path in more sub-paths).
grazie
ciao
Posted by Tom De Smedt on Mar 27, 2007
Hi Giorgio/Mike,
I don't know of a more efficient way to get paths from Cornu. The algorithm was written by Raph Levien and I should have paid more attention in math class to currently understand all of it.
It would be nice if Illustrator supported more than 32000 points.
Posted by Giorgio on Mar 20, 2007
update:
if i use 1/5 of the 1002 points (see code below) I end up having only 200 anchor points.
And in this case Illustrator shows the complete path... mmmm...