html扑克牌展开,HTML5 canvas扑克牌花式洗牌动画
【实例简介】HTML5 canvas扑克牌花式洗牌动画基于jquery.1.10.2.min.js制作,扑克牌发牌,洗牌动画。
【实例截图】
【核心代码】
CARD.prototype = {
WIDTH_RATIO : 1 / 12,
HEIGHT_RATIO : 1 / 8,
SCALE_RATIO : 4 / 5,
init : function(){
var index = this.column * this.renderer.ROW this.row;
this.width = Math.min(this.renderer.width, this.renderer.height) * this.WIDTH_RATIO;
this.height = Math.min(this.renderer.width, this.renderer.height) * this.HEIGHT_RATIO;
this.axis = [
{x : this.renderer.width / 2, y : this.renderer.height / 2},
{x : this.renderer.width / 4 this.renderer.width / 2 * (this.row % 2), y : this.renderer.height / 4 this.renderer.height / 2 * Math.floor(this.row / 2)},
{x : this.width * 2, y : this.renderer.height / 8 this.height / 2 this.renderer.height / 4 * this.row},
{x : this.width / 2 (this.renderer.width - this.width * 3 / 2) * this.column / this.renderer.COLUMN, y : this.renderer.height / 8 this.height / 2 this.renderer.height / 4 * this.row},
{x : this.width / 2 (this.renderer.width - this.width * 2) * index / this.renderer.ROW / this.renderer.COLUMN, y : this.renderer.height / 2 this.height / 2},
{x : this.width / 2 (this.renderer.width - this.width * 2) * index / this.renderer.ROW / this.renderer.COLUMN, y : this.height * 3 / 2 (this.renderer.height - this.height * 2) * (1 - Math.abs(1 - index / this.renderer.ROW / this.renderer.COLUMN * 2))},
{x : this.renderer.width / 6 this.renderer.width / 3 * (this.column % 3), y : this.renderer.height / 10 this.height / 2 this.renderer.height / 4 * Math.floor(this.column / 3)},
{x : this.renderer.width / 2, y : this.renderer.height / 2}
];
this.radian = [index / this.renderer.ROW / this.renderer.COLUMN, this.column / this.renderer.COLUMN, this.row / (this.renderer.ROW - 1)];
this.scale = this.SCALE_RATIO * this.row / (this.renderer.ROW - 1);
this.hue = this.radian[0] * 360 | 0;
},
controlStatus : function(context, status, rate){
if(status == 0){
this.x = this.axis[status].x;
this.y = this.axis[status].y;
}else{
var next = (status == this.renderer.MAX_STATUS) ? 0 : status;
this.x = this.axis[status - 1].x (this.axis[next].x - this.axis[status - 1].x) * rate;
this.y = this.axis[status - 1].y (this.axis[next].y - this.axis[status - 1].y) * rate;
}
switch(status){
case 0:
context.rotate(this.radian[0] * Math.PI * 2 * rate);
context.translate(0, -this.height);
break;
case 1:
context.rotate(this.translateAngle(this.radian[0] * Math.PI * 2, this.radian[1] * Math.PI * 2, rate));
context.translate(0, -this.height * (1 - rate));
break;
case 2:
context.rotate(this.translateAngle(this.radian[1] * Math.PI * 2, Math.PI * 2, rate));
break;
case 6:
context.rotate((this.radian[2] * Math.PI / 2 - Math.PI / 4) * rate);
context.translate(-this.width / 2 * rate, 0);
break;
case 7:
context.rotate(this.translateAngle(this.radian[2] * Math.PI / 2 - Math.PI / 4, this.radian[1] * Math.PI * 2, rate));
context.scale(1 - this.scale * rate, 1 - this.scale * rate);
context.translate(-this.width / 2, -this.height * 3 * rate);
break;
case 8:
context.rotate(this.translateAngle(this.radian[1] * Math.PI * 2, this.radian[0] * Math.PI * 2, rate));
context.scale(1 - this.scale * (1 - rate), 1 - this.scale * (1 - rate));
context.translate(-this.width / 2 * (1 - rate), this.height * (2 * rate - 3));
}
},
translateAngle : function(source, destination, rate){
return source (destination - source) * rate;
},
render : function(context, status, rate){
context.save();
context.translate(this.x, this.y);
this.controlStatus(context, status, rate);
context.lineWidth = this.width / 20;
context.strokeStyle = 'hsl(' this.hue ', 60%, 90%)';
context.fillStyle = 'hsl(' this.hue ', 60%, 60%)';
context.fillRect(0, -this.height, this.width, this.height);
context.strokeRect(0, -this.height, this.width, this.height);
context.restore();
}
};
html扑克牌展开,HTML5 canvas扑克牌花式洗牌动画相关推荐
- html5 canvas雨点打到窗玻璃动画
html5 canvas雨点打到窗玻璃动画 HTML5下雨效果 效果预览:http://hovertree.com/texiao/html5/4.htm 以下是代码: 1 <!doctype h ...
- 粒子背景php,html5+canvas圆形粒子移动背景动画特效
html5+canvas圆形粒子移动背景动画特效 this.update = function () { var lastPoint = { x: _this.x, y: _this.y }; // ...
- html飞机动画,html5 canvas纸飞机跟随鼠标飞行动画
这是一款效果很酷的html5 canvas纸飞机跟随鼠标飞行动画.插件中使用了paper.js来构建场景中的各种元素. HTML html结构只需要一个canvas,并给它一个id triangle- ...
- HTML5+Canvas漂亮的3D烟花动画生日特效,节日特效,烟花
fireworks HTML5+Canvas漂亮的3D烟花动画生日特效,节日特效,烟花 https://github.com/louislivi/fireworks
- html圆点跟链接线,html5 canvas简洁的圆点线动画特效
特效描述:html5 canvas简洁的 圆点线动画特效.html5 canvas绘制简洁动画特效,圆点和线条连接的背景动画特效. 代码结构 1. HTML代码 在美国的研究 我们一起可以在学术界产生 ...
- android气球上升的属性动画,html5 canvas告白气球上升背景动画特效
特效描述:html5 canvas 告白气球上升 背景动画特效.html5基于canvas绘制各种卡通气球上升动画.告白气球背景动画特效. 代码结构 1. 引入JS 2. HTML代码 Balloon ...
- 扑克牌排序_JAVA 扑克牌排序打印,并进行洗牌
点击上方蓝字关注我们 一.Puke类: 首先定义扑克牌的参数 定义字符串型的花色(color),点数(points)两个有关于扑克牌的参数,且用private关键字进行修饰,被private修饰的后的 ...
- HTML5 Canvas 超逼真烟花绽放动画
各位前端朋友们,大家好!五一假期即将结束,在开启加班模式之前,我要给大家分享一个超酷超逼真的HTML5 Canvas烟花模拟动画.这次升级版的烟花动画有以下几个特点: 烟花绽放时,将展现不同的色彩,不 ...
- 7 款基于 HTML5 Canvas 的超炫 3D 动画效果
在以前,想要在浏览器中实现3D动画效果是非常困难的,但是自从HTML5诞生之后,这就变得十分简单了.遗憾的是,目前的浏览器对3D渲染效果还不是非常理想,尤其是渲染速度,可能用chrome和safari ...
- html5 canvas爆炸,html5 canvas彩色爆炸的小球动画特效
特效描述:html5 canvas 彩色爆炸 小球动画特效.html5 canvas特效,有中心向四周爆炸的彩色小球,有开始和暂停按钮 代码结构 1. HTML代码 开始运动 停止运动 var can ...
最新文章
- 怎么查询redis缓存的数据_阿里开发十年写出这份「Redis简明教程」+「Redis实战」请你查收...
- proe5.0安装教程
- android学习日记16--GridView(网格视图)
- 【Redis学习】Redis开启多个端口
- Spring Boot 2.0 迁移指南
- shellwhile比较_[Shell] if、for、while流程语句以及整数字符串判断比较的实例详解...
- Google 推荐和鼓励的 13 条代码审查标准,建议收藏!
- POI Excel 13 添加图片
- 缩放浏览器不会换行_深入解析 EventLoop 和浏览器渲染、帧动画、空闲回调的关系...
- 苹果Magic Trackpad2成功被谷歌团队写进去个Linux
- 强制卸载pip以及安装老版本pip
- 手机传感器你知道多少个?
- 《东周列国志》第四十七回 弄玉吹箫双跨凤 赵盾背秦立灵公
- matlab怎么表示二元函数,如何用Matlab画二元函数?
- 摸鱼神器 Thief-Book
- 周六研易01:深入研究甲木选用法
- “当高启强遇到陈书婷”与TCP协议
- HTMLCSS常见面试题
- SA-NET: Shuffle attention for DCNN 论文学习
- Arcgis软件应用(六)利用缓冲区分析和叠置分析进行购房选址
热门文章
- 如何将自己写的项目发布到外网上
- 塔尔寺景点门票销售管理系统
- linux系统有线网卡,Thinkpad E430+CentOS 6.4+ linux-3.10.12内核网卡驱动(无线+有线)配置...
- 文档服务器 件排名,服务器十大品牌排名
- 微信H5支付浏览器支付
- 杨辉三角简单规律 2021-7-30
- qt 设置焦点 跳到下个控件_Qt控件焦点切换
- python图片处理大全_python图像处理:怎么给图片加框?
- 酒店抖音小程序开发方案
- Elasticsearch 地理位置查询