having problem with closePath() (beginner)

38 views
Skip to first unread message

M. Scott Veach

unread,
May 13, 2013, 2:47:55 PM5/13/13
to pap...@googlegroups.com
I'm trying to give some simple shapes I'm drawing with paperjs a hand-sketched look.

There are a couple techniques I am using to achieve this. One of them is to start with a simple
shape, say a circle, and then draw a second path on top of the shape with a much thinner stroke
where each one of the points of the second path is just slightly offset in a random direction from
the corresponding point in the underlying shape.

With the right offset and smoothing, this creates a fairly compelling illusion that someone traced
over the shape a few times.

To do this, I am iterating over the segments of the original shape, cloning the three points of
the segment (point, handleIn and handleOut) into a new segment. Offsetting those points just a bit
so it's not an exact copy. Then adding that new segment into a new path.

This works fine as long as I don't call closePath(). But the second I call closePath() the entire path
won't display. If I don't call closePath(), I see all the segments with a gap between the last and the
first. If I call closePath(), nothing is displayed.

Does anyone have any idea what might be going on here?

One possibly relevant detail: the original, bottom-layer shape is being made with the Circle constructor.
I then use flatten followed by smooth to give myself a bunch of segments to work with, then I mess
around with the segments and use various transforms on the path until what I have at the end
is a misshapen closed curve.

That's the underlying shape I start with--then I start to "trace" over it but this time I don't use
Circle constructor, I simply build up the path segment by segment and try to close it at the end
with a call to closePath().

I hope that's clear... I'm fairly new to all of this and find that being able to describe a problem is
often much harder than being able to solve it...!

Jürg Lehni

unread,
May 13, 2013, 4:34:55 PM5/13/13
to pap...@googlegroups.com
Closing paths tells the paths that they have to be filled. If they have a fill color defined, that fill color will then paint over the paths below them. Is this perhaps what's happening?

Try setting "path.fillColor = null;" to see if that's the case.

If that doesn't work, try setting "path.fullySelected = true;" on both paths and see if they are still there.

If both doesn't work out, please provide a test case (e.g. on http://jsfiddle.net/) so we can look into it. Thanks!

Jürg
> --
> You received this message because you are subscribed to the Google Groups "Paper.js" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to paperjs+u...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Reply all
Reply to author
Forward
0 new messages