I am playing with the Raphael SVG library and I defined a element holding the Raphael canvas
<div id="canvas_container"></div>
and I placed the Raphael canvas/paper inside it :
paper = new Raphael(document.getElementById('canvas_container'), '100%', '100%');
Now I would like to get the absolute width/height of the canvas. I figured out how to access the canvas with paper.canvas but if I try to get the paper.canvas.width I get a SVGAnimatedLength element and not the width.
I noticed when using the Chrome dev-tools and selecting the paper.canvas in the console with the mouse, the proper absolute size appears in the window by the selected element (the blue selection appearing in the page when some element selected in the Chrome dev console). But how to get it in the code ?
I am playing with the Raphael SVG library and I defined a element holding the Raphael canvas
<div id="canvas_container"></div>
and I placed the Raphael canvas/paper inside it :
paper = new Raphael(document.getElementById('canvas_container'), '100%', '100%');
Now I would like to get the absolute width/height of the canvas. I figured out how to access the canvas with paper.canvas but if I try to get the paper.canvas.width I get a SVGAnimatedLength element and not the width.
I noticed when using the Chrome dev-tools and selecting the paper.canvas in the console with the mouse, the proper absolute size appears in the window by the selected element (the blue selection appearing in the page when some element selected in the Chrome dev console). But how to get it in the code ?
Share Improve this question edited Oct 3, 2019 at 7:43 Vadim Kotov 8,2848 gold badges50 silver badges63 bronze badges asked Mar 4, 2013 at 14:50 karlitoskarlitos 1,6564 gold badges29 silver badges64 bronze badges2 Answers
Reset to default 6You can use the offsetWidth
and offsetHeight
values of the canvas
object in order to determine the true dimensions of the Raphael canvas.
Example: http://jsfiddle/g54PR/1/
The properties paper.width
and paper.hight
will help you.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744544781a4579945.html
评论列表(0条)