views:

432

answers:

2

Does anyone know if it's possible, either natively or mathematically with javascript, to implement the evenodd fill-rule from SVG in the HTML5 canvas element? Links to projects that do this would be helpful.

Thanks!

A: 

Yes, it should be possible with globalCompositeOperation. If I'm not mistaken, default "source-over" value should correspond to SVG's "evenodd" (otherwise, try few others one and see if resulting image looks identical).

kangax
This works if you are drawing more than one shape. But if you are drawing a single path, it does not. Any other thoughts?
devongovett
A: 

By mathematically do you mean an algorithm implementation ? It is certainly possible, see http://gpolo.awardspace.info/fill/main.html. It is more a demo than anything, but it solves this issue "mathematically".

Abc