canvas玩转微信红包
CSS3相关属性:










<!DOCTYPE html>
<html>
<head lang='en'>
<meta charset='UTF-8'/>
<meta name='viewport' content='height=device-height,
width=device-width,
initial-scale= 1.0,
minimum-scale= 1.0,
maximum-scale= 1.0,
user-scale= no' />
<title>canvas玩转微信红包</title>
<script src='jquery-1.10.2.min.js' type='text/javascript'></script>
<style>
*{
padding:0px;
margin:0px;
}
#blur-div{
width: 620px;
height: 350px;
position: relative;
margin: 0 auto;
}
#blur-image{
width: 620px;
height: 350px;
display: block;
margin: 0 auto; filter: blur(5px); /*grayscale(灰度)/sepia(黄棕色)/saturate(饱和度)/hue-rotate(色相)/invert(反色)/opacity(不透明度)/brightness(明度)/contrast/(对比度)blur(模糊)/drop-shadow(阴影)*/
-webkit-filter: blur(5px);
-moz-filter: blur(5px);
-ms-filter: blur(5px);
-o-filter: blur(5px); position: absolute;
left: 0px;
top: 0px; z-index: 0;
} #canvas{
display: block;
margin: 0 auto; position: absolute;
left:0px;
top: 0px; z-index: 100;
//background-color: red;
}
.button{
display: block;
position: absolute;
z-index: 200; width: 100px;
height: 30px; color: white;
text-decoration: none;
text-align: center;
line-height: 30px; border-radius: 5px;
}
#reset-button{
left: 200px;
bottom: 20px;
background-color: #085;
}
#show-button{
left: 400px;
bottom: 20px;
background-color: #074;
}
</style>
</head>
<body>
<div id='blur-div'>
<img id='blur-image' src='image.jpg'/>
<canvas id='canvas'></canvas>
<a href='javascript:reset()' class='button' id='reset-button'>RESET</a>
<a href='javascript:show()' class='button' id='show-button'>SHOW</a>
</div> <script type='text/javascript'>
var canvasWidth = 620; //window.innerWidth
var canvasHeight = 350; //window.innerHeight
var canvas = document.getElementById('canvas');
var context = canvas.getContext('2d'); canvas.width = canvasWidth;
canvas.height = canvasHeight; var image = new Image();
var clippingRegion = {x: -1, y: -1, r: 30};
image.src = 'image.jpg';
image.onload = function(e){
initCanvas();
}
function initCanvas(){
clippingRegion = {x: Math.random()*600, y: Math.random()*300, r: 30};
draw(image, clippingRegion);
}
function setClippingRegion(clippingRegion){
context.beginPath();
context.arc(clippingRegion.x, clippingRegion.y, clippingRegion.r, 0, Math.PI*2, false); //绘制圆
context.clip(); //剪辑区域函数
}
function draw(image, clippingRegion){
context.clearRect(0,0,canvas.width,canvas.height);
context.save();
setClippingRegion(clippingRegion);
context.drawImage(image,0,0);
context.restore();
}
function reset(){
initCanvas();
}
function show(){
var tip = setInterval(function(){
clippingRegion.r += 20;
if(clippingRegion.r> Math.max(canvas.width,canvas.height)){
clearInterval(tip);
}
draw(image, clippingRegion);console.log('hahah');
},30);
}
</script>
</body>
</html>

