使用 Javascript 创建 SVG 图形? [英] Creating SVG graphics using Javascript?

查看:19
本文介绍了使用 Javascript 创建 SVG 图形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 JavaScript 创建 SVG 图形?

How can I create SVG graphics using JavaScript?

所有浏览器都支持 SVG 吗?

Do all browsers support SVG?

推荐答案

看看 this维基百科上关于哪些浏览器支持 SVG 的列表.它还提供了指向脚注中更多详细信息的链接.例如,Firefox 支持基本的 SVG,但目前缺乏大多数动画功能.

Have a look at this list on Wikipedia about which browsers support SVG. It also provides links to more details in the footnotes. Firefox for example supports basic SVG, but at the moment lacks most animation features.

可以找到有关如何使用 Javascript 创建 SVG 对象的教程 此处:

A tutorial about how to create SVG objects using Javascript can be found here:

var svgns = "http://www.w3.org/2000/svg";
var svgDocument = evt.target.ownerDocument;
var shape = svgDocument.createElementNS(svgns, "circle");
shape.setAttributeNS(null, "cx", 25);
shape.setAttributeNS(null, "cy", 25);
shape.setAttributeNS(null, "r",  20);
shape.setAttributeNS(null, "fill", "green"); 

这篇关于使用 Javascript 创建 SVG 图形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