I want to draw a shape that has a double line border using html5 canvas path. The default stroke (context.stroke()) has a single line type of path. I can draw a similar shape inside an original shape to generate a figure that looks like a one made with two border lines, but I want some kind of generic solution. Any ideas?
相关问题
- Highlight parent path to the root
- Does using percentages instead of pixels change an
- Method for drawing circles in a pyramid pattern
- How to get a fixed number of evenly spaced points
- Rounded corners on a textarea with a scrollbar
相关文章
- HTML5 control
- linux / libusb get usb device path
- How to get server path of physical path ?
- canvas.toDataURL() not working properly [duplicate
- Why ContextClassLoader returns path with exclamati
- Can I add a border to an SKSpriteNode, similar to
- libxml2.2.dylib reference in python program
- How can I resolve a relative path to absolute path
There are several ways to do this. One simple way would be to draw a fat line and "cut out" the middle of it, leaving two smaller strokes.
What you want to do is draw any kind of path - on an in-memory, temporary canvas - and then draw the same path with less thickness and with the
globalCompositeOperation
set todestination-out
on that same canvas.That will get you the shape you want, essentially 2 lines with transparency between them.
Then you draw that canvas onto the real canvas that has whatever on it (complex background, etc).
Here's an example:
http://jsfiddle.net/uTbsC/