(最后效果如上:)
canvas玩转微信红包的更多相关文章
- 基于微信红包插件的原理实现android任何APP自动发送评论(已开源)
背景 地址:https://github.com/huijimuhe/postman 核心就是android的AccessibilityService,回复功能api需要23以上版本才行. 其实很像在 ...
- 微信红包中使用的技术:AA收款+随机算法
除夕夜你领到红包了吗?有的说“我领了好几K!”“我领了几W!” 土豪何其多,苦逼也不少!有的说“我出来工作了,没压岁钱了,还要发红包”.那您有去抢微信红包吗?微信群中抢“新年红包”春节爆红.618微信 ...
- (实用篇)php官方微信接口大全(微信支付、微信红包、微信摇一摇、微信小店)
微信入口绑定,微信事件处理,微信API全部操作包含在这些文件中.内容有:微信摇一摇接口/微信多客服接口/微信支付接口/微信红包接口/微信卡券接口/微信小店接口/JSAPI <?php class ...
- 对接微信红包时:CA证书出错,请登录微信支付商户平台下载证书
今天在对接微信支付的微信红包发放时,出现““CA证书出错,请登录微信支付商户平台下载证书”的错误,特此记录一下: 如果你也在对接微信红包,并且你也在这个页面上下载了demo,再就是你也参照了里面的文档 ...
- 用Canvas玩3D:点-线-面
声明:本文为原创文章,如需转载,请注明来源WAxes,谢谢! 玩Canvas玩了有两三个礼拜了,平面的东西玩来玩去也就那样,所以就开始折腾3D了. 因为Canvas画布终究还是平面的,所以要有3D就得 ...
- 用Python玩转微信(一)
欢迎大家访问我的个人网站<刘江的博客和教程>:www.liujiangblog.com 主要分享Python 及Django教程以及相关的博客 交流QQ群:453131687 今天偶然看见 ...
- 微信红包店小程序开发过程中遇到的问题 php获取附近周边商家 显示最近商家
最近公司在做一个项目就是微信红包店.仿照的是微信官方在做的那个红包店的模式.客户抢红包,抢到以后到店消费,消费以后就可以拿到商家的红包了. 项目中的两个难点: 1通过小程序来发红包 这个之前在开发语 ...
- PHP实现微信随机红包算法和微信红包的架构设计简介
微信红包的架构设计简介: 原文:https://www.zybuluo.com/yulin718/note/93148 @来源于QCon某高可用架构群整理,整理朱玉华. 背景:有某个朋友在朋友圈咨询微 ...
- 微信支付现金红包接口应用实例代码说明和DEMO详解,适合用来做微信红包营销活动、吸粉利器
本文详细介绍微信红包开发的接口,商户调用接口时,通过指定发送对象以及发送金额的方式发放红包,领取到红包后,用户的资金直接进入微信零钱.后面带有具体调用php实例 总结一下:需要注意的是PEM秘 ...
随机推荐
- shell-002:统计IP访问量
统计IP访问量 #!/bin/bash # 统计IP的访问量 # 第一步首先得获取到日志的IP # 第二步给IP排序,这样相同的的IP就会在一起 sort # 第三步则给重复的IP统计数量,去重 un ...
- springcloud整合bus
bus的使用主要是配合springcloud config部分来一起使用,并没有单独使用 首先建立服务端: <dependency> <groupId>org.springfr ...
- prcharm 注册码
JetBrains全系列在线激活中心 使用方法: 1. 点击Help,选择Register.打开注册页面. 2. 选择License server, 在License server address 中 ...
- pika教程
http://www.01happy.com/python-pika-rabbitmq-summary/
- node.js express 启用 https
服务端和客户端各有一对公钥和私钥,使用公钥加密的数据只能用私钥解密,建立https传输之前,客户端和服务端互换公钥.客户端发送数据前使用服务端公钥加密,服务端接收到数据后使用私钥解密,反之亦如此. 公 ...
- BZOJ - 2115 独立回路 线性基
题意:给定一个图集\((V,E)\),求路径\(1...n\)的最大异或和,其中重复经过的部分也会重复异或 所求既任意一条\(1...n\)的路径的异或和,再异或上任意独立回路的组合的异或和(仔细想想 ...
- Codeforces - 617E 年轻人的第一道莫队·改
题意:给出\(n,m,k,a[1...n]\),对于每次询问,求\([l,r]\)中\(a[i] \ xor \ a[i+1] \ xor \ ...a[j],l<=i<=j<=r\ ...
- 剑指offer——面试题14:剪绳子
// 面试题14:剪绳子 // 题目:给你一根长度为n绳子,请把绳子剪成m段(m.n都是整数,n>1并且m≥1). // 每段的绳子的长度记为k[0].k[1].…….k[m].k[0]*k[1 ...
- linux 安装maven,注意下载-bin.tar.gz文件
先去http://maven.apache.org/download.cgi下载对应的版本然后放到服务器上/var/local文件夹下面, 此处使用的是apache-maven-3.5.2-bin.t ...
- oracle 基础知识(二)-表空间
一,表空间 01,表空间? Oracle数据库是通过表空间来存储物理表的,一个数据库实例可以有N个表空间,一个表空间下可以有N张表.有了数据库,就可以创建表空间.表空间(tablespace)是数据库 ...