下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
第使用FabricJS向Polygon对象添加收缩和展开动画scaleX:此属性接受Number值。分配的值决定水平对象比例因子。它的默认值为1。
scaleY:此属性接受Number值。分配的值决定垂直对象比例因子。它的默认值为1。
示例1:为多边形添加收缩动画
让我们看一个代码示例,看看如何使用animate方法添加收缩动画。我们向scaleX和scaleY属性传递一个值0.5,这使得多边形从水平和垂直方向都是原始大小的一半。
!DOCTYPEhtml
html
head
!--AddingtheFabricJSLibrary--
scriptsrc=/ajax/libs/fabric.js/510/fabric.min.js/script
/head
body
h2Addingshrinkanimationtothepolygon/h2
pYoucanseethatshrinkanimationhasbeenaddedtothepolygon/p
canvasid=canvas/canvas
script
//Initiateacanvasinstance
varcanvas=newfabric.Canvas(canvas
canvas.setWidth(document.body.scrollWidth);
canvas.setHeight(250);
//Initiateapolygonobject
varpolygon=newfabric.Polygon(
{x:60,y:0},
{x:60,y:60},
{x:0,y:60},
{x:0,y:0},
fill:#ffe4e1,
stroke:green,
strokeWidth:5,
top:90,
left:100,
//Addingittothecanvas
canvas.add(polygon);
//UsingtheanimatemethodandpassingscaleXproperty
polygon.animate(scaleX,0.5,{
onChange:canvas.renderAll.bind(canvas),
easing:fabric.util.ease.easeInCubic,
duration:1000,
//UsingtheanimatemethodandpassingscaleYproperty
polygon.animate(scaleY,0.5,{
onChange:canvas.renderAll.bind(canvas),
easing:fabric.util.ease.easeInCubic,
duration:1000,
/script
/body
/html
示例2:向多边形添加展开动画
在此示例中,我们将了解如何使用animate方法添加expand动画。由于我们向scaleX和scaleY属性传递的值为1.5,因此多边形对象将在水平和垂直方向上缩放1.5倍。
!DOCTYPEhtml
html
head
!--AddingtheFabricJSLibrary--
scriptsrc=/ajax/libs/fabric.js/510/fabric.min.js/script
/head
body
h2Addingexpandanimationtothepolygon/h2
pYoucanseethatexpandanimationhasbeenaddedtothepolygon/p
canvasid=canvas/canvas
script
//Initiateacanvasinstance
varcanvas=newfabric.Canvas(canvas
canvas.setWidth(document.body.scrollWidth);
canvas.setHeight(250);
//Initiateapolygonobject
varpolygon=newfabric.Polygon(
{x:60,y:0},
{x:60,y:60},
{x:0,y:60},
{x:0,y:0},
fill:#ffe4e1,
stroke:green,
strokeWidth:5,
top:90,
left:100,
//Addingittothecanvas
canvas.add(polygon);
//UsingtheanimatemethodandpassingscaleXproperty
polygon.animate(scaleX,1.5,{
onChange:canvas.renderAll.bind(canvas),
easing:fabric.util.ease.easeInCubic,
duration:1000,
//UsingtheanimatemethodandpassingscaleYproperty
polygon.animate(scaleY,1.5,{
onChange:canvas.renderAll.bind(canvas),
easing:fab
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025 小学一年级科学下册认识常见植物花朵课件
- 2026年玄武岩矿化封存项目可行性研究报告
- 2025年江苏省徐州市中考生物真题卷含答案解析
- 2025年中级(四级)化学检验员(石油化工科研实验)理论知识试题及答案
- 2025年建筑施工技术练习题库+答案(附解析)
- 2025年焊工(三级)焊接工艺评估考试试卷(附答案)
- 人力资源部年度工作总结和计划
- 2025年鼻炎考试试题及答案
- 消防保卫措施
- 2025年化工行业应知应会试题及答案
- 2025年1月-12月时事政治归纳总结(备考必背)
- 2025年安徽省普通高中学业水平合格性考试英语试卷(含答案)
- (高清版)DG∕TJ 08-2068-2019 超高压喷射注浆技术标准
- GB/T 15107-2005旅游鞋
- GB/T 1184-1996形状和位置公差未注公差值
- 单晶结构分析原理与实践
- 蒸汽管道安装监理实施细则
- 2022年武汉首义科技创新投资发展集团有限公司招聘笔试试题及答案解析
- 旅游地接合作协议(模板)
- 众智SUN日照分析软件操作手册
- 《普及版部署及培训》PPT课件
评论
0/150
提交评论