svg

Move dynamically created SVG with mouse

限于喜欢 提交于 2021-02-11 13:53:36
问题 I'm pretty new to HTML and JS, but I'm trying to learn some of the basics. Now I'm experimenting with graphics. I'm trying to create two svg elements dynamically with JS and then move them individually with the mouse. I'm able to create them, and register the mouse events on them individually, but can't get them to move. To try to move there positions, in my dragging() function I assign the svg style.top and style.left to the value of the pointer. I can confirm in the JS console that the

Character entities in PHP and SVG

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-11 13:40:58
问题 For my HTML content I have been using htmlentities($instring,ENT_QUOTES|ENT_HTML401,"UTF-8",false) to replace certain characters with HTML entities. However, I also serve SVG content, and some of the entities are not understood, such as … . Is there a special PHP function for character entities in SVG? 回答1: Use ENT_XML1 instead of ENT_HTML401 . SVG uses XML: htmlentities($instring,ENT_QUOTES|ENT_XML1,"UTF-8",false) 来源: https://stackoverflow.com/questions/59474432/character-entities-in-php-and

Character entities in PHP and SVG

坚强是说给别人听的谎言 提交于 2021-02-11 13:40:41
问题 For my HTML content I have been using htmlentities($instring,ENT_QUOTES|ENT_HTML401,"UTF-8",false) to replace certain characters with HTML entities. However, I also serve SVG content, and some of the entities are not understood, such as … . Is there a special PHP function for character entities in SVG? 回答1: Use ENT_XML1 instead of ENT_HTML401 . SVG uses XML: htmlentities($instring,ENT_QUOTES|ENT_XML1,"UTF-8",false) 来源: https://stackoverflow.com/questions/59474432/character-entities-in-php-and

svg with mask not seen on chrome

这一生的挚爱 提交于 2021-02-11 12:36:49
问题 I'm trying to mask with some svg path that is created dynamically with React. The problem is that the resulted html code doesn't render properly on Chrome and Safari immediately. Correct results appear on browser window resize or check/uncheck of a style property from inspector. I feel like the problem in one of the -webkit properties but can't define which. Tried -webkit-mask , but it didn't give any results. Here's the html structure that should render right away: <div> <div id="type-1

How to export svg image to png file in r?

旧城冷巷雨未停 提交于 2021-02-11 12:33:42
问题 I have some svg images that I want to export as png files, using r. Is there a function that can do that? Until now I only found function that export r plots to png. But how could I export e.g. this example as a png? <svg height="100" width="100"> <circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" /> </svg> 回答1: rsvg https://github.com/jeroenooms/rsvg is designed to specifically to do this, and I'll say it does it very quickly. 回答2: The package convertGraph may be the

Why does a link not take the <title> of a contained <svg> as it's accessible name?

a 夏天 提交于 2021-02-11 12:25:34
问题 The way to provide an accessible name for an <img> element is via its alt attribute. Similarly, the way to provide an acessible name for an <svg> element is via its <title> element. If I have an img tag within an a tag, the accessible name of the link is the accessible name of the img . However, if I have an svg within an a tag, the link has has no accessible name even if the svg does. Why is this? This is apparent within both Lighthouse audits and also the Accessibility tab of Firefox dev

Use a svg image to drag along a line in d3.js

安稳与你 提交于 2021-02-11 12:17:18
问题 I want to build a visualization in D3.js that illustrates the concept of potential energy and kinetic energy for my students. In essence, I want the students to be able to drag a skier up a slope (i.e. a Line) and when they drop him, he transits down again. I'm sure it is an easy task in D3 but I'm struggling to understand how I can get the skier icon to be draggable only along the line path? Here's an image for illustration: I want the skier icon to switch place with the ball with the green

Use a svg image to drag along a line in d3.js

南楼画角 提交于 2021-02-11 12:15:57
问题 I want to build a visualization in D3.js that illustrates the concept of potential energy and kinetic energy for my students. In essence, I want the students to be able to drag a skier up a slope (i.e. a Line) and when they drop him, he transits down again. I'm sure it is an easy task in D3 but I'm struggling to understand how I can get the skier icon to be draggable only along the line path? Here's an image for illustration: I want the skier icon to switch place with the ball with the green

svg path pointer-events - click detection

别来无恙 提交于 2021-02-11 10:10:16
问题 I'm writing some HTML so that I can draw a Bezier curve using the HTML SVG and PATH tags. My curve comes out really nice and now I want to add a capability where if a user hovers his/her mouse over the curve I change the color. What's happening though is that the SVG creates a large box that contains the path and it catches all clicks. It's essentially blocking everything underneath it, even in areas where the path is not present. Imagine that the path goes from the bottom left corner to the

svg path pointer-events - click detection

北城以北 提交于 2021-02-11 10:07:03
问题 I'm writing some HTML so that I can draw a Bezier curve using the HTML SVG and PATH tags. My curve comes out really nice and now I want to add a capability where if a user hovers his/her mouse over the curve I change the color. What's happening though is that the SVG creates a large box that contains the path and it catches all clicks. It's essentially blocking everything underneath it, even in areas where the path is not present. Imagine that the path goes from the bottom left corner to the