Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drawing over an image using Raphael.js

Can I put a Raphael.js canvas over an IMG element? What should I do make this layout work?

like image 952
Vitor Py Avatar asked Aug 04 '10 15:08

Vitor Py


1 Answers

Simply position the Raphaël canvas over the top of the image element using normal CSS techniques:

#wrapper {
    position: relative;
    padding: 0;
    outline: 1px solid #999;
}
#wrapper img {
    position: absolute;
    top: 0;
    left: 0;
}
#canvas {
    position: absolute;
    top: 0;
    left: 0;
}

Then nest your elements like this:

<div id="wrapper">
    <img src="myimage.jpg">
    <div id="canvas">  
    </div>
</div>

Here's a full example.

like image 148
robertc Avatar answered Sep 20 '22 23:09

robertc