SVG基本图形
SVG 是使用 XML 来描述二维图形和绘图程序的语言
- SVG 指可伸缩矢量图形 (Scalable Vector Graphics)
- SVG 用来定义用于网络的基于矢量的图形
- SVG 使用 XML 格式定义图形
- SVG 图像在放大或改变尺寸的情况下其图形质量不会有所损失
- SVG 是万维网联盟的标准
- SVG 与诸如 DOM 和 XSL 之类的 W3C 标准是一个整体
SVG坐标系统:
一、圆
<svg width="" height="">
<circle cx="" cy="" r="" fill="blue" stroke="gray" stroke-width=""></circle>
</svg>
cx和cy属性定义圆点的x和y坐标,如果省略cx和cy,圆的中心会被设置为(0,0);r定义半径;
fill:内部填充颜色;stroke:轮廓颜色;stroke-width:轮廓宽;opacity:透明度, 0.0完全透明,1.0不透明
二、矩形
<rect
x=
"0"
y=
"0"
width=
"500"
height=
"50"
/>
三、椭圆
<ellipse
cx=
"250"
cy=
"25"
rx=
"100"
ry=
"25"
/>
四、线条line
<line
x1=
"0"
y1=
"0"
x2=
"500"
y2=
"50"
stroke=
"black"
/>
五、折线polyline
用来创建只包含直线的形状
<svg>
<polyline points="0,0 0,20 20,20 20,40 40,40 40,60" style="fill:white;stroke:red;stroke-width:2"></polyline>
</svg>
六、路径path
下面的命令可用于路径数据:(命令详情可查看https://segmentfault.com/a/1190000005053782)
- M = moveto 两个参数 画笔起始位置
- L = lineto 两个参数,画直线(x ,y)坐标 ,在当前位置和新位置(L前面画笔所在的点)之间画一条线段
- H = horizontal lineto 一个参数,绘制水平直线
- V = vertical lineto 一个参数,绘制垂直线
- C = curveto 三次贝塞尔曲线 命令参数:C x1 y1, x2 y2, x y 起点控制点,终点控制点,终点
- S = smooth curveto 简写的贝塞尔曲线命令 命令参数:S x2 y2, x y
- Q = quadratic Belzier curve 二次贝塞尔曲线 命令参数:Q x1 y1, x y 控制点,终点坐标
- T = smooth quadratic Belzier curveto Q命令的简写 T x y
- A = elliptical Arc
- Z = closepath 闭合路径,从当前点画一条直线到路径的起点。不区分大小写
注释:以上所有命令均允许小写字母。大写表示绝对定位,小写表示相对定位。
<svg>
<path d="M250 150 L150 350 L350 350 Z" stroke="blue" stroke-width="2"/>
</svg>
五、text
<text
x=
"250"
y=
"25" fill="gray" font-family="serif" font-size="25"
>
Easy-peasy</text>
Layering and Drawing Order

<svg width="" height="">
<rect x="" y="" width="" height="" fill="purple"/>
<rect x="" y="" width="" height="" fill="blue"/>
<rect x="" y="" width="" height="" fill="green"/>
<rect x="" y="" width="" height="" fill="yellow"/>
<rect x="" y="" width="" height="" fill="red"/>
</svg>
Transparency
<circle cx="" cy="" r="" fill="rgba(128, 0, 128, 1.0)"/>
<circle cx="" cy="" r="" fill="rgba(0, 0, 255, 0.75)"/>
<circle cx="" cy="" r="" fill="rgba(0, 255, 0, 0.5)"/>
<circle cx="" cy="" r="" fill="rgba(255, 255, 0, 0.25)"/>
<circle cx="" cy="" r="" fill="rgba(255, 0, 0, 0.1)"/>
<circle cx="" cy="" r="" fill="rgba(128, 0, 128, 0.75)"
stroke="rgba(0, 255, 0, 0.25)" stroke-width=""/>
<circle cx="" cy="" r="" fill="rgba(0, 255, 0, 0.75)"
stroke="rgba(0, 0, 255, 0.25)" stroke-width=""/>
<circle cx="" cy="" r="" fill="rgba(255, 255, 0, 0.75)"
stroke="rgba(255, 0, 0, 0.25)" stroke-width=""/>
<svg width="" height="">
<circle cx="" cy="" r="" fill="purple" stroke="green" stroke-width=""/>
<circle cx="" cy="" r="" fill="green" stroke="blue" stroke-width=""/>
<circle cx="" cy="" r="" fill="yellow" stroke="red" stroke-width=""/>
</svg>
<circle cx="" cy="" r="" fill="purple" stroke="green" stroke-width=""
opacity="0.9"/>
<circle cx="" cy="" r="" fill="green" stroke="blue" stroke-width=""
opacity="0.5"/>
<circle cx="" cy="" r="" fill="yellow" stroke="red" stroke-width=""
opacity="0.1"/> //透明度应用在整个circle元素上
<circle cx="" cy="" r="" fill="rgba(128, 0, 128, 0.75)"
stroke="rgba(0, 255, 0, 0.25)" stroke-width=""/>
<circle cx="" cy="" r="" fill="rgba(128, 0, 128, 0.75)"
stroke="rgba(0, 255, 0, 0.25)" stroke-width="" opacity="0.5"/>
<circle cx="" cy="" r="" fill="rgba(128, 0, 128, 0.75)"
stroke="rgba(0, 255, 0, 0.25)" stroke-width="" opacity="0.2"/>
SVG基本图形的更多相关文章
- 多比(SVG/VML)图形控件多比(SVG/VML)图形拓扑图控件免费下载地址
多比图形控件是一款基于Web(VML和SVG技术)的矢量图形控件, 类似于网页上的Visio控件拓扑图软件,是目前国内外最佳的基于web的工作流设计器.工作流流程监视器解决方案. 可广泛应用于包括:电 ...
- 【D3.V3.js系列教程】--(十五)SVG基本图形绘制
[D3.V3.js系列教程]--(十五)SVG基本图形绘制 1.path <!DOCTYPE html> <html> <head> <meta charse ...
- 理解SVG的图形填充规则
SVG的图形填充规则通过fill-rule属性来指定. 有效值: nonzero | evenodd | inherit 默认值: nonzero fill-rule属性用于指定使用哪一种算法 ...
- D3.js学习笔记(六)——SVG基础图形和D3.js
目标 在这一章,我们将会重温SVG图形,学习如何使用D3.js来创建这些图形. 这里会包括前面例子中的SVG基础图形以及如何使用D3.js设置图形的属性. 使用D3.js画一个SVG 的 圆 circ ...
- SVG 基础图形
SVG 基础图形 SVG包含了以下的基础图形元素: 矩形(包括可选的圆角),使用<rect>元素创建 圆形,使用<circle>元素创建 椭圆形,使用<ellipse&g ...
- SVG基础图形与参数
SVG是什么 SVG 指可伸缩矢量图形 (Scalable Vector Graphics) SVG 用来定义WEB上使用的矢量图 SVG 使用 XML 格式定义图形 SVG 图像在缩放时其图形质量不 ...
- SVG基本图形及clipPath;
利用SVG可以实现很多复杂的图形,SVG的功能开发者们已经开发许多,今天初识一下SVG的基本图形绘制, <svg viewbox="0,0,400,400" style=&q ...
- SVG绘制图形
一.SVG介绍 1.SVG指可伸缩矢量图片 2.SVG用来定义用于网络的基于矢量的图形 3.SVG使用XML格式定义图形 4.SVG图像在放大或改变尺寸的情况下其图形质量不会有损失 5.SVG是万维网 ...
- SVG基础图形和D3.js
使用D3.js画一个SVG 的 圆 circle 可以使用如下代码创建: <svg width="50" height="50"> <circ ...
- SVG 旋转图形实例
本实例展示如何在SVG中画出一个正方形并使之旋转.运行结果如下图所示: 在文本框中输入时间间隔,单位是毫秒.点击Start按钮,蓝色方块就会开始转动,每个时间间隔变化一度.变换的角度在下面的Angle ...
随机推荐
- ES6内容
iterator 遍历器iterator makeIterator是个遍历器,生成遍历器对象it var it = makeIterator(['a', 'b']); it.next() // { v ...
- 公用表表达式 (CTE)、递归
指定临时命名的结果集,这些结果集称为公用表表达式 (CTE).公用表表达式可以包括对自身的引用.这种表达式称为递归公用表表达式. 对于递归公用表达式来说,实现原理也是相同的,同样需要在语句中定义两部分 ...
- Selenium库简介
Selenium是一个自动化测试工具,利用它可以驱动浏览器执行特定的动作,如点击.下拉等操作,同时还可以获取浏览器当前呈现的页面的源代码,做到可见即可爬.对于一些JavaScript动态渲染的页面来说 ...
- Config 代码片段
class Config { private static Config _instance = null; public static Config Instance { get { if (_in ...
- JMS - ActiveMQ的简单使用
首先需要下载ActiveMQ,下面的链接给我们列出了所有版本:http://activemq.apache.org/download-archives.html每个版本为不同的OS提供了链接: 公司电 ...
- 修改django 后台admin用户的密码
python manage.py shellfrom django.contrib.auth.models import User from django.contrib.auth.models im ...
- springboot1.5.10兼容高版本6.1.1elasticsearch
1.引入依赖 <dependency> <groupId>org.elasticsearch</groupId> <artifactId>elastic ...
- class文件反编译工具jd-gui下载地址
https://github.com/java-decompiler/jd-gui/releases windows下载: 下载后打开软件,直接将jar包拖进去: 效果图非常美观:
- tmux使用技巧
1.tmux 进入tmux 2.在tmux中 按ctrl+b 表示要进行tmux操作了. 3. c -> create a session 4. "," -> ren ...
- CentOS 7 禁用IPV6以提高网速
方法 1 编辑文件/etc/sysctl.conf,$vi /etc/sysctl.conf添加下面的行: net.ipv6.conf.all.disable_ipv6 = net.ipv6.conf ...