svg复用方式<g>, <defs>, <symbol>, <use>
svg复用元素的方式主要有 <g>, <defs>, <symbol>, <use>
1. <g>
group, 分组,定义一组元素,初始不可见
<g id="group" fill="red">
<rect x="10" y="10" width="100" height="100" />
<rect x="120" y="10" width="100" height="100" />
</g>
2. <defs>
定义一些可供重用的元素,组,普通形状,渐变,mask,滤镜fliter,初始不可见
例如:
<defs>
<g id="g1">
<rect id="rect1" width="100" height="50" x="10" y="10" fill="#c00"/>
<circle id="circle1" cx="30" cy="30" r="10" fill="#00c"/>
</g>
<linearGradient id="a1">
<stop offset="5%" stop-color="#F00" />
<stop offset="95%" stop-color="#ff0" />
</linearGradient>
<path id="a1" d="M0 50 C150 150 100 -50 300 50" stroke="#000" fill="none"/>
<mask id="mask1">
<rect x="50" y="50" width="100" height="100" fill="#ccc"/>
<rect x="150" y="150" width="50" height="50" fill="#fff"/>
</mask>
<filter width="200" height="200" x="0" y="0" id="blur" filterUnits="userSpaceOnUse">
<feGaussianBlur stdDeviation="5" />
</filter>
</defs>
3. <use>
使用定义的元素,包括<g>, <defs>, <symbol>
<use xlink:href="#g1"/>
<use xlink:href="#rect1" x="110"/>
<use xlink:href="#circle1" x="210"/>
4. <symbol>
定义可重复使用的符号,初始不显示,能够创建自己的视窗,所以能够应用viewBox和preserveAspectRatio属性
<symbol id="symbol" viewBox="0 0 250 250">
<rect x="90" y="110" width="100" height="100" />
</symbol> <use id="ant"
transform="translate(0 110) rotate(10 0 0)"
fill="red"
xlink:href="#symbol" />
svg复用方式<g>, <defs>, <symbol>, <use>的更多相关文章
- [翻译svg教程]svg 中的g元素
svg 中的<g>元素用来组织svg元素.如果一组svg元素被g元素包裹了,你可以通过对g元素进行变换(transform),被g元素包裹的元素也将被变换,就好这些被svg包裹的元素是一个 ...
- Ubuntu系统---编译opencv程序的几种方式g++、Makefile、Cmake
Ubuntu系统---编译opencv程序的几种方式g++.Makefile.Cmake 先建立一个工程(一个文件夹),写好xxx.cpp文件,可以是多个: //----------opencv.cp ...
- 蛋疼的SVG外部引用方式
SVG在html页面中有两种引用方式: 1. 内联.就是直接将SVG图形写在html的svg标签中,比如: <html> <head></head> <bod ...
- js动态创建svg与use 使用iconfont symbol
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 酷炫的SVG 动态图标
在 loading.io 上能看到好多效果惊艳的loading图标.它们都是用svg写成的,寥寥几 ...
- W3C推进SVG规范Ver1.1(中文译稿)—Part I
转自:http://www.gispark.com/html/GISarticle/2006/1215/826.html Scalable Vector Graphics (SVG) 1.1 Spec ...
- svg 使用中的疑惑点
svg,g ,defs,symbol 都是容器元素,使用起来给人许多疑惑 svg-spirite-loader在页面生成的svg标签有什么特点? svg标签里面的symbol有什么用? 这些标签能够随 ...
- Jamstack Conf 2020
Jamstack Conf 2020 Jamstack Conf Virtual https://jamstackconf.com/virtual/ Conf Schedule https://jam ...
- D3中的each() 以及svg defs元素 clipPath的使用
each() 方法允许我们定制对选择集中DOM元素的处理行为: selection . each ( func ) 参数 func 是调用者定义的函数,在d3中被称为 访问器/accessor . d ...
随机推荐
- saltstack安装使用
官网地址:https://docs.saltstack.com/en/latest/ 安装 saltstack 1. sudo yum install https://repo.saltstack ...
- HTML常用全部代码--第一部分--HTML/CSS( 小伙伴要牢记😁😁😁😁 )
<一>html代码大全:结构性定义 (1) 文件类型<HTML></HTML> (放在档案的开头与结尾) (2) 文件主题<TITLE></TIT ...
- 决策树算法原理--good blog
转载于:http://www.cnblogs.com/pinard/p/6050306.html (楼主总结的很好,就拿来主义了,不顾以后还是多像楼主学习) 决策树算法在机器学习中算是很经典的一个算法 ...
- DB开发规范---初稿
1 公共约定 1.1 存储引擎 默认统一使用InnoDB引擎 1.2 字符集设定 后续新建DB默认使用utf8mb4字符集,校对规则使用utf8mb4_general_bin. 历史DB多使用utf8 ...
- Codeforces J. Monotonic Renumeration(组合)
题目描述: You are given an array consisting of nmonotonic renumeration as an array b consisting of \(n\) ...
- 利用avicap32.dll实现的实时视频传输
直接上代码吧! 在窗体上调用的类: using System; using System.Collections.Generic; using System.ComponentModel; using ...
- windows 10 下使用Navicat for oracle 数据库还原
一.前期准备 1.安装windows 10系统 2.安装oracle 11g 数据库 3.安装PLsql(也不需要) 4.安装sqlplus(这个必须有) 5.使用下面这个东西新建数据库(不懂创建的话 ...
- python 中的tile函数,shape函数,sum函数
1.tile函数: tile函数是模板numpy.lib.shape_base中的函数.函数的形式是tile(A,reps) A的类型几乎所有类型都可以:array, list, tuple, dic ...
- tensorflow API _ 3 (tf.train.polynomial_decay)
学习率的三种调整方式:固定的,指数的,多项式的 def _configure_learning_rate(num_samples_per_epoch, global_step): "&quo ...
- *arg和**kwarg作用
*args:可以理解为只有一列的表格,长度不固定. **kwargs:可以理解为字典,长度也不固定. 1.函数调用里的*arg和**kwarg: (1) *arg:元组或列表 ...