0

I am attempting to draw the path of a graph so that the path is transparent and the rest of the canvas is not. This way I can use the canvas as a mask and fill the path with different colors using html elements. Kind of like this:

  enter image description here  

Pavel Anossov
  • 60,842
  • 14
  • 151
  • 124
Michael
  • 373
  • 2
  • 15

2 Answers2

1

There's no way to achieve this natively through Raphael, but it could be accomplished by some selective modification of the SVG produced by Raphael. Consider the use of a mask applied to the path. This technique is used to absolutely delicious visual effect here.

Don't forget that you can access the DOM node associated with a Raphael paper object through that paper object's canvas property (I don't know why Baranovskiy chose such a misleading name!). You could use this to interact directly with the SVG in the DOM, though I can't vouch for interactions between Raphael and custom modifications =)

Kevin Nielsen
  • 4,413
  • 21
  • 26
  • 1
    Thanks for the suggestion, Kevin! I'm not doing too much heavy lifting with Raphael anyway, so I can probably stick to SVG. Not supporting IE in this application anyway ;) – Michael May 06 '13 at 21:08
0

To fill only the outer part of a path, you will have to draw what is often called a "donut" made of two path strings.

You will find a good example here : How to achieve 'donut holes' with paths in Raphael .

The idea is: * give the outer path string as a large counter clockwise closed rectangle, telling the browser that what has to be filled is what is inside * concat the inner path string as the clockwise closed path you want, telling the browser what has to be filled is what is outside.

Thus resulting in a filled shape with a hole which is the intersection of both filled shapes.

Community
  • 1
  • 1
atondelier
  • 2,424
  • 15
  • 11