Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
拉菲尔-让svg在飞一会
Search
w3cplus
November 25, 2012
Technology
650
5
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
拉菲尔-让svg在飞一会
SVG相关介绍
w3cplus
November 25, 2012
More Decks by w3cplus
See All by w3cplus
手淘互动动效探索
w3cplus
0
260
CSS Future
w3cplus
2
660
Web Animation
w3cplus
5
520
CSS3带来的变化
w3cplus
0
1.5k
Web重构之道
w3cplus
1
3k
Sass带来的变革
w3cplus
2
680
Responsive小试牛刀
w3cplus
3
570
CSS预处器——Sass、LESS和Stylus实践
w3cplus
0
420
http协议与缓存简述
w3cplus
5
560
Other Decks in Technology
See All in Technology
生成AI時代、PMは事業責任者に進化するともっと面白い〜PMだからこそ事業構造を動かせる時代に〜
kakehashi
PRO
0
260
古い指輪から広がった JAVA コミュニティ とのつながり
yamad
0
140
企画を Software Factory-ready にする——開発が高速になったとき、PdMの仕事はどう変わったか
yachibit
1
130
S3 Filesで挑む! 八戸せんべい汁の食べ頃問題
usanchuu
0
140
Claude Code on Bedrock で統制をかける小ネタ集/claude-code-bedrock-governance-tips
emiki
1
160
CTO Night|NotionのAIエージェントとFDE
kzkhykw1991
0
300
Persisting Massive Data with Rails ~Designing for 60 billion rows, and fighting the bottlenecks~ Railsで挑む大量データ永続化 〜600億件を永続化するための設計とボトルネックとの戦い〜
occhi
0
780
ストレスなくAIと付き合いたい!こんなときどうしてる?
namiki64
4
670
React改造してみた
tsukina_7mochi
0
150
10年後、Engineering 行為を剥奪されるとして、わたしたちは、どう、何を創ればいいだろうか。 / If Engineering Is Taken Away in 10 Years, How and What Should We Create?
bitkey
PRO
1
220
「Learning Outcome」を書きたくない私が、Learning Outcomeと折り合いをつけるまで
mhlyc
0
110
LambdaWebFunctionsを試してみた / exploring-lambda-web-functions
koukihosaka
1
380
Featured
See All Featured
Music & Morning Musume
bryan
48
7.4k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.5k
Fashionably flexible responsive web design (full day workshop)
malarkey
409
67k
Tell your own story through comics
letsgokoyo
1
1.1k
Leo the Paperboy
mayatellez
10
2.4k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Scaling GitHub
holman
464
140k
Done Done
chrislema
187
17k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
790
Paper Plane
katiecoart
PRO
5
54k
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
2
2.2k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
950
Transcript
拉菲尔-让svg在飞一会 99 前端工程师 新浪微博@宇宙一片小囧
Svg是一个 标准! Svg是什么? 可缩放矢量图形(Scalable Vector Graphics,SVG)是基于可扩展标记语言 (XML),用于描述二维矢量图形的一种图 形格式。SVG由W3C制定,是一个开放标 准。 http://graphic.duapp.com/
怎样抖的? 抖的什么? Svg?Png?gif?bit64?
图像层面! Svg优点? 非常容易修改 SVG 是可伸缩的,尺寸更小 SVG 图像中的文本是可选的,同时也是可 搜索的(很适合制作地图)
可操纵性! Svg优点? 非常容易修改 http://jsbin.com/epiwul/7 SVG节点,事件绑定与动画,都不是问 题。。。 JavaScript和CSS自由操纵svg
基于未来的 图形图像算 法! Svg有什么用? 几乎所有高兼容性的图表库的底层库均为拉 斐尔。(数据可视化http://datavlab.org/) http://coding.smashingmagazine.com/2012 /01/16/resolution-independence-with-svg/ 面向未来的图形解决方案 响应式设计的最
佳伴侣 http://www.evernote.com/shard/s156/sh/31 d8e8a5-d90f-41e7-8b83- 96c0e32b1733/1ac9acb4f44140296276e9 6362e4117a
扯淡吧! 为什么不用Svg? 大家可能都不知道。。都去玩canvas了。。 http://raphaeljs.com 兼容性:不是问题。 基于dom的元素操作非常繁琐:不是问题
想学么! Raphaeljs 跨越时代的js库 无数的demo http://raphaeljs.com 开源,完全免费,学习成本不算特别高。。。 Icon http://raphaeljs.com/icons/
想学么! Raphaeljs 跨越时代的js库 <script src="http://cdnjs.cloudflare.com/ajax/libs/r aphael/2.0.0/raphael-min.js"> var paper = Raphael(50,
50, 500, 500); for (var i = 0; i <5; i++) { paper.circle(10 + 15 * i, 10, 10)//创建 circle(x,y,r)的圆 .attr({fill: "#000"})//设置属性 .data("i", i)//设置自定义属性 .click(function () {//绑定事件 console.log(this.attr('cx'),this.data('i')); }); http://jsbin.com/omajal/2
想学么! Raphaeljs 跨越时代的js库 attr方法 http://raphaeljs.com/reference.html#Eleme nt.attr Fill Stroke R Opacity
transform Cx Cy stroke-width Animate方法 Image方法 核心的path方法
想学么! Raphaeljs 跨越时代的js库 http://jsbin.com/omajal/10/edit // 创建画布 500 × 500 at
50, 50 var paper = Raphael(50, 50, 500, 500); paper.circle(200, 200, 10)//创建 circle(x,y,r)的圆 .attr({fill: "red",stroke:'blue','stroke- width':10,opacity:0.2,})//设置属性 继续 attr({cx:120,cy:400,r:50} http://jsbin.com/omajal/13/edit
想学么! Raphaeljs 跨越时代的js库 http://jsbin.com/omajal/10/edit // 创建画布 500 × 500 at
50, 50 var paper = Raphael(50, 50, 500, 500); paper.circle(200, 200, 10)//创建 circle(x,y,r)的圆 .attr({fill: "red",stroke:'blue','stroke- width':10,opacity:0.2,})//设置属性 继续 attr({cx:120,cy:400,r:50} http://jsbin.com/omajal/13/edit
想学么! Raphaeljs 跨越时代的js库 // 创建画布 500 × 500 at 50,
50 var paper = Raphael(50, 50, 500, 500); //Paper.rect(x, y, width, height, [r]) paper.rect(0, 0, 1000, 400, 10).attr({ stroke : "none", fill : "0-#fff-#f00:20- #000" }); http://jsbin.com/omajal/15/edit 0指的是0度,也指的是从左到右渐变(90 从下到上 180从右到左,270从上到下) 每个-指的一个颜色节点。后面加冒号指的 是百分比 上面的意思是 从左到右,#fff渐变到 #f00 渐变到20%,之后#f00渐变到#000, 从20%渐变到100%
想学么! Raphaeljs 跨越时代的js库 r.circle(100, 100, 200).attr({ stroke : "none", fill
: "r(0.5, 0.5)black:20- red:70" }); http://jsbin.com/omajal/16/edit 径向渐变只支持圆与椭圆!
想学么! Raphaeljs 跨越时代的js库 r.circle(100, 100, 200).attr({ stroke : "none", fill
: "r(0.5, 0.5)black:20- red:70" }); http://jsbin.com/omajal/16/edit 径向渐变只支持圆与椭圆!
想学么! Raphaeljs 跨越时代的js库 attr的transform属性,非常强大。。 transform: “t100,100″ 表示移动相对距离 x100,y100 transform: “r30,100,100″表示以100,100
为中心旋转30度 transform: “s2,1,300,300″ 表示以300, 300为起始点,放大2倍 缩放一次 注意个参 数的对应。 若r s未指定参数,默认为中心点 http://jsbin.com/omajal/17/edit http://raphaeljs.com/reference.html#Eleme nt.transform
想学么! Raphaeljs 跨越时代的js库 attr的transform属性,非常强大。。 transform: “t100,100″ 表示移动相对距离 x100,y100 transform: “r30,100,100″表示以100,100
为中心旋转30度 transform: “s2,1,300,300″ 表示以300, 300为起始点,放大2倍 缩放一次 注意个参 数的对应。 若r s未指定参数,默认为中心点 http://jsbin.com/omajal/17/edit http://raphaeljs.com/reference.html#Eleme nt.transform
想学么! Raphaeljs 跨越时代的js库 animate var paper = Raphael(50, 50, 500,
500); paper.circle(320, 240, 60).animate({ fill : "#223fa3", stroke : "#000", "stroke-width" : 80, "stroke-opacity" : 0.5, 'cx':200, 'r':100 }, 2000); http://jsbin.com/omajal/18/edit http://raphaeljs.com/reference.html#Eleme nt.animate
想学么! Raphaeljs 跨越时代的js库 高级animate http://jsbin.com/omajal/19/edit 支持回调函数,支持缓动 批量操作的技巧:set() 可以用push 添加进去。 http://raphaeljs.com/reference.html#Eleme
nt.animate
想学么! Raphaeljs 跨越时代的js库 高级animate http://jsbin.com/omajal/19/edit http://raphaeljs.com/reference.html#Eleme nt.animate
想学么! Raphaeljs 跨越时代的js库 核心方法 path() * M = moveto *
L = lineto * H = horizontal lineto * V = vertical lineto * C = curveto * S = smooth curveto * Q = quadratic Belzier curve * T = smooth quadratic Belzier curveto * A = elliptical Arc * Z = closepath
想学么! Raphaeljs 跨越时代的js库 核心方法 path() * M = moveto *
L = lineto * H = horizontal lineto * V = vertical lineto * C = curveto * S = smooth curveto * Q = quadratic Belzier curve * T = smooth quadratic Belzier curveto * A = elliptical Arc * Z = closepath (closePath)
想学么! Raphaeljs 跨越时代的js库 核心方法 path() 画直线 http://jsbin.com/omajal/20/edit var paper =
Raphael(50, 50, 500, 500); paper.circle(10, 200, 2).attr({fill: "#000"}) paper.path("M10 200L100 200") paper.circle(100, 200, 2).attr({fill: "#000"}) http://jsbin.com/omajal/21/edit paper.path("M10 200L100 200L200 300L300 380 400 420") 折线图所有的ok!
想学么! Raphaeljs 跨越时代的js库 核心方法 path() 如何封装一个自己的图表库? Option Data Position http://jsbin.com/omajal/22/edit
想学么! Raphaeljs 跨越时代的js库 核心方法 path() 画曲线 http://jsbin.com/omajal/24/edit
想学么! Raphaeljs 跨越时代的js库 核心方法 path() 画曲线 http://jsbin.com/omajal/27/edit http://jsbin.com/omajal/32/edit
想学么! Raphaeljs 跨越时代的js库 核心方法 path() 画贝塞尔曲线 http://jsbin.com/omajal/29 贝塞尔曲线 http://cubic-bezier.com/#.17,.67,.83,.67 ["C",
ax, ay, bx, by, zx, zy] http://jsbin.com/omajal/34/edit
想学么! Raphaeljs 跨越时代的js库 学习资料: 贝塞尔曲线 http://cubic-bezier.com/#.17,.67,.83,.67 http://raphaeljs.com/ http://blog.csdn.net/hfahe/article/details/76 61494
谢谢! W3CPLUS 99 javascript make the world beautiful @宇宙一片小囧 Q&A