HTML5 Canvas 画心 CSS 六边形
更新时间:2023-11-05 07:44:01 阅读量: 综合文库 文档下载
- html5推荐度:
- 相关推荐
HTML5 Canvas 画心CSS 六边形
文件是模块化的,修改下可以直接使用(模块化的并不是很好)
HTML5 Canvas画心,可以用来表白哦,加个jquery的缓入,加个计时时间。 以下是源码:(主要方法借鉴自网上代码)(jquery自行引入,不贴出) clover.js(文件)
/*ctx:画布上下文环境 **x,y:四叶草的中心点坐标 **length:数量级
**piece:每个数据级的大小,单位px */
function clover(ctx,x,y,length,piece){
try{
(!length || length%4!==0) && (length=4); !piece && (piece=5); ctx.save(); function point(x,y) { }
var a=new point(0,0);
var b=new point(length*piece,0);
var c=new point(length/2*piece,length/2*piece); var d=new point(length/4*piece*3,length/4*piece); var e=new point(length/2*piece,0); ctx.translate(x,y); ctx.fillStyle='green'; //ctx.beginPath();
this.x=x; this.y=y;
//ctx.moveTo(a.x,a.y); //ctx.lineTo(b.x,b.y); //ctx.lineTo(c.x,c.y); //ctx.closePath(); //ctx.stroke(); ctx.beginPath(); ctx.moveTo(a.x,a.y);
ctx.quadraticCurveTo(c.x,c.y,d.x,d.y); ctx.quadraticCurveTo(b.x,b.y,e.x,e.y); ctx.fill(); //ctx.stroke(); //ctx.beginPath(); //ctx.moveTo(a.x,-a.y); //ctx.lineTo(b.x,-b.y); //ctx.lineTo(c.x,-c.y); //ctx.closePath(); //ctx.stroke(); ctx.beginPath(); ctx.moveTo(a.x,-a.y);
ctx.quadraticCurveTo(c.x,-c.y,d.x,-d.y); ctx.quadraticCurveTo(b.x,-b.y,e.x,-e.y); ctx.fill(); //ctx.beginPath(); //ctx.moveTo(-a.x,-a.y); //ctx.lineTo(-b.x,-b.y); //ctx.lineTo(-c.x,-c.y); //ctx.closePath(); //ctx.stroke(); ctx.beginPath();
ctx.moveTo(-a.x,-a.y);
ctx.quadraticCurveTo(-c.x,-c.y,-d.x,-d.y); ctx.quadraticCurveTo(-b.x,-b.y,-e.x,-e.y); ctx.fill(); //ctx.beginPath(); //ctx.moveTo(-a.x,a.y); //ctx.lineTo(-b.x,b.y); //ctx.lineTo(-c.x,c.y); //ctx.closePath(); //ctx.stroke(); ctx.beginPath(); ctx.moveTo(-a.x,a.y);
ctx.quadraticCurveTo(-c.x,c.y,-d.x,d.y); ctx.quadraticCurveTo(-b.x,b.y,-e.x,e.y); ctx.fill();
ctx.rotate(Math.PI/2);
//ctx.beginPath(); //ctx.moveTo(a.x,a.y); //ctx.lineTo(b.x,b.y); //ctx.lineTo(c.x,c.y); //ctx.closePath(); //ctx.stroke(); ctx.beginPath(); ctx.moveTo(a.x,a.y);
ctx.quadraticCurveTo(c.x,c.y,d.x,d.y); ctx.quadraticCurveTo(b.x,b.y,e.x,e.y); ctx.fill();
//ctx.beginPath(); //ctx.moveTo(a.x,-a.y); //ctx.lineTo(b.x,-b.y); //ctx.lineTo(c.x,-c.y); //ctx.closePath(); //ctx.stroke(); ctx.beginPath(); ctx.moveTo(a.x,-a.y);
ctx.quadraticCurveTo(c.x,-c.y,d.x,-d.y); ctx.quadraticCurveTo(b.x,-b.y,e.x,-e.y); ctx.fill(); //ctx.beginPath(); //ctx.moveTo(-a.x,-a.y); //ctx.lineTo(-b.x,-b.y); //ctx.lineTo(-c.x,-c.y); //ctx.closePath(); //ctx.stroke(); ctx.beginPath(); ctx.moveTo(-a.x,-a.y);
ctx.quadraticCurveTo(-c.x,-c.y,-d.x,-d.y); ctx.quadraticCurveTo(-b.x,-b.y,-e.x,-e.y); ctx.fill(); //ctx.beginPath(); //ctx.moveTo(-a.x,a.y); //ctx.lineTo(-b.x,b.y); //ctx.lineTo(-c.x,c.y); //ctx.closePath(); //ctx.stroke(); ctx.beginPath();
}
}
ctx.moveTo(-a.x,a.y);
ctx.quadraticCurveTo(-c.x,c.y,-d.x,d.y); ctx.quadraticCurveTo(-b.x,b.y,-e.x,e.y); ctx.fill(); ctx.restore();
catch(e) { }
console.log('%c 四叶草画图失败!','color:red');
//var ctx=cav.getContext('2d');
//clover(ctx,cav.width/2,cav.height/2,8,10); dynamicCSS.css(文件) body{
font-family:'simsun','Verdana';
-webkit-user-select:none;-ms-user-select:none;-moz-user-select:none;-o-user-select:none;user-select:none; }
.formContent{ }
.formContent input,.formContent textarea{ }
margin-right:10px; padding:5px; margin-top:25px;
.formContent label{ }
#leftContain{ }
#leftContain span{ }
.container:after{ } .cus-set{ }
position: relative; height:8px; width:100%; margin-bottom:5px; margin-top:10px; content:\display:block; clear:both;
margin-bottom:20px; display:inline-block; width:700px; overflow:hidden; word-wrap:break-word; white-space:pre; min-height:250px; vertical-align:top; font-style:italic; font-weight:800;
.cus-set:before{ }
.cus-set:after{ }
.display-none{ }
.topIcon:after{
border-width:0 8px 8px !important; top:-6px !important; display:none; position:absolute; top:0; left:50%;
border-style: solid; border-width:8px 8px 0; border-color: black transparent; display:inline; content:\width:50%; height:2px;
background: -webkit-linear-gradient(left,red, purple); /* Safari 5.1 - 6.0 */ background: -o-linear-gradient(right,red, purple); /* Opera 11.1 - 12.0 */ background: -moz-linear-gradient(right,red, purple); /* Firefox 3.6 - 15 */ background-color:linear-gradient(to right,red, purple);; position:absolute; top:0; left:0; display:block; content:\
} button{ }
button:focus,button:hover{ } .mask{ } .fix-div{ }
position:fixed; bottom:0; right:20px; font-size:16px; z-index:20; position:absolute; top:0; left:0; width:100%; height:100%; opacity:0; z-index:10;
background-color:#F9A7B0; outline:none; margin-left:20px; border:2px solid green; border-radius: 25px; background-color:pink; height:3em;
DynamicDisplay.html(文件)
<动态显示文字
想要呈现的段落\ bottom;\清除
value=\字的透明度:1为不透明。\添加样式:
调节字显示的速度
显示速度为: 500
>动态展示文字
文字隐没参数
心形参数
花朵参数
>花瓣每次生长长度范围
颜色及透明度
~
>b~
value=\生长间隔时间(ms)
正方形参数
var length=ctx.measureText(text).width; var x=(cav.width-length)/2; var y=cav.height/2;
var gradient=ctx.createLinearGradient(x,y,x+length,y); gradient.addColorStop(\gradient.addColorStop(\gradient.addColorStop(\ctx.fillStyle=gradient; ctx.fillText(text,x,y);
var time=isNaN(+disappearTime.value)||!disappearTime.value?5000:(+disappearTime.value); var per=isNaN(+disappearPer.value)||!disappearPer.value?100:(+disappearPer.value); var opacity=1;
heart.init((isNaN(+heartNum.value)||!heartNum.value?500:(+heartNum.value)),(isNaN(+heartLength.value)?20:(+heartLength.value)),true);
var
cloverLength=isNaN(+cloverPieLevel.value)||!cloverPieLevel.value?100:(+cloverPieLevel.value);
var cloverPiece=isNaN(+cloverPie.value)||!cloverPie.value?5:(+cloverPie.value); var heartArray=heart.getPositiveHeartByRange(cloverLength*cloverPiece*3/2); function change(){
opacity-=1/time*per; if(opacity<=0) {
opacity=0;
ctx.clearRect(0,0,cav.width,cav.height); clearInterval(t); ctx.restore(); ctx.save();
ctx.translate(cloverLength*cloverPiece,0); ctx.beginPath();
}
}
}
for(var i=0;i //ctx.stroke(); ctx.restore(); return; // if(!i) // { // ctx.moveTo(heartArray[i].x,heartArray[i].y); // }else{ // } clover(ctx,heartArray[i].x,heartArray[i].y,cloverLength,cloverPiece); var overLoad=document.querySelector('.mask'); if(overLoad&&!overLoad.classList.contains('display-none')) { } overLoad.classList.add('display-none'); // ctx.lineTo(heartArray[i].x,heartArray[i].y); ctx.globalAlpha=opacity; ctx.clearRect(0,0,cav.width,cav.height); ctx.fillText(text,x,y); var t=setInterval(change,per); //ctx.restore(); //heartWithClover(); function customerSet(){ var all=document.querySelectorAll('.cus-set'); } for(var i=0;i function onclick(element){ }; var temp=element.nextSibling; while(temp&&temp.nodeName===\{ } if(temp&&temp.classList.contains('cus-set-detail')) { } element.onclick=function(){ }; if(temp.classList.contains('display-none')) { }else{ } temp.classList.add('display-none'); element.classList.remove('topIcon'); element.setAttribute('title',\展开设置页\temp.classList.remove('display-none'); element.classList.add('topIcon'); element.setAttribute('title',\收起设置页\ temp=temp.nextSibling; onclick(all[i]); customerSet(); function heartWithFlower(){ ctx.clearRect(0,0,cav.width,cav.height); ctx.save(); ctx.font=\宋体','sans-serif'\var text=\您将使用花朵画心形\var length=ctx.measureText(text).width; var x=(cav.width-length)/2; var y=cav.height/2; var gradient=ctx.createLinearGradient(x,y,x+length,y); gradient.addColorStop(\gradient.addColorStop(\gradient.addColorStop(\ctx.fillStyle=gradient; ctx.fillText(text,x,y); var time=isNaN(+disappearTime.value)||!disappearTime.value?5000:(+disappearTime.value); var per=isNaN(+disappearPer.value)||!disappearPer.value?150:(+disappearPer.value); var opacity=1; heart.init((isNaN(+heartNum.value)||!heartNum.value?100:(+heartNum.value)),(isNaN(+heartLength.value)?20:(+heartLength.value)),true); var distance=13; var heartArray=heart.getPositiveHeartByRange(distance); function change(){ opacity-=1/time*per; if(opacity<=0) { opacity=0; ctx.clearRect(0,0,cav.width,cav.height); clearInterval(t); ctx.restore(); ctx.save(); } } } ctx.translate(50,0); flower.reStart(true,ctx,heartArray,packageFlowerMap()?map:{flag:false}); return; ctx.globalAlpha=opacity; ctx.clearRect(0,0,cav.width,cav.height); ctx.fillText(text,x,y); var t=setInterval(change,per); //ctx.restore(); //heartWithFlower(); function squareWithFlower(){ ctx.clearRect(0,0,cav.width,cav.height); ctx.save(); ctx.font=\宋体','sans-serif'\var text=\您将使用花朵画正方形\var length=ctx.measureText(text).width; var x=(cav.width-length)/2; var y=cav.height/2; var gradient=ctx.createLinearGradient(x,y,x+length,y); gradient.addColorStop(\gradient.addColorStop(\gradient.addColorStop(\ctx.fillStyle=gradient; ctx.fillText(text,x,y); var time=isNaN(+disappearTime.value)||!disappearTime.value?5000:(+disappearTime.value); var per=isNaN(+disappearPer.value)||!disappearPer.value?100:(+disappearPer.value); var opacity=1;
- 高一物理牛顿运动定律全套学习学案
- 水处理一级反渗透加还原剂亚硫酸氢钠后为什么ORP会升高
- 毕业设计(论文)-正文董家口 - 图文
- 荣盛酒店经营管理公司录用通知及入职承诺书II
- 第二讲 大学英语四级快速阅读技巧
- 质量管理体系文件(2015年委托第三方医药物流配送企业专用版本)
- 214071收款办法
- 苏轼对《文选》选文的评价
- 《诊断学基础B》1-8作业
- 广东省东莞市高一数学下学期期末教学质量检查试题
- 海南电网公司VIS推广应用管理办法
- 红星照耀中国习题
- 苏教版小学语文六年级上册期末复习资料之生字词整理
- 局域网组建与应用—王向东
- 税务稽查内部管理文书样式
- 环保社会实践调查表
- 九年级思品第一单元复习
- 2016年全国注册咨询工程师继续教育公路路线设计规范试卷
- 毕业设计-青岛港董家口港区防波堤设计
- 撞背锻炼方法与益处
- 六边形
- Canvas
- HTML5
- CSS
- 整式知识点梳理、经典例题、课堂练习(带答案解析)解读
- 钢波纹管涵洞施工工法
- 1180采煤机控制系统说明书
- 部编人教版语文八年级上册第五单元《写作说明事物要抓住特征》word配套教案含教学反思教学设计说课稿
- 2018-2019学年高考生物大一轮复习热点题型训练学案最新版
- 个人对精益工作推进的思考
- 从“同命不同价”反思我国死亡赔偿制度
- 大学英语四翻译
- 山东省基本农田整理项目可行性研究报告 - 图文
- 幼儿园食品安全周的活动总结
- ICEM CFD动网格学习 - 图文
- 周口姓氏简介
- 变电二次设备清扫标准化作业书
- 现场检查笔录--放射卫生监督(日常监督内容0)
- 天轿年华项目计划控制书
- 汽车转向机构的设计毕业设计
- 2013年江西版二年级上册美术教案
- 中考化学专项练习有机合成材料(含解析)-化学知识点总结
- 管理科学与工程1201
- (9.10)《红星照耀中国》