raphael

Resizing and dragging SVG polygons dynamically

时间秒杀一切 提交于 2019-12-05 18:14:51
问题 I am struggling to find a way for resizing and dragging a svg polygon dynamically with the mouse. Unfortunately jQueryUi does not work for svg elements. I also checked the Raphael library, but cant find any documentation/snippets on how to realize this. Besides using SVGs, is there any other way to resize and dragg a polygon graphic dynamically? 回答1: You can work with the SVG elements yourself. In particular, you can find the points of the polygon and add HTML-element handles which are made

Extrude, or, make 2d SVG path into 3d

帅比萌擦擦* 提交于 2019-12-05 18:07:28
I am wondering if anyone has heard of some javascript which can take a simple SVG path that took maybe 30 seconds to create in illustrator or something and convert it into something that looks 3d. There is an extrude function in illustrator which does this. It is also called polling in sketchUp. I am using Raphael.js now, but am open to other suggestions. A simple solution would be to make a copy of the path and move it a couple pixels down and to the right and give it a darker color behind the original path, but I am looking for something that might have a little more shading. Thanks! Timo

How to add text to a raphael js element

半腔热情 提交于 2019-12-05 15:53:29
问题 I want to add text to a element in raphael js, I have added text with r.text(30, 20, "ellipse").attr({fill: color}); But how to add this text to ec = r.ellipse(190, 100, 30, 20); regards 回答1: Raphael does not have child/parent relationship between elements, so you will set same position for them e.g. ec = paper.ellipse(190, 100, 30, 20); paper.text(190, 100, "ellipse").attr({fill: '#ff0000'}); So if you want a ellipse with text, create your own JavaScript object which handles positioning of

Raphael center of scale in transform method

瘦欲@ 提交于 2019-12-05 13:23:58
Right now I'm using: r.forEach( function (el) { el.scale(0.5, 0.5, 0.0, 0.0); }); to scale each object around (0/0), which is working fine. The Raphael reference however states that the scale function is deprecated and I'm supposed to use Raphael.transform(...) instead. I tried: r.forEach( function (el) { el.transform("S(0.5)"); }); however, this will scale the paths using the image center as the center of scale. How can I achieve the same effect with the transform function? You can use translation string the same way as parameters of "scale" function: el.transform("s0.5, 0.5, 0, 0"); el

How to modify raphael text?

柔情痞子 提交于 2019-12-05 12:26:45
问题 After instantiating Raphael text like so var t = paper.text(50, 50, "Raphaël\nkicks\nbutt!"); how do I go about then modifying that text? t.text = "test"; did not work for me. 回答1: You must use the .attr()docs method to change the text of an existing text element like this t.attr('text','new text here'); 来源: https://stackoverflow.com/questions/2172618/how-to-modify-raphael-text

DOM manipulation during large SVG rendering

霸气de小男生 提交于 2019-12-05 10:28:57
Ok, so I'm trying to finish up my project by setting "Loading..." message with percentage indicator. Easy enough. The problem is that I have a little over 6,000 of Raphael/SVG lines of code which inject something line 2,000+ new nodes to DOM . So the real problem comes when I'm trying to change my % indicator on loading message, but the browser is just frozen till Raphael will finish up creating all that nodes. What I've tried and what I know: 1) I have very simple function to calculate % of loading by increasing count var and spreading this function all over my 6,000 code. That way I simulate

Can't scale multiple paths in Raphael?

怎甘沉沦 提交于 2019-12-05 08:28:21
I've tried using the current top Question on SO : Scaling multiple paths with raphael ...without much luck. I'm building a map of the USA through Raphael and while the map is very nice, I need it to be probably 30% the size it is currently. I was able to change the attr on the initial Raphael canvas to ".5" but that only sized each individual path instead of the whole canvas. I have also tried using javascript to scale the div containing the canvas to no avail. Paths: Actual Page: http://praxxgray.com/am/rafe2/mapTest.html javascript: http://praxxgray.com/am/rafe2/js/initMap.js I'm new to

wrap text to fit into a rectangle : raphael

与世无争的帅哥 提交于 2019-12-05 07:50:15
Anyone know of function that can break text at word boundaries to fit into rectangle Following is code for rectangle and text window.onload = function () { var outsideRectX1=30, outsideRectY1=30,outsideRectX2=220, outsideRectY2=480, outsideRectR=10; var group = paper.set(); var rect1=paper.rect(outsideRectX1+40, outsideRectY1+70, 80, 40,10); var text3=paper.text(outsideRectX1+75, outsideRectY1+85,"Test code for wrap text").attr({fill: '#000000', 'font-family':'calibri', 'font-size':'14px'}); group.push(rect1); group.push(text3); }; When text is greater than rectangle width it automatically

animating paths with raphael

喜夏-厌秋 提交于 2019-12-05 07:06:27
I'm still trying to figure out Raphael and am stuck with some basic animation. have a look here: http://jsfiddle.net/d7d3Z/ it's simple enough: two paths that animate into place. What I want though is for it to appear to 'draw' this like a single line, rather than both starting together. How can I order the animations? You can call the second animation after the first one is over. window.onload = function() { var c= Raphael("canvas", 200, 200); var p = c.path("M140 100"); var r = c.path("M190 60"); p.animate({path:"M140 100 L190 60"}, 2000, function() { r.animate({path:"M190 60 L 210 90"},

Raphaël and D3.JS - Better Browser Compatibility

只谈情不闲聊 提交于 2019-12-05 06:14:04
问题 Is it possible to use D3 and Raphael together so that visualizations are produced by D3 (using D3's API to produce svg output) and correctly visualized in IE by Raphael ? I appreciate any example/sample code. 回答1: Yes you can. We've improved r2d3 from a compatibility project to an IE fallback for D3. This was achieved by having D3 wrap Raphael elements which we extended with methods such as setAttribute. This enables D3 to work with Raphael elements like they were DOM nodes. The project still