代码语言
.
CSharp
.
JS
Java
Asp.Net
C
MSSQL
PHP
Css
PLSQL
Python
Shell
EBS
ASP
Perl
ObjC
VB.Net
VBS
MYSQL
GO
Delphi
AS
DB2
Domino
Rails
ActionScript
Scala
代码分类
文件
系统
字符串
数据库
网络相关
图形/GUI
多媒体
算法
游戏
Jquery
Extjs
Android
HTML5
菜单
网页交互
WinForm
控件
企业应用
安全与加密
脚本/批处理
开放平台
其它
【
Css
】
HTML5 Canvas 超炫效果
作者:
kingcarl
/ 发布于
2012/7/16
/
730
<div><!DOCTYPE html> <html> <head> <meta charset=utf-8 /> <title>Star</title> </head> <body style="margin:0px;padding:0px;width:100%;height:100%;overflow:hidden;"> <canvas id="c"></canvas> </body> </html></div> <div></div> <div></div> <div>window.onload = function () { C = Math.cos; // cache Math objects S = Math.sin; U = 0; w = window; j = document; d = j.getElementById("c"); c = d.getContext("2d"); W = d.width = w.innerWidth; H = d.height = w.innerHeight; c.fillRect(0, 0, W, H); // resize <canvas> and draw black rect (default) c.globalCompositeOperation = "lighter"; // switch to additive color application c.lineWidth = 0.2; c.lineCap = "round"; var bool = 0, t = 0; // theta d.onmousemove = function (e) { if(window.T) { if(D==9) { D=Math.random()*15; f(1); } clearTimeout(T); } X = e.pageX; // grab mouse pixel coords Y = e.pageY; a=0; // previous coord.x b=0; // previous coord.y A = X, // original coord.x B = Y; // original coord.y R=(e.pageX/W * 999>>0)/999; r=(e.pageY/H * 999>>0)/999; U=e.pageX/H * 360 >>0; D=9; g = 360 * Math.PI / 180; T = setInterval(f = function (e) { // start looping spectrum c.save(); c.globalCompositeOperation = "source-over"; // switch to additive color application if(e!=1) { c.fillStyle = "rgba(0,0,0,0.02)"; c.fillRect(0, 0, W, H); // resize <canvas> and draw black rect (default) } c.restore(); i = 25; while(i --) { c.beginPath(); if(D > 450 || bool) { // decrease diameter if(!bool) { // has hit maximum bool = 1; } if(D < 0.1) { // has hit minimum bool = 0; } t -= g; // decrease theta D -= 0.1; // decrease size } if(!bool) { t += g; // increase theta D += 0.1; // increase size } q = (R / r - 1) * t; // create hypotrochoid from current mouse position, and setup variables (see: http://en.wikipedia.org/wiki/Hypotrochoid) x = (R - r) * C(t) + D * C(q) + (A + (X - A) * (i / 25)) + (r - R); // center on xy coords y = (R - r) * S(t) - D * S(q) + (B + (Y - B) * (i / 25)); if (a) { // draw once two points are set c.moveTo(a, b); c.lineTo(x, y) } c.strokeStyle = "hsla(" + (U % 360) + ",100%,50%,0.75)"; // draw rainbow hypotrochoid c.stroke(); a = x; // set previous coord.x b = y; // set previous coord.y } U -= 0.5; // increment hue A = X; // set original coord.x B = Y; // set original coord.y }, 16); } j.onkeydown = function(e) { a=b=0; R += 0.05 } d.onmousemove({pageX:300, pageY:290}) }
试试其它关键字
Canvas
同语言下
.
前端PC-移动端CSS公共样式+HTML
.
手机端页面通用样式
.
H5页面通用头部设置
.
elect默认样式美化代码兼容移动端和pc端
.
按钮效果 css
.
唤醒app
.
放大效果
.
html5+css3实现上拉和下拉刷新
.
html上传图片后,在页面显示上传的图片
.
html5实现点击弹出图片
可能有用的
.
C#实现的html内容截取
.
List 切割成几份 工具类
.
SQL查询 多列合并成一行用逗号隔开
.
一行一行读取txt的内容
.
C#动态修改文件夹名称(FSO实现,不移动文件)
.
c# 移动文件或文件夹
.
c#图片添加水印
.
Java PDF转换成图片并输出给前台展示
.
网站后台修改图片尺寸代码
.
处理大图片在缩略图时的展示
kingcarl
贡献的其它代码
(
2
)
.
HTML5 Canvas 超炫效果
.
绑定修改网卡绑定关系脚本
Copyright © 2004 - 2024 dezai.cn. All Rights Reserved
站长博客
粤ICP备13059550号-3