raphael

SVG Gradient turns black when there is a BASE tag in HTML page?

懵懂的女人 提交于 2019-11-27 19:22:27
I am using the Raphaël JavaScript Library to create SVG elements in an HTML page and using CodeIgniter as a PHP framework. In the CodeIgniter framework I need to add a <base> tag in the head of the HTML document to use JS,CSS and images, but it caused a strange problem in the SVG element. When I use the <base> tag, gradients do not work. Instead, the object turns black. It behaves exactly the same with image filled path objects. SVG Gradients are defined in the document with a unique id attribute, and then referenced from another element as a URL. Typically the URL is just the identifier

Convert SVG polygon to path

走远了吗. 提交于 2019-11-27 17:53:16
I have a fairly large SVG file of administrative subdivisions that I need to work with in Raphael.JS (it has 600 polygons and weights 1.2 Mb). Now, I need to convert these polygons to paths so that it works in Raphael. The great poly2path tool does that, but it doesn't support any batch command, so that each polygon's position relative to the others is lost. Do you know of any tool to convert SVG polygons to paths? (I also have the AI file which was used to export the SVG). Many thanks Open your SVG in a web browser. Run this code: var polys = document.querySelectorAll('polygon,polyline'); []

How to either determine SVG text box width, or force line breaks after 'x' characters?

不羁的心 提交于 2019-11-27 17:44:03
I'm creating an SVG text box using the Raphael library, and filling it with a dynamic string which is extracted from an XML document. Sometimes, this string is longer than the canvas I am placing the text box on, so I need to either limit the width of the box which will itself force the line breaks (I can't find any evidence of this being possible) OR ensure that a '\n' line break is inserted after a certain amount of characters. So (1) is this the best option? And (2) how would I do this? There isn't an attribute for text wrapping, but there is a simple trick you can use. Add one word at a

drawing centered arcs in raphael js

强颜欢笑 提交于 2019-11-27 17:24:33
I need to draw concentric arcs of various sizes using raphael.js. I tried to understand the code behind http://raphaeljs.com/polar-clock.html , which is very similar to what I want, but, whithout comments, it is quite difficult to fathom. Ideally, I would need a function that creates a path that is at a given distance from some center point, starts at some angle and ends at some other angle. genkilabs That answer is ok, but cant be animated. I ripped the important stuff out of polar-clock for you. Here is a red arc that animates growing. enjoy. // Custom Arc Attribute, position x&y, value

How can one add drop shadows to Raphael.js objects?

*爱你&永不变心* 提交于 2019-11-27 15:54:44
问题 I would like to find out how to add blurry edged drop shadows to Raphael.js objects/paths. As far as I know it is not possible with the library as is but is there a work around? 回答1: Adding a link to Raphael.blur in a separate answer, per the OP's request. http://github.com/DmitryBaranovskiy/raphael/blob/master/plugins/raphael.blur.js Updated code sample: var shadow = canvas.path(p); shadow.attr({stroke: "none", fill: "#555", translation: "4,4"}); shadow.blur(4); var shape = canvas.path(p);

Canvas generated by canvg is blurry on retina screen

眉间皱痕 提交于 2019-11-27 15:14:02
问题 I'm using Raphael to draw an object, then transferring it to an HTML canvas element with canvg so that I can use toDataURL to save it as a PNG. But when I use canvg, the resulting image is blurry. The code below, for example, produces this (raphael on top, canvg on bottom): <html> <head> <script src="lib/raphael-min.js"></script> <script type="text/javascript" src="http://canvg.googlecode.com/svn/trunk/rgbcolor.js"></script> <script type="text/javascript" src="http://canvg.googlecode.com/svn

jQuery offset top doesn't work correctly

落花浮王杯 提交于 2019-11-27 14:44:51
问题 I'm trying to create an script draw something in an element by mouse and I'm using Raphaeljs to do that. For correct drawing I need to find top and left of ‍ input‍‍ element. I'm using var offset = $("#input").offset(); to get left and top . But the top value isn't correct. It's 10px lower than ‍‍the real top distance. I think the 10px maybe change in different resolutions then I can't add 10px to it normally then I want to know how can I fix the problem! I uploaded my test here. 回答1: The

How to animate a Raphael object along a path?

纵然是瞬间 提交于 2019-11-27 13:30:02
问题 The object could be simple, a rect or circle. But the path should be a bezier curve. Please provide javascript/Raphael code if not too much trouble. It will be nice if there is trailing effect of the moving object during annimation. 回答1: Just in case you are trying to use this with RaphaelJS 2 (animateAlong doesn't exist anymore), here you can see a possible solution: http://jsfiddle.net/gyeSf/17/. And here the original discussion: https://groups.google.com/forum/#!searchin/raphaeljs

Draggables and Resizables in SVG

我的梦境 提交于 2019-11-27 10:52:57
I want to make an svg element (path, rect, or circle) be able to be draggable and give it resize handles. But unlike HTML DOM, not all elements have an upper left hand corner x,y coordinate and a width and height for a box surrounding the content. This makes it inconvenient to make a generic resize or drag procedure. Is it a good idea to have each path or circle be drawn inside its own svg object to give me a box to play with? How is draggable/resizable typically implemented in SVG? Peter Ajtai Note: For both drag and resize, you'll have to make separate cases for certain different types of

How can I combine objects in the Raphael javascript library?

杀马特。学长 韩版系。学妹 提交于 2019-11-27 10:34:09
Sorry for a long question but here goes. I am trying to modify the drag shapes around demo here: http://raphaeljs.com/graffle.html The demo works fine. What I want to do is put words inside the shapes and move the shape and text around as a composite single object. Here is the code for creating the objects: window.onload = function () { var dragger = function () { this.ox = this.type == "rect" ? this.attr("x") : this.attr("cx"); this.oy = this.type == "rect" ? this.attr("y") : this.attr("cy"); this.animate({"fill-opacity": .2}, 500); }, move = function (dx, dy) { var att = this.type == "rect"