├── _config.yml
├── canvas
├── css
│ ├── style.css
│ └── normalize.css
├── index.html
└── js
│ ├── lvrjwz.js
│ └── script.js
├── translate
├── img
│ ├── 1.jpg
│ ├── 2.jpg
│ └── 3.jpg
├── fonts
│ ├── icomoon.eot
│ ├── icomoon.ttf
│ ├── icomoon.woff
│ └── icomoon.svg
├── css
│ ├── normalize.css
│ └── htmleaf-demo.css
├── index2.html
└── index.html
├── h5game
├── fonts
│ ├── icomoon.eot
│ ├── icomoon.ttf
│ ├── icomoon.woff
│ └── icomoon.svg
├── css
│ ├── reset.css
│ ├── game.css
│ └── default.css
├── index.html
└── js
│ ├── stopExecutionOnTimeout.js
│ ├── modernizr.js
│ └── game.js
├── jQueryScroll
├── img
│ ├── bg1.jpg
│ ├── bg2.png
│ ├── bird1.png
│ ├── bird2.png
│ ├── bird3.png
│ ├── bird4.png
│ ├── bird5.png
│ ├── bird6.png
│ ├── bird7.png
│ ├── bird8.png
│ ├── bird9.png
│ ├── cage.png
│ └── man.png
├── fonts
│ ├── icomoon.eot
│ ├── icomoon.ttf
│ ├── icomoon.woff
│ └── icomoon.svg
├── css
│ ├── normalize.css
│ └── default.css
├── js
│ ├── stopExecutionOnTimeout.js
│ └── Sprite3D.js
└── index.html
├── jQuery手风琴
├── fonts
│ ├── icomoon.eot
│ ├── icomoon.ttf
│ ├── icomoon.woff
│ └── icomoon.svg
├── images
│ ├── bg-overlay.png
│ ├── img-slide-1.jpg
│ ├── img-slide-2.jpg
│ ├── img-slide-3.jpg
│ └── img-slide-4.jpg
├── css
│ ├── style.css
│ ├── htmleaf-demo.css
│ └── normalize.css
└── index.html
├── index.md
└── threejs
├── index.html
├── css
└── base.css
└── js
├── Distortions.js
└── InfiniteLights.js
/_config.yml:
--------------------------------------------------------------------------------
1 | theme: jekyll-theme-cayman
--------------------------------------------------------------------------------
/canvas/css/style.css:
--------------------------------------------------------------------------------
1 | html, body {
2 | background: black;
3 | }
4 |
--------------------------------------------------------------------------------
/translate/img/1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1363684100/animation/HEAD/translate/img/1.jpg
--------------------------------------------------------------------------------
/translate/img/2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1363684100/animation/HEAD/translate/img/2.jpg
--------------------------------------------------------------------------------
/translate/img/3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1363684100/animation/HEAD/translate/img/3.jpg
--------------------------------------------------------------------------------
/h5game/fonts/icomoon.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1363684100/animation/HEAD/h5game/fonts/icomoon.eot
--------------------------------------------------------------------------------
/h5game/fonts/icomoon.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1363684100/animation/HEAD/h5game/fonts/icomoon.ttf
--------------------------------------------------------------------------------
/h5game/fonts/icomoon.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1363684100/animation/HEAD/h5game/fonts/icomoon.woff
--------------------------------------------------------------------------------
/jQueryScroll/img/bg1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1363684100/animation/HEAD/jQueryScroll/img/bg1.jpg
--------------------------------------------------------------------------------
/jQueryScroll/img/bg2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1363684100/animation/HEAD/jQueryScroll/img/bg2.png
--------------------------------------------------------------------------------
/jQueryScroll/img/bird1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1363684100/animation/HEAD/jQueryScroll/img/bird1.png
--------------------------------------------------------------------------------
/jQueryScroll/img/bird2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1363684100/animation/HEAD/jQueryScroll/img/bird2.png
--------------------------------------------------------------------------------
/jQueryScroll/img/bird3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1363684100/animation/HEAD/jQueryScroll/img/bird3.png
--------------------------------------------------------------------------------
/jQueryScroll/img/bird4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1363684100/animation/HEAD/jQueryScroll/img/bird4.png
--------------------------------------------------------------------------------
/jQueryScroll/img/bird5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1363684100/animation/HEAD/jQueryScroll/img/bird5.png
--------------------------------------------------------------------------------
/jQueryScroll/img/bird6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1363684100/animation/HEAD/jQueryScroll/img/bird6.png
--------------------------------------------------------------------------------
/jQueryScroll/img/bird7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1363684100/animation/HEAD/jQueryScroll/img/bird7.png
--------------------------------------------------------------------------------
/jQueryScroll/img/bird8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1363684100/animation/HEAD/jQueryScroll/img/bird8.png
--------------------------------------------------------------------------------
/jQueryScroll/img/bird9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1363684100/animation/HEAD/jQueryScroll/img/bird9.png
--------------------------------------------------------------------------------
/jQueryScroll/img/cage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1363684100/animation/HEAD/jQueryScroll/img/cage.png
--------------------------------------------------------------------------------
/jQueryScroll/img/man.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1363684100/animation/HEAD/jQueryScroll/img/man.png
--------------------------------------------------------------------------------
/jQuery手风琴/fonts/icomoon.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1363684100/animation/HEAD/jQuery手风琴/fonts/icomoon.eot
--------------------------------------------------------------------------------
/jQuery手风琴/fonts/icomoon.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1363684100/animation/HEAD/jQuery手风琴/fonts/icomoon.ttf
--------------------------------------------------------------------------------
/jQuery手风琴/fonts/icomoon.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1363684100/animation/HEAD/jQuery手风琴/fonts/icomoon.woff
--------------------------------------------------------------------------------
/translate/fonts/icomoon.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1363684100/animation/HEAD/translate/fonts/icomoon.eot
--------------------------------------------------------------------------------
/translate/fonts/icomoon.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1363684100/animation/HEAD/translate/fonts/icomoon.ttf
--------------------------------------------------------------------------------
/translate/fonts/icomoon.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1363684100/animation/HEAD/translate/fonts/icomoon.woff
--------------------------------------------------------------------------------
/jQueryScroll/fonts/icomoon.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1363684100/animation/HEAD/jQueryScroll/fonts/icomoon.eot
--------------------------------------------------------------------------------
/jQueryScroll/fonts/icomoon.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1363684100/animation/HEAD/jQueryScroll/fonts/icomoon.ttf
--------------------------------------------------------------------------------
/jQueryScroll/fonts/icomoon.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1363684100/animation/HEAD/jQueryScroll/fonts/icomoon.woff
--------------------------------------------------------------------------------
/jQuery手风琴/images/bg-overlay.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1363684100/animation/HEAD/jQuery手风琴/images/bg-overlay.png
--------------------------------------------------------------------------------
/jQuery手风琴/images/img-slide-1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1363684100/animation/HEAD/jQuery手风琴/images/img-slide-1.jpg
--------------------------------------------------------------------------------
/jQuery手风琴/images/img-slide-2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1363684100/animation/HEAD/jQuery手风琴/images/img-slide-2.jpg
--------------------------------------------------------------------------------
/jQuery手风琴/images/img-slide-3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1363684100/animation/HEAD/jQuery手风琴/images/img-slide-3.jpg
--------------------------------------------------------------------------------
/jQuery手风琴/images/img-slide-4.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1363684100/animation/HEAD/jQuery手风琴/images/img-slide-4.jpg
--------------------------------------------------------------------------------
/canvas/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | canvas炫酷光粒子动画特效
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/h5game/css/reset.css:
--------------------------------------------------------------------------------
1 | html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:'';content:none}table{border-collapse:collapse;border-spacing:0}
--------------------------------------------------------------------------------
/h5game/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | HTML5响应式网页贪吃蛇小游戏
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
20 |
21 | 0
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/index.md:
--------------------------------------------------------------------------------
1 | ## Welcome to GitHub Pages
2 |
3 | You can use the [editor on GitHub](https://github.com/1363684100/animation/edit/master/index.md) to maintain and preview the content for your website in Markdown files.
4 |
5 | Whenever you commit to this repository, GitHub Pages will run [Jekyll](https://jekyllrb.com/) to rebuild the pages in your site, from the content in your Markdown files.
6 |
7 | ### Markdown
8 |
9 | Markdown is a lightweight and easy-to-use syntax for styling your writing. It includes conventions for
10 |
11 | ```markdown
12 | Syntax highlighted code block
13 |
14 | # Header 1
15 | ## Header 2
16 | ### Header 3
17 |
18 | - Bulleted
19 | - List
20 |
21 | 1. Numbered
22 | 2. List
23 |
24 | **Bold** and _Italic_ and `Code` text
25 |
26 | [Link](url) and 
27 | ```
28 |
29 | For more details see [GitHub Flavored Markdown](https://guides.github.com/features/mastering-markdown/).
30 |
31 | ### Jekyll Themes
32 |
33 | Your Pages site will use the layout and styles from the Jekyll theme you have selected in your [repository settings](https://github.com/1363684100/animation/settings). The name of this theme is saved in the Jekyll `_config.yml` configuration file.
34 |
35 | ### Support or Contact
36 |
37 | Having trouble with Pages? Check out our [documentation](https://help.github.com/categories/github-pages-basics/) or [contact support](https://github.com/contact) and we’ll help you sort it out.
38 |
--------------------------------------------------------------------------------
/jQuery手风琴/css/style.css:
--------------------------------------------------------------------------------
1 | /*
2 | Theme Name:
3 |
4 | Theme URI:
5 |
6 | Description:
7 |
8 | Version: 1.0
9 |
10 | Author: WebCastle
11 |
12 | Author URI: http://webcastletech.com/
13 |
14 | */
15 |
16 | a:focus{ outline:none;}
17 | input:focus{ outline:none;}
18 | textarea:focus{ outline:none;}
19 | ::-moz-selection
20 | {
21 | background:#9cd167;
22 | color:#fff
23 | }
24 | ::selection{
25 | background:#9cd167;
26 | color:#fff
27 | }
28 | .clear {
29 | clear: both;
30 | display: block;
31 | overflow: hidden;
32 | visibility: hidden;
33 | width: 0;
34 | height: 0;
35 | }
36 | ul , ol{
37 | margin:0px; padding:0px;
38 | }
39 |
40 | li{
41 | padding:0px;
42 | margin:0px;
43 | list-style:none;
44 | }
45 | a{
46 | text-decoration:none;
47 | }
48 | h1, h2, h3, h4, h5, h6 {
49 |
50 | font-weight: normal;
51 | padding:0px;
52 | margin:0px;
53 | }
54 | p{
55 | margin:0px;
56 | padding:0px;
57 | }
58 | body
59 | {
60 | font-family: Helvetica, Arial, sans-serif;
61 | font-size:12px;
62 | line-height:18px;
63 | }
64 | .banner-container
65 | {
66 | overflow:hidden;
67 | position:relative;
68 | /*width:1024px;
69 | margin:25px auto;*/
70 | }
71 | .banner-container ul
72 | {
73 | height: 639px;
74 | }
75 | .banner-container li
76 | {
77 | float:left;
78 | overflow:hidden;
79 | cursor:pointer;
80 | position:relative;
81 | z-index:9;
82 | }
83 | .banner-container li a
84 | {
85 | display:block;
86 | padding:0px;
87 | margin:0px;
88 | }
89 | .banner-container li span.overlay
90 | {
91 | background:url(../images/bg-overlay.png) repeat;
92 | width:100%;
93 | height:100%;
94 | position:absolute;
95 | top:0px;
96 | left:0px;
97 | }
98 |
99 |
100 |
--------------------------------------------------------------------------------
/translate/css/normalize.css:
--------------------------------------------------------------------------------
1 | article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block;}audio,canvas,video{display:inline-block;}audio:not([controls]){display:none;height:0;}[hidden]{display:none;}html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%;}body{margin:0;}a:focus{outline:thin dotted;}a:active,a:hover{outline:0;}h1{font-size:2em;margin:0.67em 0;}abbr[title]{border-bottom:1px dotted;}b,strong{font-weight:bold;}dfn{font-style:italic;}hr{-moz-box-sizing:content-box;box-sizing:content-box;height:0;}mark{background:#ff0;color:#000;}code,kbd,pre,samp{font-family:monospace,serif;font-size:1em;}pre{white-space:pre-wrap;}q{quotes:"\201C" "\201D" "\2018" "\2019";}small{font-size:80%;}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline;}sup{top:-0.5em;}sub{bottom:-0.25em;}img{border:0;}svg:not(:root){overflow:hidden;}figure{margin:0;}fieldset{border:1px solid #c0c0c0;margin:0 2px;padding:0.35em 0.625em 0.75em;}legend{border:0;padding:0;}button,input,select,textarea{font-family:inherit;font-size:100%;margin:0;}button,input{line-height:normal;}button,select{text-transform:none;}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer;}button[disabled],html input[disabled]{cursor:default;}input[type="checkbox"],input[type="radio"]{box-sizing:border-box;padding:0;}input[type="search"]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box;}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none;}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0;}textarea{overflow:auto;vertical-align:top;}table{border-collapse:collapse;border-spacing:0;}
--------------------------------------------------------------------------------
/jQueryScroll/css/normalize.css:
--------------------------------------------------------------------------------
1 | article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block;}audio,canvas,video{display:inline-block;}audio:not([controls]){display:none;height:0;}[hidden]{display:none;}html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%;}body{margin:0;}a:focus{outline:thin dotted;}a:active,a:hover{outline:0;}h1{font-size:2em;margin:0.67em 0;}abbr[title]{border-bottom:1px dotted;}b,strong{font-weight:bold;}dfn{font-style:italic;}hr{-moz-box-sizing:content-box;box-sizing:content-box;height:0;}mark{background:#ff0;color:#000;}code,kbd,pre,samp{font-family:monospace,serif;font-size:1em;}pre{white-space:pre-wrap;}q{quotes:"\201C" "\201D" "\2018" "\2019";}small{font-size:80%;}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline;}sup{top:-0.5em;}sub{bottom:-0.25em;}img{border:0;}svg:not(:root){overflow:hidden;}figure{margin:0;}fieldset{border:1px solid #c0c0c0;margin:0 2px;padding:0.35em 0.625em 0.75em;}legend{border:0;padding:0;}button,input,select,textarea{font-family:inherit;font-size:100%;margin:0;}button,input{line-height:normal;}button,select{text-transform:none;}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer;}button[disabled],html input[disabled]{cursor:default;}input[type="checkbox"],input[type="radio"]{box-sizing:border-box;padding:0;}input[type="search"]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box;}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none;}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0;}textarea{overflow:auto;vertical-align:top;}table{border-collapse:collapse;border-spacing:0;}
--------------------------------------------------------------------------------
/h5game/js/stopExecutionOnTimeout.js:
--------------------------------------------------------------------------------
1 | "use strict";"object"!=typeof window.CP&&(window.CP={}),window.CP.PenTimer={programNoLongerBeingMonitored:!1,timeOfFirstCallToShouldStopLoop:0,_loopExits:{},_loopTimers:{},START_MONITORING_AFTER:2e3,STOP_ALL_MONITORING_TIMEOUT:5e3,MAX_TIME_IN_LOOP_WO_EXIT:2200,exitedLoop:function(o){this._loopExits[o]=!0},shouldStopLoop:function(o){if(this.programKilledSoStopMonitoring)return!0;if(this.programNoLongerBeingMonitored)return!1;if(this._loopExits[o])return!1;var t=this._getTime();if(0===this.timeOfFirstCallToShouldStopLoop)return this.timeOfFirstCallToShouldStopLoop=t,!1;var i=t-this.timeOfFirstCallToShouldStopLoop;if(ithis.STOP_ALL_MONITORING_TIMEOUT)return this.programNoLongerBeingMonitored=!0,!1;try{this._checkOnInfiniteLoop(o,t)}catch(n){return this._sendErrorMessageToEditor(),this.programKilledSoStopMonitoring=!0,!0}return!1},_sendErrorMessageToEditor:function(){try{if(this._shouldPostMessage()){var o={action:"infinite-loop",line:this._findAroundLineNumber()};parent.postMessage(JSON.stringify(o),"*")}else this._throwAnErrorToStopPen()}catch(t){this._throwAnErrorToStopPen()}},_shouldPostMessage:function(){return document.location.href.match(/boomerang/)},_throwAnErrorToStopPen:function(){throw"We found an infinite loop in your Pen. We've stopped the Pen from running. Please correct it or contact support@codepen.io."},_findAroundLineNumber:function(){var o=new Error,t=0;if(o.stack){var i=o.stack.match(/boomerang\S+:(\d+):\d+/);i&&(t=i[1])}return t},_checkOnInfiniteLoop:function(o,t){if(!this._loopTimers[o])return this._loopTimers[o]=t,!1;var i=t-this._loopTimers[o];if(i>this.MAX_TIME_IN_LOOP_WO_EXIT)throw"Infinite Loop found on loop: "+o},_getTime:function(){return+new Date}},window.CP.shouldStopExecution=function(o){return window.CP.PenTimer.shouldStopLoop(o)},window.CP.exitedLoop=function(o){window.CP.PenTimer.exitedLoop(o)};
--------------------------------------------------------------------------------
/jQueryScroll/js/stopExecutionOnTimeout.js:
--------------------------------------------------------------------------------
1 | "use strict";"object"!=typeof window.CP&&(window.CP={}),window.CP.PenTimer={programNoLongerBeingMonitored:!1,timeOfFirstCallToShouldStopLoop:0,_loopExits:{},_loopTimers:{},START_MONITORING_AFTER:2e3,STOP_ALL_MONITORING_TIMEOUT:5e3,MAX_TIME_IN_LOOP_WO_EXIT:2200,exitedLoop:function(o){this._loopExits[o]=!0},shouldStopLoop:function(o){if(this.programKilledSoStopMonitoring)return!0;if(this.programNoLongerBeingMonitored)return!1;if(this._loopExits[o])return!1;var t=this._getTime();if(0===this.timeOfFirstCallToShouldStopLoop)return this.timeOfFirstCallToShouldStopLoop=t,!1;var i=t-this.timeOfFirstCallToShouldStopLoop;if(ithis.STOP_ALL_MONITORING_TIMEOUT)return this.programNoLongerBeingMonitored=!0,!1;try{this._checkOnInfiniteLoop(o,t)}catch(n){return this._sendErrorMessageToEditor(),this.programKilledSoStopMonitoring=!0,!0}return!1},_sendErrorMessageToEditor:function(){try{if(this._shouldPostMessage()){var o={action:"infinite-loop",line:this._findAroundLineNumber()};parent.postMessage(JSON.stringify(o),"*")}else this._throwAnErrorToStopPen()}catch(t){this._throwAnErrorToStopPen()}},_shouldPostMessage:function(){return document.location.href.match(/boomerang/)},_throwAnErrorToStopPen:function(){throw"We found an infinite loop in your Pen. We've stopped the Pen from running. Please correct it or contact support@codepen.io."},_findAroundLineNumber:function(){var o=new Error,t=0;if(o.stack){var i=o.stack.match(/boomerang\S+:(\d+):\d+/);i&&(t=i[1])}return t},_checkOnInfiniteLoop:function(o,t){if(!this._loopTimers[o])return this._loopTimers[o]=t,!1;var i=t-this._loopTimers[o];if(i>this.MAX_TIME_IN_LOOP_WO_EXIT)throw"Infinite Loop found on loop: "+o},_getTime:function(){return+new Date}},window.CP.shouldStopExecution=function(o){return window.CP.PenTimer.shouldStopLoop(o)},window.CP.exitedLoop=function(o){window.CP.PenTimer.exitedLoop(o)};
--------------------------------------------------------------------------------
/h5game/fonts/icomoon.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/jQueryScroll/fonts/icomoon.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/jQuery手风琴/fonts/icomoon.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/translate/fonts/icomoon.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/canvas/js/lvrjwz.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const {
4 | PI,
5 | cos,
6 | sin,
7 | tan,
8 | abs,
9 | sqrt,
10 | pow,
11 | min,
12 | max,
13 | ceil,
14 | floor,
15 | round,
16 | random,
17 | atan2
18 | } = Math;
19 | const HALF_PI = 0.5 * PI;
20 | const QUART_PI = 0.25 * PI;
21 | const TAU = 2 * PI;
22 | const TO_RAD = PI / 180;
23 | const G = 6.67 * pow(10, -11);
24 | const EPSILON = 2.220446049250313e-16;
25 | const rand = n => n * random();
26 | const randIn = (_min, _max) => rand(_max - _min) + _min;
27 | const randRange = n => n - rand(2 * n);
28 | const fadeIn = (t, m) => t / m;
29 | const fadeOut = (t, m) => (m - t) / m;
30 | const fadeInOut = (t, m) => {
31 | let hm = 0.5 * m;
32 | return abs((t + hm) % m - hm) / hm;
33 | };
34 | const dist = (x1, y1, x2, y2) => sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));
35 | const angle = (x1, y1, x2, y2) => atan2(y2 - y1, x2 - x1);
36 | const lerp = (a, b, amt) => (1 - amt) * a + amt * b;
37 | const vh = p => p * window.innerHeight * 0.01;
38 | const vw = p => p * window.innerWidth * 0.01;
39 | const vmin = p => min(vh(p), vw(p));
40 | const vmax = p => max(vh(p), vw(p));
41 | const clamp = (n, _min, _max) => min(max(n, _min), _max);
42 | const norm = (n, _min, _max) => (n - _min) / (_max - _min);
43 |
44 | Array.prototype.lerp = function(t = [], a = 0) {
45 | this.forEach((n, i) => (this[i] = lerp(n, t[i], a)));
46 | };
47 |
48 | Float32Array.prototype.get = function(i = 0, n = 0) {
49 | const t = i + n;
50 |
51 | let r = [];
52 |
53 | for (; i < t; i++) {
54 | r.push(this[i]);
55 | }
56 |
57 | return r;
58 | };
59 |
60 | class PropsArray {
61 | constructor(count = 0, props = []) {
62 | this.count = count;
63 | this.props = props;
64 | this.spread = props.length;
65 | this.values = new Float32Array(count * props.length);
66 | }
67 | get length() {
68 | return this.values.length;
69 | }
70 | set(a = [], i = 0) {
71 | this.values.set(a, i);
72 | }
73 | setMap(o = {}, i = 0) {
74 | this.set(Object.values(o), i);
75 | }
76 | get(i = 0) {
77 | return this.values.get(i, this.props.length);
78 | }
79 | getMap(i = 0) {
80 | return this.get(i).reduce(
81 | (r, v, i) => ({
82 | ...r,
83 | ...{ [this.props[i]]: v }
84 | }),
85 | {}
86 | );
87 | }
88 | forEach(cb) {
89 | let i = 0;
90 |
91 | for (; i < this.length; i += this.props.length) {
92 | cb(this.get(this, i), i, this);
93 | }
94 | }
95 | map(cb) {
96 | let i = 0;
97 |
98 | for (; i < this.length; i += this.props.length) {
99 | this.set(cb(this.get(this, i), i, this), i);
100 | }
101 | }
102 | async* read() {
103 | let i = 0;
104 |
105 | for (; i < this.length; i += this.props.length) {
106 | yield this.get(i);
107 | }
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/jQuery手风琴/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | jquery横向手风琴效果
8 |
9 |
10 |
11 |
12 |
13 |
14 |
17 |
18 |
19 | -
20 |
21 |
22 |
23 | -
24 |
25 |
26 |
27 | -
28 |
29 |
30 |
31 | -
32 |
33 |
34 |
35 | -
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
76 |
77 |
--------------------------------------------------------------------------------
/canvas/css/normalize.css:
--------------------------------------------------------------------------------
1 | article,
2 | aside,
3 | details,
4 | figcaption,
5 | figure,
6 | footer,
7 | header,
8 | hgroup,
9 | main,
10 | nav,
11 | section,
12 | summary {
13 | display: block;
14 | }
15 |
16 | audio,
17 | canvas,
18 | video {
19 | display: inline-block;
20 | }
21 |
22 | audio:not([controls]) {
23 | display: none;
24 | height: 0;
25 | }
26 |
27 | [hidden] {
28 | display: none;
29 | }
30 |
31 | html {
32 | font-family: sans-serif;
33 | -ms-text-size-adjust: 100%;
34 | -webkit-text-size-adjust: 100%;
35 | }
36 |
37 | body {
38 | margin: 0;
39 | }
40 |
41 | a:focus {
42 | outline: thin dotted;
43 | }
44 |
45 | a:active,
46 | a:hover {
47 | outline: 0;
48 | }
49 |
50 | h1 {
51 | font-size: 2em;
52 | margin: 0.67em 0;
53 | }
54 |
55 | abbr[title] {
56 | border-bottom: 1px dotted;
57 | }
58 |
59 | b,
60 | strong {
61 | font-weight: bold;
62 | }
63 |
64 | dfn {
65 | font-style: italic;
66 | }
67 |
68 | hr {
69 | -moz-box-sizing: content-box;
70 | box-sizing: content-box;
71 | height: 0;
72 | }
73 |
74 | mark {
75 | background: #ff0;
76 | color: #000;
77 | }
78 |
79 | code,
80 | kbd,
81 | pre,
82 | samp {
83 | font-family: monospace, serif;
84 | font-size: 1em;
85 | }
86 |
87 | pre {
88 | white-space: pre-wrap;
89 | }
90 |
91 | q {
92 | quotes: "\201C""\201D""\2018""\2019";
93 | }
94 |
95 | small {
96 | font-size: 80%;
97 | }
98 |
99 | sub,
100 | sup {
101 | font-size: 75%;
102 | line-height: 0;
103 | position: relative;
104 | vertical-align: baseline;
105 | }
106 |
107 | sup {
108 | top: -0.5em;
109 | }
110 |
111 | sub {
112 | bottom: -0.25em;
113 | }
114 |
115 | img {
116 | border: 0;
117 | }
118 |
119 | svg:not(:root) {
120 | overflow: hidden;
121 | }
122 |
123 | figure {
124 | margin: 0;
125 | }
126 |
127 | fieldset {
128 | border: 1px solid #c0c0c0;
129 | margin: 0 2px;
130 | padding: 0.35em 0.625em 0.75em;
131 | }
132 |
133 | legend {
134 | border: 0;
135 | padding: 0;
136 | }
137 |
138 | button,
139 | input,
140 | select,
141 | textarea {
142 | font-family: inherit;
143 | font-size: 100%;
144 | margin: 0;
145 | }
146 |
147 | button,
148 | input {
149 | line-height: normal;
150 | }
151 |
152 | button,
153 | select {
154 | text-transform: none;
155 | }
156 |
157 | button,
158 | html input[type="button"],
159 | input[type="reset"],
160 | input[type="submit"] {
161 | -webkit-appearance: button;
162 | cursor: pointer;
163 | }
164 |
165 | button[disabled],
166 | html input[disabled] {
167 | cursor: default;
168 | }
169 |
170 | input[type="checkbox"],
171 | input[type="radio"] {
172 | box-sizing: border-box;
173 | padding: 0;
174 | }
175 |
176 | input[type="search"] {
177 | -webkit-appearance: textfield;
178 | -moz-box-sizing: content-box;
179 | -webkit-box-sizing: content-box;
180 | box-sizing: content-box;
181 | }
182 |
183 | input[type="search"]::-webkit-search-cancel-button,
184 | input[type="search"]::-webkit-search-decoration {
185 | -webkit-appearance: none;
186 | }
187 |
188 | button::-moz-focus-inner,
189 | input::-moz-focus-inner {
190 | border: 0;
191 | padding: 0;
192 | }
193 |
194 | textarea {
195 | overflow: auto;
196 | vertical-align: top;
197 | }
198 |
199 | table {
200 | border-collapse: collapse;
201 | border-spacing: 0;
202 | }
--------------------------------------------------------------------------------
/h5game/css/game.css:
--------------------------------------------------------------------------------
1 | /*================================================
2 |
3 | General
4 |
5 | ================================================*/
6 |
7 | * {
8 | box-sizing: border-box;
9 | }
10 |
11 | html,
12 | body {
13 | background-color: #000;
14 | height: 100%;
15 | }
16 |
17 | body {
18 | background: #222;
19 | background: -webkit-radial-gradient(#333, #111);
20 | background: radial-gradient(#333, #111);
21 | background-position: center center;
22 | background-repeat: no-repeat;
23 | background-size: cover;
24 | color: #fff;
25 | font: 100%/1.5 sans-serif;
26 | overflow: hidden;
27 | }
28 |
29 | /*================================================
30 |
31 | Score
32 |
33 | ================================================*/
34 |
35 | .score {
36 | color: rgba(255, 255, 255, 0.5);
37 | font-size: 16px;
38 | font-weight: bold;
39 | padding-top: 5px;
40 | text-align: center;
41 | }
42 |
43 | /*================================================
44 |
45 | Stage
46 |
47 | ================================================*/
48 |
49 | .stage {
50 | bottom: 0;
51 | left: 0;
52 | margin: auto;
53 | position: absolute;
54 | right: 0;
55 | top: 0;
56 | z-index: 2;
57 | }
58 |
59 | /*================================================
60 |
61 | Tiles
62 |
63 | ================================================*/
64 |
65 | .tile {
66 | background: rgba(0, 0, 0, 0.15);
67 | position: absolute;
68 | -webkit-transition-property:
69 | background,
70 | box-shadow,
71 | opacity,
72 | -webkit-transform
73 | ;
74 | transition-property:
75 | background,
76 | box-shadow,
77 | opacity,
78 | transform
79 | ;
80 | -webkit-transform: translateZ(0);
81 | transform: translateZ(0);
82 | -webkit-transition-duration: 3000ms;
83 | transition-duration: 3000ms;
84 | }
85 |
86 | .tile:before {
87 | bottom: 0;
88 | content: '';
89 | height: 0;
90 | left: 0;
91 | margin: auto;
92 | opacity: 0;
93 | position: absolute;
94 | right: 0;
95 | top: 0;
96 | width: 0;
97 | -webkit-transition: opacity 300ms;
98 | transition: opacity 300ms;
99 | }
100 |
101 | .tile.path:before {
102 | opacity: 1;
103 | }
104 |
105 | .tile.up:before {
106 | border-bottom: 4px inset rgba(255, 255, 255, 0.15);
107 | border-left: 4px solid transparent;
108 | border-right: 4px solid transparent;
109 | }
110 |
111 | .tile.down:before {
112 | border-top: 4px inset rgba(255, 255, 255, 0.15);
113 | border-left: 4px solid transparent;
114 | border-right: 4px solid transparent;
115 | }
116 |
117 | .tile.left:before {
118 | border-right: 4px inset rgba(255, 255, 255, 0.15);
119 | border-top: 4px solid transparent;
120 | border-bottom: 4px solid transparent;
121 | }
122 |
123 | .tile.right:before {
124 | border-left: 4px inset rgba(255, 255, 255, 0.15);
125 | border-top: 4px solid transparent;
126 | border-bottom: 4px solid transparent;
127 | }
128 |
129 | @media (max-width: 900px), (max-height: 900px) {
130 | .tile.up:before,
131 | .tile.down:before,
132 | .tile.left:before,
133 | .tile.right:before {
134 | border-width: 3px;
135 | }
136 | }
137 |
138 | @media (max-width: 500px), (max-height: 500px) {
139 | .tile.up:before,
140 | .tile.down:before,
141 | .tile.left:before,
142 | .tile.right:before {
143 | border-width: 2px;
144 | }
145 | }
146 |
147 | .tile.pressed {
148 | background: rgba(0, 0, 0, 0.3);
149 | box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.6);
150 | -webkit-transition-duration: 0ms;
151 | transition-duration: 0ms;
152 | }
--------------------------------------------------------------------------------
/threejs/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | 基于Threejs的高速运动动画特效
8 |
9 |
14 |
15 |
16 |
17 |
18 |
提示: 点击鼠标来提高速度
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
105 |
106 |
--------------------------------------------------------------------------------
/jQueryScroll/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | 炫酷视差特效
8 |
9 |
10 |
37 |
38 |
39 |
40 |
41 |
42 |
124 |
125 |
--------------------------------------------------------------------------------
/canvas/js/script.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const particleCount = 1000;
4 | const particleProps = [
5 | "x",
6 | "y",
7 | "z",
8 | "vx",
9 | "vy",
10 | "vz",
11 | "life",
12 | "ttl",
13 | "speed"];
14 |
15 | const rangeY = 100;
16 | const rangeZ = 200;
17 | const baseTTL = 50;
18 | const rangeTTL = 200;
19 | const baseHue = rand(360);
20 | const rangeHue = 100;
21 | const xc = 0.0005;
22 | const yc = 0.0005;
23 | const zc = 0.0005;
24 | const tc = 0.0005;
25 | const noiseSteps = ceil(rand(4)) + 4;
26 | const backgroundColor = "hsla(0,0%,0%,0.5)";
27 |
28 | let canvas;
29 | let ctx;
30 | let center;
31 | let tick;
32 | let simplex;
33 | let particles;
34 |
35 | function setup() {
36 | createCanvas();
37 | resize();
38 | initParticles();
39 |
40 | draw();
41 | }
42 |
43 | function initParticles() {
44 | tick = 0;
45 | simplex = new SimplexNoise();
46 | particles = new PropsArray(particleCount, particleProps);
47 |
48 | let i = 0;
49 |
50 | for (; i < particles.length; i += particleProps.length) {
51 | initParticle(i);
52 | }
53 | }
54 |
55 | function initParticle(i) {
56 | let x, y, z, vx, vy, vz, life, ttl, speed, radius, hue;
57 |
58 | x = rand(canvas.a.width);
59 | y = center[1] + randIn(-rangeY, rangeY);
60 | z = rand(rangeZ);
61 | vx = 0;
62 | vy = 0;
63 | vz = 0;
64 | life = 0;
65 | ttl = baseTTL + rand(rangeTTL);
66 | speed = 0;
67 |
68 | particles.set([x, y, z, vx, vy, vz, life, ttl, speed], i);
69 | }
70 |
71 | function drawParticles() {
72 | let i = 0;
73 |
74 | for (; i < particles.length; i += particleProps.length) {
75 | updateParticle(i);
76 | }
77 | }
78 |
79 | function updateParticle(i) {
80 | let n, theta, phi, cosPhi, x2, y2, z2, width, hue;
81 |
82 | let [x, y, z, vx, vy, vz, life, ttl, speed] = particles.get(i);
83 |
84 | n = simplex.noise4D(x * xc, y * yc, z * zc, tick) * noiseSteps;
85 | theta = n * TAU;
86 | phi = (1 - n) * PI;
87 | cosPhi = cos(phi);
88 | vx = lerp(vx, cos(theta) * cosPhi, 0.0725);
89 | vy = lerp(vy, sin(phi), 0.0725);
90 | vz = lerp(vz, sin(theta) * cosPhi, 0.0725);
91 | x2 = x + vx * speed;
92 | y2 = y + vy * speed;
93 | z2 = z + vz * speed;
94 | width = 0.015 * z2 + 2;
95 | speed = lerp(speed, 0.05 * z2, 0.15);
96 | hue = baseHue + speed * 0.035 * rangeHue;
97 |
98 | drawParticle(x, y, z, x2, y2, life, ttl, width, hue);
99 |
100 | life++;
101 |
102 | particles.set([x2, y2, z2, vx, vy, vz, life, ttl, speed], i);
103 |
104 | (checkBounds(x, y, width) || life > ttl) && initParticle(i);
105 | }
106 |
107 | function drawParticle(x, y, z, x2, y2, life, ttl, width, hue) {
108 | ctx.a.save();
109 | ctx.a.lineWidth = width;
110 | ctx.a.strokeStyle = `hsla(${hue + clamp(z, 0, 180)},${clamp(z, 10, 60)}%,${clamp(z, 10, 50)}%,${fadeInOut(life, ttl) * (0.01 * clamp(z, 50, 100))})`;
111 | ctx.a.beginPath();
112 | ctx.a.moveTo(x, y);
113 | ctx.a.lineTo(x2, y2);
114 | ctx.a.stroke();
115 | ctx.a.closePath();
116 | ctx.a.restore();
117 | }
118 |
119 | function checkBounds(x, y, r) {
120 | return x > r + canvas.a.width || x < -r || y > r + canvas.a.height || y < -r;
121 | }
122 |
123 | function createCanvas() {
124 | canvas = {
125 | a: document.createElement("canvas"),
126 | b: document.createElement("canvas") };
127 |
128 |
129 | canvas.b.style = `
130 | position: fixed;
131 | top: 0;
132 | left: 0;
133 | width: 100%;
134 | height: 100%;
135 | `;
136 | document.body.appendChild(canvas.b);
137 | ctx = {
138 | a: canvas.a.getContext("2d"),
139 | b: canvas.b.getContext("2d") };
140 |
141 |
142 | center = [];
143 | }
144 |
145 | function resize() {
146 | const { innerWidth, innerHeight } = window;
147 |
148 | canvas.a.width = innerWidth;
149 | canvas.a.height = innerHeight;
150 |
151 | ctx.a.drawImage(canvas.b, 0, 0);
152 |
153 | canvas.b.width = innerWidth;
154 | canvas.b.height = innerHeight;
155 |
156 | ctx.b.drawImage(canvas.a, 0, 0);
157 |
158 | center[0] = 0.5 * canvas.a.width;
159 | center[1] = 0.5 * canvas.a.height;
160 | }
161 |
162 | function renderGlow() {
163 | ctx.b.save();
164 | ctx.b.filter = "blur(8px) brightness(200%)";
165 | ctx.b.globalCompositeOperation = "lighter";
166 | ctx.b.drawImage(canvas.a, 0, 0);
167 | ctx.b.restore();
168 |
169 | ctx.b.save();
170 | ctx.b.filter = "blur(4px) brightness(200%)";
171 | ctx.b.globalCompositeOperation = "lighter";
172 | ctx.b.drawImage(canvas.a, 0, 0);
173 | ctx.b.restore();
174 | }
175 |
176 | function renderToScreen() {
177 | ctx.b.save();
178 | ctx.b.globalCompositeOperation = "lighter";
179 | ctx.b.drawImage(canvas.a, 0, 0);
180 | ctx.b.restore();
181 | }
182 |
183 | function drawBackground() {
184 | ctx.a.clearRect(0, 0, canvas.a.width, canvas.a.height);
185 |
186 | ctx.b.fillStyle = backgroundColor;
187 | ctx.b.fillRect(0, 0, canvas.a.width, canvas.a.height);
188 | }
189 |
190 | function draw() {
191 | tick += tc;
192 |
193 | drawBackground();
194 | drawParticles();
195 | renderToScreen();
196 | renderGlow();
197 |
198 | window.requestAnimationFrame(draw);
199 | }
200 |
201 | window.addEventListener("load", setup);
202 | window.addEventListener("resize", resize);
--------------------------------------------------------------------------------
/threejs/css/base.css:
--------------------------------------------------------------------------------
1 | *,
2 | *::after,
3 | *::before {
4 | box-sizing: border-box;
5 | }
6 |
7 | :root {
8 | font-size: 18px;
9 | }
10 |
11 | body.cda-noimg #cdawrap {
12 | padding: 0;
13 | top: auto;
14 | left: 4.5rem;
15 | right: auto;
16 | bottom: 2.5rem;
17 | font-size: 1rem;
18 | font-family: inherit;
19 | --cda-width: 250px;
20 | --cda-text-color: var(--color-link);
21 | --cda-text-weight: 400;
22 | --cda-remove-color: inherit;
23 | --cda-sp-color: inherit;
24 | }
25 |
26 | body {
27 | margin: 0;
28 | --color-text: #fff;
29 | --color-bg: #000;
30 | --color-link: #5a5a5a;
31 | --color-link-hover: #3eaaf1;
32 | --color-alt: #3ba2e5;
33 | --color-info: #fff;
34 | color: var(--color-text);
35 | background-color: var(--color-bg);
36 | font-family: ltc-bodoni-175, serif;
37 | -webkit-font-smoothing: antialiased;
38 | -moz-osx-font-smoothing: grayscale;
39 | }
40 |
41 | .demo-2 {
42 | --color-link-hover: #53C2C6;
43 | --color-alt: #53C2C6;
44 | --color-info: #FF5F73;
45 | }
46 |
47 | .demo-3 {
48 | --color-link-hover: #DFD98A;
49 | --color-alt: #DFD98A;
50 | --color-info: #A90519;
51 | }
52 |
53 | .demo-4 {
54 | --color-info: #D856BF;
55 | }
56 |
57 | .demo-5 {
58 | --color-link-hover: #334BF7;
59 | --color-alt: #334BF7;
60 | --color-info: #DC5B20;
61 | }
62 |
63 | .demo-6 {
64 | --color-info: #FF322F;
65 | }
66 |
67 | .demo-7 {
68 | --color-link-hover: #7686BF;
69 | --color-alt: #7686BF;
70 | --color-info: #E2173C;
71 | }
72 |
73 | /* Page Loader */
74 | .js .loading::before,
75 | .js .loading::after {
76 | content: '';
77 | position: fixed;
78 | z-index: 1000;
79 | }
80 |
81 | .js .loading::before {
82 | top: 0;
83 | left: 0;
84 | width: 100%;
85 | height: 100%;
86 | background: var(--color-bg);
87 | }
88 |
89 | .js .loading::after {
90 | top: 50%;
91 | left: 50%;
92 | width: 60px;
93 | height: 60px;
94 | margin: -30px 0 0 -30px;
95 | opacity: 0.4;
96 | background: var(--color-link);
97 | animation: loaderAnim 0.7s linear infinite alternate forwards;
98 | }
99 |
100 | @keyframes loaderAnim {
101 | to {
102 | opacity: 1;
103 | transform: scale3d(0.5,0.5,1) rotate3d(0,0,1,180deg);
104 | border-radius: 50%;
105 | }
106 | }
107 |
108 | a {
109 | text-decoration: none;
110 | color: var(--color-link);
111 | outline: none;
112 | }
113 |
114 | a:hover,
115 | a:focus {
116 | color: var(--color-link-hover);
117 | outline: none;
118 | }
119 |
120 | .message {
121 | background: var(--color-text);
122 | color: var(--color-bg);
123 | padding: 1rem;
124 | text-align: center;
125 | }
126 |
127 | .frame {
128 | padding: 3rem 5vw;
129 | text-align: center;
130 | position: relative;
131 | z-index: 1000;
132 | }
133 |
134 | .frame__title {
135 | font-size: 1rem;
136 | margin: 0 0 1rem;
137 | font-weight: normal;
138 | }
139 |
140 | .frame__links {
141 | display: inline;
142 | }
143 |
144 | .frame__links a {
145 | display: block;
146 | margin: 0 1rem 0.5rem;
147 | }
148 |
149 | .frame__demos {
150 | margin: 1rem 0;
151 | }
152 |
153 | .frame__demo {
154 | display: block;
155 | padding-top: 0.5rem;
156 | }
157 |
158 | .frame__demo--current,
159 | .frame__demo--current:hover {
160 | color: var(--color-link-hover);
161 | }
162 |
163 | .frame__info {
164 | color: var(--color-info);
165 | }
166 |
167 | .content {
168 | display: flex;
169 | flex-direction: column;
170 | width: 100vw;
171 | height: calc(100vh - 13rem);
172 | position: relative;
173 | justify-content: flex-start;
174 | align-items: center;
175 | }
176 |
177 | .content__title-wrap {
178 | position: relative;
179 | text-align: center;
180 | pointer-events: none;
181 | -webkit-touch-callout: none;
182 | -webkit-user-select: none;
183 | -khtml-user-select: none;
184 | -moz-user-select: none;
185 | -ms-user-select: none;
186 | user-select: none;
187 | }
188 |
189 | .content__title-wrap a {
190 | pointer-events: auto;
191 | }
192 |
193 | .content__pretitle {
194 | color: var(--color-alt);
195 | font-size: 1.35rem;
196 | }
197 |
198 | .content__title {
199 | font-size: 6vw;
200 | font-weight: normal;
201 | margin: 0.5rem 0 1.5rem;
202 | font-family: azo-sans-uber, sans-serif;
203 | }
204 |
205 | .content__link {
206 | text-decoration: underline;
207 | font-family: azo-sans-uber, sans-serif;
208 | font-size: 1.1rem;
209 | color: inherit;
210 | }
211 |
212 | #app {
213 | width: 100%;
214 | height: 100vh;
215 | overflow: hidden;
216 | position: absolute;
217 | }
218 |
219 | canvas {
220 | width: 100%;
221 | height: 100%;
222 | }
223 |
224 | @media screen and (min-width: 53em) {
225 | .message {
226 | display: none;
227 | }
228 | .frame {
229 | position: fixed;
230 | text-align: left;
231 | z-index: 100;
232 | top: 0;
233 | left: 0;
234 | display: grid;
235 | align-content: space-between;
236 | width: 100%;
237 | max-width: none;
238 | height: 100vh;
239 | padding: 2.5rem 4.5rem;
240 | pointer-events: none;
241 | grid-template-columns: 75% 25%;
242 | grid-template-rows: auto auto auto;
243 | grid-template-areas: 'title info'
244 | '... ...'
245 | '... demos';
246 | }
247 | .frame__title-wrap {
248 | grid-area: title;
249 | display: flex;
250 | }
251 | .frame__title {
252 | margin: 0 8vw 0 0;
253 | }
254 | .frame__demos {
255 | margin: 0;
256 | grid-area: demos;
257 | justify-self: end;
258 | }
259 | .frame__links a {
260 | display: inline-block;
261 | }
262 | .frame__info {
263 | justify-self: end;
264 | }
265 | .frame a {
266 | pointer-events: auto;
267 | }
268 | .content {
269 | height: 100vh;
270 | justify-content: center;
271 | }
272 | }
273 |
--------------------------------------------------------------------------------
/translate/index2.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | 鼠标hover图片CSS3动画特效
9 |
10 |
11 |
12 |
126 |
127 |
128 |
129 |
136 |
137 |
138 |
139 |
140 |
141 |

142 |
143 |
CSS动画特效
144 | translate
145 |
146 |
150 |
151 |
152 |
153 |
154 |
155 |

156 |
157 |
CSS动画特效
158 | translate
159 |
160 |
164 |
165 |
166 |
167 |
168 |
169 |

170 |
171 |
CSS动画特效
172 | translate
173 |
174 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
--------------------------------------------------------------------------------
/translate/css/htmleaf-demo.css:
--------------------------------------------------------------------------------
1 | @font-face {
2 | font-family: 'icomoon';
3 | src:url('../fonts/icomoon.eot?rretjt');
4 | src:url('../fonts/icomoon.eot?#iefixrretjt') format('embedded-opentype'),
5 | url('../fonts/icomoon.woff?rretjt') format('woff'),
6 | url('../fonts/icomoon.ttf?rretjt') format('truetype'),
7 | url('../fonts/icomoon.svg?rretjt#icomoon') format('svg');
8 | font-weight: normal;
9 | font-style: normal;
10 | }
11 |
12 | [class^="icon-"], [class*=" icon-"] {
13 | font-family: 'icomoon';
14 | speak: none;
15 | font-style: normal;
16 | font-weight: normal;
17 | font-variant: normal;
18 | text-transform: none;
19 | line-height: 1;
20 |
21 | /* Better Font Rendering =========== */
22 | -webkit-font-smoothing: antialiased;
23 | -moz-osx-font-smoothing: grayscale;
24 | }
25 |
26 | body, html { font-size: 100%; padding: 0; margin: 0;}
27 |
28 | /* Reset */
29 | *,
30 | *:after,
31 | *:before {
32 | -webkit-box-sizing: border-box;
33 | -moz-box-sizing: border-box;
34 | box-sizing: border-box;
35 | }
36 |
37 | /* Clearfix hack by Nicolas Gallagher: http://nicolasgallagher.com/micro-clearfix-hack/ */
38 | .clearfix:before,
39 | .clearfix:after {
40 | content: " ";
41 | display: table;
42 | }
43 |
44 | .clearfix:after {
45 | clear: both;
46 | }
47 |
48 | body{
49 | background: #494A5F;
50 | color: #D5D6E2;
51 | font-weight: 500;
52 | font-size: 1.05em;
53 | font-family: "Microsoft YaHei","Segoe UI", "Lucida Grande", Helvetica, Arial,sans-serif;
54 | }
55 | a{ color: rgba(255, 255, 255, 0.6);outline: none;text-decoration: none;-webkit-transition: 0.2s;transition: 0.2s;}
56 | a:hover,a:focus{color:#74777b;text-decoration: none;}
57 | .htmleaf-container{
58 | margin: 0 auto;
59 | }
60 |
61 | .bgcolor-1 { background: #f0efee; }
62 | .bgcolor-2 { background: #f9f9f9; }
63 | .bgcolor-3 { background: #e8e8e8; }/*light grey*/
64 | .bgcolor-4 { background: #2f3238; color: #fff; }/*Dark grey*/
65 | .bgcolor-5 { background: #df6659; color: #521e18; }/*pink1*/
66 | .bgcolor-6 { background: #2fa8ec; }/*sky blue*/
67 | .bgcolor-7 { background: #d0d6d6; }/*White tea*/
68 | .bgcolor-8 { background: #3d4444; color: #fff; }/*Dark grey2*/
69 | .bgcolor-9 { background: #ef3f52; color: #fff;}/*pink2*/
70 | .bgcolor-10{ background: #64448f; color: #fff;}/*Violet*/
71 | .bgcolor-11{ background: #3755ad; color: #fff;}/*dark blue*/
72 | .bgcolor-12{ background: #3498DB; color: #fff;}/*light blue*/
73 | .bgcolor-20{ background: #494A5F;color: #D5D6E2;}
74 | /* Header */
75 | .htmleaf-header{
76 | padding: 1em 190px 1em;
77 | letter-spacing: -1px;
78 | text-align: center;
79 | background: #66677c;
80 | }
81 | .htmleaf-header h1 {
82 | color: #D5D6E2;
83 | font-weight: 600;
84 | font-size: 2em;
85 | line-height: 1;
86 | margin-bottom: 0;
87 | }
88 | .htmleaf-header h1 span {
89 | display: block;
90 | font-size: 60%;
91 | font-weight: 400;
92 | padding: 0.8em 0 0.5em 0;
93 | color: #c3c8cd;
94 | }
95 | /*nav*/
96 | .htmleaf-demo a{color: #fff;text-decoration: none;}
97 | .htmleaf-demo{width: 100%;padding-bottom: 1.2em;}
98 | .htmleaf-demo a{display: inline-block;margin: 0.5em;padding: 0.6em 1em;border: 3px solid #fff;font-weight: 700;}
99 | .htmleaf-demo a:hover{opacity: 0.6;}
100 | .htmleaf-demo a.current{background:#1d7db1;color: #fff; }
101 | /* Top Navigation Style */
102 | .htmleaf-links {
103 | position: relative;
104 | display: inline-block;
105 | white-space: nowrap;
106 | font-size: 1.5em;
107 | text-align: center;
108 | }
109 |
110 | .htmleaf-links::after {
111 | position: absolute;
112 | top: 0;
113 | left: 50%;
114 | margin-left: -1px;
115 | width: 2px;
116 | height: 100%;
117 | background: #dbdbdb;
118 | content: '';
119 | -webkit-transform: rotate3d(0,0,1,22.5deg);
120 | transform: rotate3d(0,0,1,22.5deg);
121 | }
122 |
123 | .htmleaf-icon {
124 | display: inline-block;
125 | margin: 0.5em;
126 | padding: 0em 0;
127 | width: 1.5em;
128 | text-decoration: none;
129 | }
130 |
131 | .htmleaf-icon span {
132 | display: none;
133 | }
134 |
135 | .htmleaf-icon:before {
136 | margin: 0 5px;
137 | text-transform: none;
138 | font-weight: normal;
139 | font-style: normal;
140 | font-variant: normal;
141 | font-family: 'icomoon';
142 | line-height: 1;
143 | speak: none;
144 | -webkit-font-smoothing: antialiased;
145 | }
146 | /* footer */
147 | .htmleaf-footer{width: 100%;padding-top: 10px;}
148 | .htmleaf-small{font-size: 0.8em;}
149 | .center{text-align: center;}
150 | /****/
151 | .related {
152 | color: #fff;
153 | background: #494A5F;
154 | text-align: center;
155 | font-size: 1.25em;
156 | padding: 0.5em 0;
157 | overflow: hidden;
158 | }
159 |
160 | .related > a {
161 | vertical-align: top;
162 | width: calc(100% - 20px);
163 | max-width: 340px;
164 | display: inline-block;
165 | text-align: center;
166 | margin: 20px 10px;
167 | padding: 25px;
168 | font-family: "Microsoft YaHei","宋体","Segoe UI", "Lucida Grande", Helvetica, Arial,sans-serif, FreeSans, Arimo;
169 | }
170 | .related a {
171 | display: inline-block;
172 | text-align: left;
173 | margin: 20px auto;
174 | padding: 10px 20px;
175 | opacity: 0.8;
176 | -webkit-transition: opacity 0.3s;
177 | transition: opacity 0.3s;
178 | -webkit-backface-visibility: hidden;
179 | }
180 |
181 | .related a:hover,
182 | .related a:active {
183 | opacity: 1;
184 | }
185 |
186 | .related a img {
187 | max-width: 100%;
188 | opacity: 0.8;
189 | border-radius: 4px;
190 | }
191 | .related a:hover img,
192 | .related a:active img {
193 | opacity: 1;
194 | }
195 | .related h3{font-family: "Microsoft YaHei", sans-serif;font-size: 1.2em}
196 | .related a h3 {
197 | font-size: 0.85em;
198 | font-weight: 300;
199 | margin-top: 0.15em;
200 | color: #fff;
201 | }
202 | /* icomoon */
203 | .icon-htmleaf-home-outline:before {
204 | content: "\e5000";
205 | }
206 |
207 | .icon-htmleaf-arrow-forward-outline:before {
208 | content: "\e5001";
209 | }
210 |
211 | @media screen and (max-width: 1024px) {
212 | .htmleaf-header {
213 | padding: 2em 10% 2em;
214 | }
215 | .htmleaf-header h1 {
216 | font-size:1.4em;
217 | }
218 | .htmleaf-links{font-size: 1.4em}
219 | }
220 |
221 | @media screen and (max-width: 960px) {
222 | .htmleaf-header {
223 | padding: 2em 10% 2em;
224 | }
225 | .htmleaf-header h1 {
226 | font-size:1.2em;
227 | }
228 | .htmleaf-links{font-size: 1.2em}
229 | .related h3{font-size: 1em;}
230 | .related a h3 {
231 | font-size: 0.8em;
232 | }
233 | }
234 |
235 | @media screen and (max-width: 766px) {
236 | .htmleaf-header h1 {
237 | font-size:1.3em;
238 | }
239 | .htmleaf-links{font-size: 1.3em}
240 | }
241 |
242 | @media screen and (max-width: 640px) {
243 | .htmleaf-header {
244 | padding: 2em 10% 2em;
245 | }
246 | .htmleaf-header h1 {
247 | font-size:1em;
248 | }
249 | .htmleaf-links{font-size: 1em}
250 | .related h3{font-size: 0.8em;}
251 | .related a h3 {
252 | font-size: 0.6em;
253 | }
254 | }
--------------------------------------------------------------------------------
/jQuery手风琴/css/htmleaf-demo.css:
--------------------------------------------------------------------------------
1 | @font-face {
2 | font-family: 'icomoon';
3 | src:url('../fonts/icomoon.eot?rretjt');
4 | src:url('../fonts/icomoon.eot?#iefixrretjt') format('embedded-opentype'),
5 | url('../fonts/icomoon.woff?rretjt') format('woff'),
6 | url('../fonts/icomoon.ttf?rretjt') format('truetype'),
7 | url('../fonts/icomoon.svg?rretjt#icomoon') format('svg');
8 | font-weight: normal;
9 | font-style: normal;
10 | }
11 |
12 | [class^="icon-"], [class*=" icon-"] {
13 | font-family: 'icomoon';
14 | speak: none;
15 | font-style: normal;
16 | font-weight: normal;
17 | font-variant: normal;
18 | text-transform: none;
19 | line-height: 1;
20 |
21 | /* Better Font Rendering =========== */
22 | -webkit-font-smoothing: antialiased;
23 | -moz-osx-font-smoothing: grayscale;
24 | }
25 |
26 | body, html { font-size: 100%; padding: 0; margin: 0;}
27 |
28 | /* Reset */
29 | *,
30 | *:after,
31 | *:before {
32 | -webkit-box-sizing: border-box;
33 | -moz-box-sizing: border-box;
34 | box-sizing: border-box;
35 | }
36 |
37 | /* Clearfix hack by Nicolas Gallagher: http://nicolasgallagher.com/micro-clearfix-hack/ */
38 | .clearfix:before,
39 | .clearfix:after {
40 | content: " ";
41 | display: table;
42 | }
43 |
44 | .clearfix:after {
45 | clear: both;
46 | }
47 |
48 | body{
49 | background: #494A5F;
50 | color: #D5D6E2;
51 | font-weight: 500;
52 | font-size: 1.05em;
53 | font-family: "Microsoft YaHei","Segoe UI", "Lucida Grande", Helvetica, Arial,sans-serif;
54 | }
55 | .htmleaf-links a{ color: rgba(255, 255, 255, 0.6);outline: none;text-decoration: none;-webkit-transition: 0.2s;transition: 0.2s;}
56 | .htmleaf-links a:hover,.htmleaf-links a:focus{color:#74777b;text-decoration: none;}
57 | .htmleaf-container{
58 | margin: 0 auto;
59 | }
60 |
61 | .bgcolor-1 { background: #f0efee; }
62 | .bgcolor-2 { background: #f9f9f9; }
63 | .bgcolor-3 { background: #e8e8e8; }/*light grey*/
64 | .bgcolor-4 { background: #2f3238; color: #fff; }/*Dark grey*/
65 | .bgcolor-5 { background: #df6659; color: #521e18; }/*pink1*/
66 | .bgcolor-6 { background: #2fa8ec; }/*sky blue*/
67 | .bgcolor-7 { background: #d0d6d6; }/*White tea*/
68 | .bgcolor-8 { background: #3d4444; color: #fff; }/*Dark grey2*/
69 | .bgcolor-9 { background: #ef3f52; color: #fff;}/*pink2*/
70 | .bgcolor-10{ background: #64448f; color: #fff;}/*Violet*/
71 | .bgcolor-11{ background: #3755ad; color: #fff;}/*dark blue*/
72 | .bgcolor-12{ background: #3498DB; color: #fff;}/*light blue*/
73 | .bgcolor-20{ background: #494A5F;color: #D5D6E2;}
74 | /* Header */
75 | .htmleaf-header{
76 | padding: 1em 190px 1em;
77 | letter-spacing: -1px;
78 | text-align: center;
79 | background: #66677c;
80 | }
81 | .htmleaf-header h1 {
82 | color: #D5D6E2;
83 | font-weight: 600;
84 | font-size: 2em;
85 | line-height: 1;
86 | margin-bottom: 0;
87 | }
88 | .htmleaf-header h1 span {
89 | display: block;
90 | font-size: 60%;
91 | font-weight: 400;
92 | padding: 0.8em 0 0.5em 0;
93 | color: #c3c8cd;
94 | }
95 | /*nav*/
96 | .htmleaf-demo a{color: #fff;text-decoration: none;}
97 | .htmleaf-demo{width: 100%;padding-bottom: 1.2em;}
98 | .htmleaf-demo a{display: inline-block;margin: 0.5em;padding: 0.6em 1em;border: 3px solid #fff;font-weight: 700;}
99 | .htmleaf-demo a:hover{opacity: 0.6;}
100 | .htmleaf-demo a.current{background:#1d7db1;color: #fff; }
101 | /* Top Navigation Style */
102 | .htmleaf-links {
103 | position: relative;
104 | display: inline-block;
105 | white-space: nowrap;
106 | font-size: 1.5em;
107 | text-align: center;
108 | }
109 |
110 | .htmleaf-links::after {
111 | position: absolute;
112 | top: 0;
113 | left: 50%;
114 | margin-left: -1px;
115 | width: 2px;
116 | height: 100%;
117 | background: #dbdbdb;
118 | content: '';
119 | -webkit-transform: rotate3d(0,0,1,22.5deg);
120 | transform: rotate3d(0,0,1,22.5deg);
121 | }
122 |
123 | .htmleaf-icon {
124 | display: inline-block;
125 | margin: 0.5em;
126 | padding: 0em 0;
127 | width: 1.5em;
128 | text-decoration: none;
129 | }
130 |
131 | .htmleaf-icon span {
132 | display: none;
133 | }
134 |
135 | .htmleaf-icon:before {
136 | margin: 0 5px;
137 | text-transform: none;
138 | font-weight: normal;
139 | font-style: normal;
140 | font-variant: normal;
141 | font-family: 'icomoon';
142 | line-height: 1;
143 | speak: none;
144 | -webkit-font-smoothing: antialiased;
145 | }
146 | /* footer */
147 | .htmleaf-footer{width: 100%;padding-top: 10px;}
148 | .htmleaf-small{font-size: 0.8em;}
149 | .center{text-align: center;}
150 | /****/
151 | .related {
152 | color: #fff;
153 | background: #494A5F;
154 | text-align: center;
155 | font-size: 1.25em;
156 | padding: 0.5em 0;
157 | overflow: hidden;
158 | }
159 |
160 | .related > a {
161 | vertical-align: top;
162 | width: calc(100% - 20px);
163 | max-width: 340px;
164 | display: inline-block;
165 | text-align: center;
166 | margin: 20px 10px;
167 | padding: 25px;
168 | font-family: "Microsoft YaHei","宋体","Segoe UI", "Lucida Grande", Helvetica, Arial,sans-serif, FreeSans, Arimo;
169 | }
170 | .related a {
171 | display: inline-block;
172 | text-align: left;
173 | margin: 20px auto;
174 | padding: 10px 20px;
175 | opacity: 0.8;
176 | -webkit-transition: opacity 0.3s;
177 | transition: opacity 0.3s;
178 | -webkit-backface-visibility: hidden;
179 | text-decoration: none;
180 | }
181 |
182 | .related a:hover,
183 | .related a:active {
184 | opacity: 1;
185 | }
186 |
187 | .related a img {
188 | max-width: 100%;
189 | opacity: 0.8;
190 | border-radius: 4px;
191 | }
192 | .related a:hover img,
193 | .related a:active img {
194 | opacity: 1;
195 | }
196 | .related h3{font-family: "Microsoft YaHei", sans-serif;font-size: 1.2em}
197 | .related a h3 {
198 | font-size: 0.85em;
199 | font-weight: 300;
200 | margin-top: 0.15em;
201 | color: #fff;
202 | }
203 | /* icomoon */
204 | .icon-htmleaf-home-outline:before {
205 | content: "\e5000";
206 | }
207 |
208 | .icon-htmleaf-arrow-forward-outline:before {
209 | content: "\e5001";
210 | }
211 |
212 | @media screen and (max-width: 1024px) {
213 | .htmleaf-header {
214 | padding: 2em 10% 2em;
215 | }
216 | .htmleaf-header h1 {
217 | font-size:1.4em;
218 | }
219 | .htmleaf-links{font-size: 1.4em}
220 | }
221 |
222 | @media screen and (max-width: 960px) {
223 | .htmleaf-header {
224 | padding: 2em 10% 2em;
225 | }
226 | .htmleaf-header h1 {
227 | font-size:1.2em;
228 | }
229 | .htmleaf-links{font-size: 1.2em}
230 | .related h3{font-size: 1em;}
231 | .related a h3 {
232 | font-size: 0.8em;
233 | }
234 | }
235 |
236 | @media screen and (max-width: 766px) {
237 | .htmleaf-header h1 {
238 | font-size:1.3em;
239 | }
240 | .htmleaf-links{font-size: 1.3em}
241 | }
242 |
243 | @media screen and (max-width: 640px) {
244 | .htmleaf-header {
245 | padding: 2em 10% 2em;
246 | }
247 | .htmleaf-header h1 {
248 | font-size:1em;
249 | }
250 | .htmleaf-links{font-size: 1em}
251 | .related h3{font-size: 0.8em;}
252 | .related a h3 {
253 | font-size: 0.6em;
254 | }
255 | }
--------------------------------------------------------------------------------
/h5game/css/default.css:
--------------------------------------------------------------------------------
1 | @font-face {
2 | font-family: 'icomoon';
3 | src:url('../fonts/icomoon.eot?rretjt');
4 | src:url('../fonts/icomoon.eot?#iefixrretjt') format('embedded-opentype'),
5 | url('../fonts/icomoon.woff?rretjt') format('woff'),
6 | url('../fonts/icomoon.ttf?rretjt') format('truetype'),
7 | url('../fonts/icomoon.svg?rretjt#icomoon') format('svg');
8 | font-weight: normal;
9 | font-style: normal;
10 | }
11 |
12 | [class^="icon-"], [class*=" icon-"] {
13 | font-family: 'icomoon';
14 | speak: none;
15 | font-style: normal;
16 | font-weight: normal;
17 | font-variant: normal;
18 | text-transform: none;
19 | line-height: 1;
20 |
21 | /* Better Font Rendering =========== */
22 | -webkit-font-smoothing: antialiased;
23 | -moz-osx-font-smoothing: grayscale;
24 | }
25 |
26 | body, html { font-size: 100%; padding: 0; margin: 0;}
27 |
28 | /* Reset */
29 | *,
30 | *:after,
31 | *:before {
32 | -webkit-box-sizing: border-box;
33 | -moz-box-sizing: border-box;
34 | box-sizing: border-box;
35 | }
36 |
37 | /* Clearfix hack by Nicolas Gallagher: http://nicolasgallagher.com/micro-clearfix-hack/ */
38 | .clearfix:before,
39 | .clearfix:after {
40 | content: " ";
41 | display: table;
42 | }
43 |
44 | .clearfix:after {
45 | clear: both;
46 | }
47 |
48 | body{
49 | background: #f9f7f6;
50 | color: #404d5b;
51 | font-weight: 500;
52 | font-size: 1.05em;
53 | font-family: "Segoe UI", "Lucida Grande", Helvetica, Arial, "Microsoft YaHei", FreeSans, Arimo, "Droid Sans", "wenquanyi micro hei", "Hiragino Sans GB", "Hiragino Sans GB W3", "FontAwesome", sans-serif;
54 | }
55 | a{color: #2fa0ec;text-decoration: none;outline: none;}
56 | a:hover,a:focus{color:#74777b;}
57 |
58 | .htmleaf-container{
59 | margin: 0 auto;
60 | text-align: center;
61 | overflow: hidden;
62 | }
63 | .htmleaf-content {
64 | font-size: 150%;
65 | padding: 1em 0;
66 | }
67 |
68 | .htmleaf-content h2 {
69 | margin: 0 0 2em;
70 | opacity: 0.1;
71 | }
72 |
73 | .htmleaf-content p {
74 | margin: 1em 0;
75 | padding: 5em 0 0 0;
76 | font-size: 0.65em;
77 | }
78 | .bgcolor-1 { background: #f0efee; }
79 | .bgcolor-2 { background: #f9f9f9; }
80 | .bgcolor-3 { background: #e8e8e8; }/*light grey*/
81 | .bgcolor-4 { background: #2f3238; color: #fff; }/*Dark grey*/
82 | .bgcolor-5 { background: #df6659; color: #521e18; }/*pink1*/
83 | .bgcolor-6 { background: #2fa8ec; }/*sky blue*/
84 | .bgcolor-7 { background: #d0d6d6; }/*White tea*/
85 | .bgcolor-8 { background: #3d4444; color: #fff; }/*Dark grey2*/
86 | .bgcolor-9 { background: #ef3f52; color: #fff;}/*pink2*/
87 | .bgcolor-10{ background: #64448f; color: #fff;}/*Violet*/
88 | .bgcolor-11{ background: #3755ad; color: #fff;}/*dark blue*/
89 | .bgcolor-12{ background: #3498DB; color: #fff;}/*light blue*/
90 | /* Header */
91 | .htmleaf-header{
92 | padding: 1em 190px 1em;
93 | letter-spacing: -1px;
94 | text-align: center;
95 | }
96 | .htmleaf-header h1 {
97 | font-weight: 600;
98 | font-size: 2em;
99 | line-height: 1;
100 | margin-bottom: 0;
101 | font-family: "Segoe UI", "Lucida Grande", Helvetica, Arial, "Microsoft YaHei", FreeSans, Arimo, "Droid Sans", "wenquanyi micro hei", "Hiragino Sans GB", "Hiragino Sans GB W3", "FontAwesome", sans-serif;
102 | }
103 | .htmleaf-header h1 span {
104 | font-family: "Segoe UI", "Lucida Grande", Helvetica, Arial, "Microsoft YaHei", FreeSans, Arimo, "Droid Sans", "wenquanyi micro hei", "Hiragino Sans GB", "Hiragino Sans GB W3", "FontAwesome", sans-serif;
105 | display: block;
106 | font-size: 60%;
107 | font-weight: 400;
108 | padding: 0.8em 0 0.5em 0;
109 | color: #c3c8cd;
110 | }
111 | /*nav*/
112 | .htmleaf-demo a{color: #1d7db1;text-decoration: none;}
113 | .htmleaf-demo{width: 100%;padding-bottom: 1.2em;}
114 | .htmleaf-demo a{display: inline-block;margin: 0.5em;padding: 0.6em 1em;border: 3px solid #1d7db1;font-weight: 700;}
115 | .htmleaf-demo a:hover{opacity: 0.6;}
116 | .htmleaf-demo a.current{background:#1d7db1;color: #fff; }
117 | /* Top Navigation Style */
118 | .htmleaf-links {
119 | position: relative;
120 | display: inline-block;
121 | white-space: nowrap;
122 | font-size: 1.5em;
123 | text-align: center;
124 | }
125 |
126 | .htmleaf-links::after {
127 | position: absolute;
128 | top: 0;
129 | left: 50%;
130 | margin-left: -1px;
131 | width: 2px;
132 | height: 100%;
133 | background: #dbdbdb;
134 | content: '';
135 | -webkit-transform: rotate3d(0,0,1,22.5deg);
136 | transform: rotate3d(0,0,1,22.5deg);
137 | }
138 |
139 | .htmleaf-icon {
140 | display: inline-block;
141 | margin: 0.5em;
142 | padding: 0em 0;
143 | width: 1.5em;
144 | text-decoration: none;
145 | }
146 |
147 | .htmleaf-icon span {
148 | display: none;
149 | }
150 |
151 | .htmleaf-icon:before {
152 | margin: 0 5px;
153 | text-transform: none;
154 | font-weight: normal;
155 | font-style: normal;
156 | font-variant: normal;
157 | font-family: 'icomoon';
158 | line-height: 1;
159 | speak: none;
160 | -webkit-font-smoothing: antialiased;
161 | }
162 | /* footer */
163 | .htmleaf-footer{width: 100%;padding-top: 10px;}
164 | .htmleaf-small{font-size: 0.8em;}
165 | .center{text-align: center;}
166 | /****/
167 | .related {
168 | color: #fff;
169 | background: #333;
170 | text-align: center;
171 | font-size: 1.25em;
172 | padding: 0.5em 0;
173 | overflow: hidden;
174 | }
175 |
176 | .related > a {
177 | vertical-align: top;
178 | width: calc(100% - 20px);
179 | max-width: 340px;
180 | display: inline-block;
181 | text-align: center;
182 | margin: 20px 10px;
183 | padding: 25px;
184 | font-family: "Segoe UI", "Lucida Grande", Helvetica, Arial, "Microsoft YaHei", FreeSans, Arimo, "Droid Sans", "wenquanyi micro hei", "Hiragino Sans GB", "Hiragino Sans GB W3", "FontAwesome", sans-serif;
185 | }
186 | .related a {
187 | display: inline-block;
188 | text-align: left;
189 | margin: 20px auto;
190 | padding: 10px 20px;
191 | opacity: 0.8;
192 | -webkit-transition: opacity 0.3s;
193 | transition: opacity 0.3s;
194 | -webkit-backface-visibility: hidden;
195 | }
196 |
197 | .related a:hover,
198 | .related a:active {
199 | opacity: 1;
200 | }
201 |
202 | .related a img {
203 | max-width: 100%;
204 | opacity: 0.8;
205 | border-radius: 4px;
206 | }
207 | .related a:hover img,
208 | .related a:active img {
209 | opacity: 1;
210 | }
211 | .related h3{font-family: "Microsoft YaHei", sans-serif;}
212 | .related a h3 {
213 | font-weight: 300;
214 | margin-top: 0.15em;
215 | color: #fff;
216 | }
217 | /* icomoon */
218 | .icon-htmleaf-home-outline:before {
219 | content: "\e5000";
220 | }
221 |
222 | .icon-htmleaf-arrow-forward-outline:before {
223 | content: "\e5001";
224 | }
225 |
226 | @media screen and (max-width: 50em) {
227 | .htmleaf-header {
228 | padding: 3em 10% 4em;
229 | }
230 | .htmleaf-header h1 {
231 | font-size:2em;
232 | }
233 | }
234 |
235 |
236 | @media screen and (max-width: 40em) {
237 | .htmleaf-header h1 {
238 | font-size: 1.5em;
239 | }
240 | }
241 |
242 | @media screen and (max-width: 30em) {
243 | .htmleaf-header h1 {
244 | font-size:1.2em;
245 | }
246 | }
--------------------------------------------------------------------------------
/jQueryScroll/css/default.css:
--------------------------------------------------------------------------------
1 | @font-face {
2 | font-family: 'icomoon';
3 | src:url('../fonts/icomoon.eot?rretjt');
4 | src:url('../fonts/icomoon.eot?#iefixrretjt') format('embedded-opentype'),
5 | url('../fonts/icomoon.woff?rretjt') format('woff'),
6 | url('../fonts/icomoon.ttf?rretjt') format('truetype'),
7 | url('../fonts/icomoon.svg?rretjt#icomoon') format('svg');
8 | font-weight: normal;
9 | font-style: normal;
10 | }
11 |
12 | [class^="icon-"], [class*=" icon-"] {
13 | font-family: 'icomoon';
14 | speak: none;
15 | font-style: normal;
16 | font-weight: normal;
17 | font-variant: normal;
18 | text-transform: none;
19 | line-height: 1;
20 |
21 | /* Better Font Rendering =========== */
22 | -webkit-font-smoothing: antialiased;
23 | -moz-osx-font-smoothing: grayscale;
24 | }
25 |
26 | body, html { font-size: 100%; padding: 0; margin: 0;}
27 |
28 | /* Reset */
29 | *,
30 | *:after,
31 | *:before {
32 | -webkit-box-sizing: border-box;
33 | -moz-box-sizing: border-box;
34 | box-sizing: border-box;
35 | }
36 |
37 | /* Clearfix hack by Nicolas Gallagher: http://nicolasgallagher.com/micro-clearfix-hack/ */
38 | .clearfix:before,
39 | .clearfix:after {
40 | content: " ";
41 | display: table;
42 | }
43 |
44 | .clearfix:after {
45 | clear: both;
46 | }
47 |
48 | body{
49 | background: #f9f7f6;
50 | color: #404d5b;
51 | font-weight: 500;
52 | font-size: 1.05em;
53 | font-family: "Segoe UI", "Lucida Grande", Helvetica, Arial, "Microsoft YaHei", FreeSans, Arimo, "Droid Sans", "wenquanyi micro hei", "Hiragino Sans GB", "Hiragino Sans GB W3", "FontAwesome", sans-serif;
54 | }
55 | a{color: #2fa0ec;text-decoration: none;outline: none;}
56 | a:hover,a:focus{color:#74777b;}
57 |
58 | .htmleaf-container{
59 | margin: 0 auto;
60 | text-align: center;
61 | overflow: hidden;
62 | }
63 | .htmleaf-content {
64 | font-size: 150%;
65 | padding: 1em 0;
66 | }
67 |
68 | .htmleaf-content h2 {
69 | margin: 0 0 2em;
70 | opacity: 0.1;
71 | }
72 |
73 | .htmleaf-content p {
74 | margin: 1em 0;
75 | padding: 5em 0 0 0;
76 | font-size: 0.65em;
77 | }
78 | .bgcolor-1 { background: #f0efee; }
79 | .bgcolor-2 { background: #f9f9f9; }
80 | .bgcolor-3 { background: #e8e8e8; }/*light grey*/
81 | .bgcolor-4 { background: #2f3238; color: #fff; }/*Dark grey*/
82 | .bgcolor-5 { background: #df6659; color: #521e18; }/*pink1*/
83 | .bgcolor-6 { background: #2fa8ec; }/*sky blue*/
84 | .bgcolor-7 { background: #d0d6d6; }/*White tea*/
85 | .bgcolor-8 { background: #3d4444; color: #fff; }/*Dark grey2*/
86 | .bgcolor-9 { background: #ef3f52; color: #fff;}/*pink2*/
87 | .bgcolor-10{ background: #64448f; color: #fff;}/*Violet*/
88 | .bgcolor-11{ background: #3755ad; color: #fff;}/*dark blue*/
89 | .bgcolor-12{ background: #3498DB; color: #fff;}/*light blue*/
90 | /* Header */
91 | .htmleaf-header{
92 | padding: 1em 190px 1em;
93 | letter-spacing: -1px;
94 | text-align: center;
95 | }
96 | .htmleaf-header h1 {
97 | font-weight: 600;
98 | font-size: 2em;
99 | line-height: 1;
100 | margin-bottom: 0;
101 | font-family: "Segoe UI", "Lucida Grande", Helvetica, Arial, "Microsoft YaHei", FreeSans, Arimo, "Droid Sans", "wenquanyi micro hei", "Hiragino Sans GB", "Hiragino Sans GB W3", "FontAwesome", sans-serif;
102 | }
103 | .htmleaf-header h1 span {
104 | font-family: "Segoe UI", "Lucida Grande", Helvetica, Arial, "Microsoft YaHei", FreeSans, Arimo, "Droid Sans", "wenquanyi micro hei", "Hiragino Sans GB", "Hiragino Sans GB W3", "FontAwesome", sans-serif;
105 | display: block;
106 | font-size: 60%;
107 | font-weight: 400;
108 | padding: 0.8em 0 0.5em 0;
109 | color: #c3c8cd;
110 | }
111 | /*nav*/
112 | .htmleaf-demo a{color: #1d7db1;text-decoration: none;}
113 | .htmleaf-demo{width: 100%;padding-bottom: 1.2em;}
114 | .htmleaf-demo a{display: inline-block;margin: 0.5em;padding: 0.6em 1em;border: 3px solid #1d7db1;font-weight: 700;}
115 | .htmleaf-demo a:hover{opacity: 0.6;}
116 | .htmleaf-demo a.current{background:#1d7db1;color: #fff; }
117 | /* Top Navigation Style */
118 | .htmleaf-links {
119 | position: relative;
120 | display: inline-block;
121 | white-space: nowrap;
122 | font-size: 1.5em;
123 | text-align: center;
124 | }
125 |
126 | .htmleaf-links::after {
127 | position: absolute;
128 | top: 0;
129 | left: 50%;
130 | margin-left: -1px;
131 | width: 2px;
132 | height: 100%;
133 | background: #dbdbdb;
134 | content: '';
135 | -webkit-transform: rotate3d(0,0,1,22.5deg);
136 | transform: rotate3d(0,0,1,22.5deg);
137 | }
138 |
139 | .htmleaf-icon {
140 | display: inline-block;
141 | margin: 0.5em;
142 | padding: 0em 0;
143 | width: 1.5em;
144 | text-decoration: none;
145 | }
146 |
147 | .htmleaf-icon span {
148 | display: none;
149 | }
150 |
151 | .htmleaf-icon:before {
152 | margin: 0 5px;
153 | text-transform: none;
154 | font-weight: normal;
155 | font-style: normal;
156 | font-variant: normal;
157 | font-family: 'icomoon';
158 | line-height: 1;
159 | speak: none;
160 | -webkit-font-smoothing: antialiased;
161 | }
162 | /* footer */
163 | .htmleaf-footer{width: 100%;padding-top: 10px;}
164 | .htmleaf-small{font-size: 0.8em;}
165 | .center{text-align: center;}
166 | /****/
167 | .related {
168 | color: #fff;
169 | background: #333;
170 | text-align: center;
171 | font-size: 1.25em;
172 | padding: 0.5em 0;
173 | overflow: hidden;
174 | }
175 |
176 | .related > a {
177 | vertical-align: top;
178 | width: calc(100% - 20px);
179 | max-width: 340px;
180 | display: inline-block;
181 | text-align: center;
182 | margin: 20px 10px;
183 | padding: 25px;
184 | font-family: "Segoe UI", "Lucida Grande", Helvetica, Arial, "Microsoft YaHei", FreeSans, Arimo, "Droid Sans", "wenquanyi micro hei", "Hiragino Sans GB", "Hiragino Sans GB W3", "FontAwesome", sans-serif;
185 | }
186 | .related a {
187 | display: inline-block;
188 | text-align: left;
189 | margin: 20px auto;
190 | padding: 10px 20px;
191 | opacity: 0.8;
192 | -webkit-transition: opacity 0.3s;
193 | transition: opacity 0.3s;
194 | -webkit-backface-visibility: hidden;
195 | }
196 |
197 | .related a:hover,
198 | .related a:active {
199 | opacity: 1;
200 | }
201 |
202 | .related a img {
203 | max-width: 100%;
204 | opacity: 0.8;
205 | border-radius: 4px;
206 | }
207 | .related a:hover img,
208 | .related a:active img {
209 | opacity: 1;
210 | }
211 | .related h3{font-family: "Microsoft YaHei", sans-serif;}
212 | .related a h3 {
213 | font-weight: 300;
214 | margin-top: 0.15em;
215 | color: #fff;
216 | }
217 | /* icomoon */
218 | .icon-htmleaf-home-outline:before {
219 | content: "\e5000";
220 | }
221 |
222 | .icon-htmleaf-arrow-forward-outline:before {
223 | content: "\e5001";
224 | }
225 |
226 | @media screen and (max-width: 50em) {
227 | .htmleaf-header {
228 | padding: 3em 10% 4em;
229 | }
230 | .htmleaf-header h1 {
231 | font-size:2em;
232 | }
233 | }
234 |
235 |
236 | @media screen and (max-width: 40em) {
237 | .htmleaf-header h1 {
238 | font-size: 1.5em;
239 | }
240 | }
241 |
242 | @media screen and (max-width: 30em) {
243 | .htmleaf-header h1 {
244 | font-size:1.2em;
245 | }
246 | }
--------------------------------------------------------------------------------
/translate/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | 鼠标hover图片CSS3动画特效
9 |
10 |
11 |
12 |
116 |
117 |
118 |
119 |
126 |
127 |
128 |
129 |
130 |
131 |

132 |
133 |
CSS动画特效
134 |
translate
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |

148 |
149 |
CSS动画特效
150 |
translate
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |

164 |
165 |
CSS动画特效
166 |
translate
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
--------------------------------------------------------------------------------
/jQuery手风琴/css/normalize.css:
--------------------------------------------------------------------------------
1 | /*! normalize.css 2011-10-24T11:29 UTC - http://github.com/necolas/normalize.css */
2 |
3 | /* =============================================================================
4 | HTML5 display definitions
5 | ========================================================================== */
6 |
7 | /*
8 | * Corrects block display not defined in IE6/7/8/9 & FF3
9 | */
10 |
11 | article,
12 | aside,
13 | details,
14 | figcaption,
15 | figure,
16 | footer,
17 | header,
18 | hgroup,
19 | nav,
20 | section {
21 | display: block;
22 | }
23 |
24 | /*
25 | * Corrects inline-block display not defined in IE6/7/8/9 & FF3
26 | */
27 |
28 | audio,
29 | canvas,
30 | video {
31 | display: inline-block;
32 | *display: inline;
33 | *zoom: 1;
34 | }
35 |
36 | /*
37 | * Prevents modern browsers from displaying 'audio' without controls
38 | */
39 |
40 | audio:not([controls]) {
41 | display: none;
42 | }
43 |
44 | /*
45 | * Addresses styling for 'hidden' attribute not present in IE7/8/9, FF3, S4
46 | * Known issue: no IE6 support
47 | */
48 |
49 | [hidden] {
50 | display: none;
51 | }
52 |
53 |
54 | /* =============================================================================
55 | Base
56 | ========================================================================== */
57 |
58 | /*
59 | * 1. Corrects text resizing oddly in IE6/7 when body font-size is set using em units
60 | * http://clagnut.com/blog/348/#c790
61 | * 2. Keeps page centred in all browsers regardless of content height
62 | * 3. Prevents iOS text size adjust after orientation change, without disabling user zoom
63 | * www.456bereastreet.com/archive/201012/controlling_text_size_in_safari_for_ios_without_disabling_user_zoom/
64 | */
65 |
66 | html {
67 | font-size: 100%; /* 1 */
68 | /* 2 */
69 | -webkit-text-size-adjust: 100%; /* 3 */
70 | -ms-text-size-adjust: 100%; /* 3 */
71 | }
72 |
73 | /*
74 | * Addresses margins handled incorrectly in IE6/7
75 | */
76 |
77 | body {
78 | margin: 0;
79 | }
80 |
81 | /*
82 | * Addresses font-family inconsistency between 'textarea' and other form elements.
83 | */
84 |
85 | body,
86 | button,
87 | input,
88 | select,
89 | textarea {
90 | font-family: sans-serif;
91 | }
92 |
93 |
94 | /* =============================================================================
95 | Links
96 | ========================================================================== */
97 |
98 | /*
99 | * Addresses outline displayed oddly in Chrome
100 | */
101 |
102 | a:focus {
103 | outline: thin dotted;
104 | }
105 |
106 | /*
107 | * Improves readability when focused and also mouse hovered in all browsers
108 | * people.opera.com/patrickl/experiments/keyboard/test
109 | */
110 |
111 | a:hover,
112 | a:active {
113 | outline: 0;
114 | }
115 |
116 |
117 | /* =============================================================================
118 | Typography
119 | ========================================================================== */
120 |
121 | /*
122 | * Addresses styling not present in IE7/8/9, S5, Chrome
123 | */
124 |
125 | abbr[title] {
126 | border-bottom: 1px dotted;
127 | }
128 |
129 | /*
130 | * Addresses style set to 'bolder' in FF3/4, S4/5, Chrome
131 | */
132 |
133 | b,
134 | strong {
135 | font-weight: bold;
136 | }
137 |
138 | blockquote {
139 | margin: 1em 40px;
140 | }
141 |
142 | /*
143 | * Addresses styling not present in S5, Chrome
144 | */
145 |
146 | dfn {
147 | font-style: italic;
148 | }
149 |
150 | /*
151 | * Addresses styling not present in IE6/7/8/9
152 | */
153 |
154 | mark {
155 | background: #ff0;
156 | color: #000;
157 | }
158 |
159 | /*
160 | * Corrects font family set oddly in IE6, S4/5, Chrome
161 | * en.wikipedia.org/wiki/User:Davidgothberg/Test59
162 | */
163 |
164 | pre,
165 | code,
166 | kbd,
167 | samp {
168 | font-family: monospace, serif;
169 | _font-family: 'courier new', monospace;
170 | font-size: 1em;
171 | }
172 |
173 | /*
174 | * Improves readability of pre-formatted text in all browsers
175 | */
176 |
177 | pre {
178 | white-space: pre;
179 | white-space: pre-wrap;
180 | word-wrap: break-word;
181 | }
182 |
183 | /*
184 | * 1. Addresses CSS quotes not supported in IE6/7
185 | * 2. Addresses quote property not supported in S4
186 | */
187 |
188 | /* 1 */
189 |
190 | q {
191 | quotes: none;
192 | }
193 |
194 | /* 2 */
195 |
196 | q:before,
197 | q:after {
198 | content: '';
199 | content: none;
200 | }
201 |
202 | small {
203 | font-size: 75%;
204 | }
205 |
206 | /*
207 | * Prevents sub and sup affecting line-height in all browsers
208 | * gist.github.com/413930
209 | */
210 |
211 | sub,
212 | sup {
213 | font-size: 75%;
214 | line-height: 0;
215 | position: relative;
216 | vertical-align: baseline;
217 | }
218 |
219 | sup {
220 | top: -0.5em;
221 | }
222 |
223 | sub {
224 | bottom: -0.25em;
225 | }
226 |
227 |
228 | /* =============================================================================
229 | Lists
230 | ========================================================================== */
231 |
232 | ul,
233 | ol {
234 | margin: 1em 0;
235 | padding: 0 0 0 40px;
236 | }
237 |
238 | dd {
239 | margin: 0 0 0 40px;
240 | }
241 |
242 | nav ul,
243 | nav ol {
244 | list-style: none;
245 | list-style-image: none;
246 | }
247 |
248 |
249 | /* =============================================================================
250 | Embedded content
251 | ========================================================================== */
252 |
253 | /*
254 | * 1. Removes border when inside 'a' element in IE6/7/8/9, FF3
255 | * 2. Improves image quality when scaled in IE7
256 | * code.flickr.com/blog/2008/11/12/on-ui-quality-the-little-things-client-side-image-resizing/
257 | */
258 |
259 | img {
260 | border: 0; /* 1 */
261 | -ms-interpolation-mode: bicubic; /* 2 */
262 | }
263 |
264 | /*
265 | * Corrects overflow displayed oddly in IE9
266 | */
267 |
268 | svg:not(:root) {
269 | overflow: hidden;
270 | }
271 |
272 |
273 | /* =============================================================================
274 | Figures
275 | ========================================================================== */
276 |
277 | /*
278 | * Addresses margin not present in IE6/7/8/9, S5, O11
279 | */
280 |
281 | figure {
282 | margin: 0;
283 | }
284 |
285 |
286 | /* =============================================================================
287 | Forms
288 | ========================================================================== */
289 |
290 | /*
291 | * Corrects margin displayed oddly in IE6/7
292 | */
293 |
294 | form {
295 | margin: 0;
296 | }
297 |
298 | /*
299 | * Define consistent border, margin, and padding
300 | */
301 |
302 | fieldset {
303 | border: 1px solid #c0c0c0;
304 | margin: 0 2px;
305 | padding: 0.35em 0.625em 0.75em;
306 | }
307 |
308 | /*
309 | * 1. Corrects color not being inherited in IE6/7/8/9
310 | * 2. Corrects alignment displayed oddly in IE6/7
311 | */
312 |
313 | legend {
314 | border: 0; /* 1 */
315 | *margin-left: -7px; /* 2 */
316 | }
317 |
318 | /*
319 | * 1. Corrects font size not being inherited in all browsers
320 | * 2. Addresses margins set differently in IE6/7, FF3/4, S5, Chrome
321 | * 3. Improves appearance and consistency in all browsers
322 | */
323 |
324 | button,
325 | input,
326 | select,
327 | textarea {
328 | font-size: 100%; /* 1 */
329 | margin: 0; /* 2 */
330 | vertical-align: baseline; /* 3 */
331 | *vertical-align: middle; /* 3 */
332 | }
333 |
334 | /*
335 | * Addresses FF3/4 setting line-height on 'input' using !important in the UA stylesheet
336 | */
337 |
338 | button,
339 | input {
340 | line-height: normal; /* 1 */
341 | }
342 |
343 | /*
344 | * 1. Improves usability and consistency of cursor style between image-type 'input' and others
345 | * 2. Corrects inability to style clickable 'input' types in iOS
346 | * 3. Corrects inner spacing displayed oddly in IE7 without effecting normal text inputs
347 | * Known issue: inner spacing remains in IE6
348 | */
349 |
350 | button,
351 | input[type="button"],
352 | input[type="reset"],
353 | input[type="submit"] {
354 | cursor: pointer; /* 1 */
355 | -webkit-appearance: button; /* 2 */
356 | *overflow: visible; /* 3 */
357 | }
358 |
359 | /*
360 | * 1. Addresses box sizing set to content-box in IE8/9
361 | * 2. Addresses excess padding in IE8/9
362 | */
363 |
364 | input[type="checkbox"],
365 | input[type="radio"] {
366 | box-sizing: border-box; /* 1 */
367 | padding: 0; /* 2 */
368 | }
369 |
370 | /*
371 | * 1. Addresses appearance set to searchfield in S5, Chrome
372 | * 2. Addresses box sizing set to border-box in S5, Chrome (include -moz to future-proof)
373 | */
374 |
375 | input[type="search"] {
376 | -webkit-appearance: textfield; /* 1 */
377 | -moz-box-sizing: content-box;
378 | -webkit-box-sizing: content-box; /* 2 */
379 | box-sizing: content-box;
380 | }
381 |
382 | /*
383 | * Corrects inner padding displayed oddly in S5, Chrome on OSX
384 | */
385 |
386 | input[type="search"]::-webkit-search-decoration {
387 | -webkit-appearance: none;
388 | }
389 |
390 | /*
391 | * Corrects inner padding and border displayed oddly in FF3/4
392 | * www.sitepen.com/blog/2008/05/14/the-devils-in-the-details-fixing-dojos-toolbar-buttons/
393 | */
394 |
395 | button::-moz-focus-inner,
396 | input::-moz-focus-inner {
397 | border: 0;
398 | padding: 0;
399 | }
400 |
401 | /*
402 | * 1. Removes default vertical scrollbar in IE6/7/8/9
403 | * 2. Improves readability and alignment in all browsers
404 | */
405 |
406 | textarea {
407 | overflow: auto; /* 1 */
408 | vertical-align: top; /* 2 */
409 | }
410 |
411 |
412 | /* =============================================================================
413 | Tables
414 | ========================================================================== */
415 |
416 | /*
417 | * Remove most spacing between table cells
418 | */
419 |
420 | table {
421 | border-collapse: collapse;
422 | border-spacing: 0;
423 | }
--------------------------------------------------------------------------------
/threejs/js/Distortions.js:
--------------------------------------------------------------------------------
1 | /**
2 |
3 | Here on top you can find the uniforms for each distortion.
4 |
5 | // ShaderShaping funcitns
6 | https://thebookofshaders.com/05/
7 | Steps
8 | 1. Write getDistortion in GLSL
9 | 2. Write custom uniforms for tweak parameters. Put them outside the object.
10 | 3. Re-create the GLSl funcion in javascript to get camera paning
11 |
12 | Notes:
13 | LookAtAmp AND lookAtOffset are hand tuned to get a good camera panning.
14 | */
15 |
16 | const mountainUniforms = {
17 | // x, y, z
18 | uFreq: new THREE.Uniform(new THREE.Vector3(3, 6, 10)),
19 | uAmp: new THREE.Uniform(new THREE.Vector3(30, 30, 20))
20 | };
21 |
22 | const xyUniforms = {
23 | // x,y
24 | uFreq: new THREE.Uniform(new THREE.Vector2(5, 2)),
25 | uAmp: new THREE.Uniform(new THREE.Vector2(25, 15))
26 | };
27 |
28 | const LongRaceUniforms = {
29 | // x, y
30 | uFreq: new THREE.Uniform(new THREE.Vector2(2, 3)),
31 | uAmp: new THREE.Uniform(new THREE.Vector2(35, 10))
32 | };
33 |
34 | const turbulentUniforms = {
35 | // x,x, y,y
36 | uFreq: new THREE.Uniform(new THREE.Vector4(4, 8, 8, 1)),
37 | uAmp: new THREE.Uniform(new THREE.Vector4(25, 5, 10, 10))
38 | };
39 |
40 | const deepUniforms = {
41 | // x, y
42 | uFreq: new THREE.Uniform(new THREE.Vector2(4, 8)),
43 | uAmp: new THREE.Uniform(new THREE.Vector2(10, 20)),
44 | uPowY: new THREE.Uniform(new THREE.Vector2(20, 2))
45 | };
46 |
47 | let nsin = val => Math.sin(val) * 0.5 + 0.5;
48 |
49 | let mountainDistortion = {
50 | uniforms: mountainUniforms,
51 | getDistortion: `
52 |
53 | uniform vec3 uAmp;
54 | uniform vec3 uFreq;
55 |
56 | #define PI 3.14159265358979
57 |
58 | float nsin(float val){
59 | return sin(val) * 0.5+0.5;
60 | }
61 |
62 | vec3 getDistortion(float progress){
63 |
64 | float movementProgressFix = 0.02;
65 | return vec3(
66 | cos(progress * PI * uFreq.x + uTime) * uAmp.x - cos(movementProgressFix * PI * uFreq.x + uTime) * uAmp.x,
67 | nsin(progress * PI * uFreq.y + uTime) * uAmp.y - nsin(movementProgressFix * PI * uFreq.y + uTime) * uAmp.y,
68 | nsin(progress * PI * uFreq.z + uTime) * uAmp.z - nsin(movementProgressFix * PI * uFreq.z + uTime) * uAmp.z
69 | );
70 | }
71 | `,
72 | getJS: (progress, time) => {
73 | let movementProgressFix = 0.02;
74 |
75 | let uFreq = mountainUniforms.uFreq.value;
76 | let uAmp = mountainUniforms.uAmp.value;
77 |
78 | let distortion = new THREE.Vector3(
79 | Math.cos(progress * Math.PI * uFreq.x + time) * uAmp.x -
80 | Math.cos(movementProgressFix * Math.PI * uFreq.x + time) * uAmp.x,
81 | nsin(progress * Math.PI * uFreq.y + time) * uAmp.y -
82 | nsin(movementProgressFix * Math.PI * uFreq.y + time) * uAmp.y,
83 | nsin(progress * Math.PI * uFreq.z + time) * uAmp.z -
84 | nsin(movementProgressFix * Math.PI * uFreq.z + time) * uAmp.z
85 | );
86 |
87 | let lookAtAmp = new THREE.Vector3(2, 2, 2);
88 | let lookAtOffset = new THREE.Vector3(0, 0, -5);
89 | return distortion.multiply(lookAtAmp).add(lookAtOffset);
90 | }
91 | };
92 |
93 | let xyDistortion = {
94 | uniforms: xyUniforms,
95 | getDistortion: `
96 | uniform vec2 uFreq;
97 | uniform vec2 uAmp;
98 |
99 | #define PI 3.14159265358979
100 |
101 |
102 | vec3 getDistortion(float progress){
103 |
104 | float movementProgressFix = 0.02;
105 | return vec3(
106 | cos(progress * PI * uFreq.x + uTime) * uAmp.x - cos(movementProgressFix * PI * uFreq.x + uTime) *uAmp.x,
107 | sin(progress * PI * uFreq.y + PI/2. + uTime) * uAmp.y - sin(movementProgressFix * PI * uFreq.y + PI/2. + uTime) * uAmp.y,
108 | 0.
109 | );
110 | }
111 | `,
112 | getJS: (progress, time) => {
113 | let movementProgressFix = 0.02;
114 |
115 | let uFreq = xyUniforms.uFreq.value;
116 | let uAmp = xyUniforms.uAmp.value;
117 |
118 | let distortion = new THREE.Vector3(
119 | Math.cos(progress * Math.PI * uFreq.x + time) * uAmp.x -
120 | Math.cos(movementProgressFix * Math.PI * uFreq.x + time) * uAmp.x,
121 | Math.sin(progress * Math.PI * uFreq.y + time + Math.PI / 2) * uAmp.y -
122 | Math.sin(movementProgressFix * Math.PI * uFreq.y + time + Math.PI / 2) *
123 | uAmp.y,
124 | 0
125 | );
126 | let lookAtAmp = new THREE.Vector3(2, 0.4, 1);
127 | let lookAtOffset = new THREE.Vector3(0, 0, -3);
128 | return distortion.multiply(lookAtAmp).add(lookAtOffset);
129 | }
130 | };
131 |
132 | let LongRaceDistortion = {
133 | uniforms: LongRaceUniforms,
134 | getDistortion: `
135 |
136 | uniform vec2 uFreq;
137 | uniform vec2 uAmp;
138 | #define PI 3.14159265358979
139 |
140 | vec3 getDistortion(float progress){
141 |
142 | float camProgress = 0.0125;
143 | return vec3(
144 | sin(progress * PI * uFreq.x +uTime) * uAmp.x - sin(camProgress * PI * uFreq.x+uTime ) * uAmp.x,
145 | sin(progress * PI * uFreq.y +uTime) * uAmp.y - sin(camProgress * PI * uFreq.y+uTime ) * uAmp.y,
146 | 0.
147 | );
148 | }
149 | `,
150 | getJS: (progress, time) => {
151 | let camProgress = 0.0125;
152 |
153 | let uFreq = LongRaceUniforms.uFreq.value;
154 | let uAmp = LongRaceUniforms.uAmp.value;
155 | // Uniforms
156 |
157 | let distortion = new THREE.Vector3(
158 | Math.sin(progress * Math.PI * uFreq.x + time) * uAmp.x -
159 | Math.sin(camProgress * Math.PI * uFreq.x + time) * uAmp.x,
160 | Math.sin(progress * Math.PI * uFreq.y + time) * uAmp.y -
161 | Math.sin(camProgress * Math.PI * uFreq.y + time) * uAmp.y,
162 | 0
163 | );
164 |
165 | let lookAtAmp = new THREE.Vector3(1, 1, 0);
166 | let lookAtOffset = new THREE.Vector3(0, 0, -5);
167 | return distortion.multiply(lookAtAmp).add(lookAtOffset);
168 | }
169 | };
170 |
171 | const turbulentDistortion = {
172 | uniforms: turbulentUniforms,
173 | getDistortion: `
174 | uniform vec4 uFreq;
175 | uniform vec4 uAmp;
176 | float nsin(float val){
177 | return sin(val) * 0.5+0.5;
178 | }
179 |
180 | #define PI 3.14159265358979
181 | float getDistortionX(float progress){
182 | return
183 | (
184 | cos( PI * progress * uFreq.r + uTime) * uAmp.r +
185 | pow(cos(PI * progress * uFreq.g + uTime * (uFreq.g / uFreq.r)),2. )* uAmp.g
186 |
187 | );
188 | }
189 | float getDistortionY(float progress){
190 | return
191 | (
192 | -nsin( PI * progress * uFreq.b + uTime) * uAmp.b +
193 | -pow(nsin(PI * progress * uFreq.a + uTime / (uFreq.b / uFreq.a) ),5.) * uAmp.a
194 |
195 | );
196 | }
197 | vec3 getDistortion(float progress){
198 | return vec3(
199 | getDistortionX(progress)-getDistortionX(0.0125) ,
200 | getDistortionY(progress)- getDistortionY(0.0125),
201 | 0.
202 | );
203 | }
204 | `,
205 | getJS: (progress, time) => {
206 | const uFreq = turbulentUniforms.uFreq.value;
207 | const uAmp = turbulentUniforms.uAmp.value;
208 |
209 | const getX = p =>
210 | Math.cos(Math.PI * p * uFreq.x + time) * uAmp.x +
211 | Math.pow(
212 | Math.cos(Math.PI * p * uFreq.y + time * (uFreq.y / uFreq.x)),
213 | 2
214 | ) *
215 | uAmp.y;
216 | const getY = p =>
217 | -nsin(Math.PI * p * uFreq.z + time) * uAmp.z -
218 | Math.pow(nsin(Math.PI * p * uFreq.w + time / (uFreq.z / uFreq.w)), 5) *
219 | uAmp.w;
220 |
221 | let distortion = new THREE.Vector3(
222 | getX(progress) - getX(progress + 0.007),
223 | getY(progress) - getY(progress + 0.007),
224 | 0
225 | );
226 | let lookAtAmp = new THREE.Vector3(-2, -5, 0);
227 | let lookAtOffset = new THREE.Vector3(0, 0, -10);
228 | return distortion.multiply(lookAtAmp).add(lookAtOffset);
229 | }
230 | };
231 |
232 | const turbulentDistortionStill = {
233 | uniforms: turbulentUniforms,
234 | getDistortion: `
235 | uniform vec4 uFreq;
236 | uniform vec4 uAmp;
237 | float nsin(float val){
238 | return sin(val) * 0.5+0.5;
239 | }
240 |
241 | #define PI 3.14159265358979
242 | float getDistortionX(float progress){
243 | return
244 | (
245 | cos( PI * progress * uFreq.r ) * uAmp.r +
246 | pow(cos(PI * progress * uFreq.g * (uFreq.g / uFreq.r)),2. )* uAmp.g
247 |
248 | );
249 | }
250 | float getDistortionY(float progress){
251 | return
252 | (
253 | -nsin( PI * progress * uFreq.b ) * uAmp.b +
254 | -pow(nsin(PI * progress * uFreq.a / (uFreq.b / uFreq.a) ),5.) * uAmp.a
255 |
256 | );
257 | }
258 | vec3 getDistortion(float progress){
259 | return vec3(
260 | getDistortionX(progress)-getDistortionX(0.02) ,
261 | getDistortionY(progress)- getDistortionY(0.02),
262 | 0.
263 | );
264 | }
265 | `
266 | };
267 |
268 | const deepDistortion = {
269 | uniforms: deepUniforms,
270 | getDistortion: `
271 | uniform vec4 uFreq;
272 | uniform vec4 uAmp;
273 | uniform vec2 uPowY;
274 | float nsin(float val){
275 | return sin(val) * 0.5+0.5;
276 | }
277 |
278 | #define PI 3.14159265358979
279 | float getDistortionX(float progress){
280 | return
281 | (
282 | sin(progress * PI * uFreq.x + uTime) * uAmp.x
283 |
284 | );
285 | }
286 | float getDistortionY(float progress){
287 | return
288 | (
289 | pow(abs(progress * uPowY.x),uPowY.y) + sin(progress * PI * uFreq.y + uTime) * uAmp.y
290 | );
291 | }
292 | vec3 getDistortion(float progress){
293 | return vec3(
294 | getDistortionX(progress)-getDistortionX(0.02) ,
295 | getDistortionY(progress)- getDistortionY(0.02),
296 | 0.
297 | );
298 | }
299 | `,
300 | getJS: (progress, time) => {
301 | const uFreq = deepUniforms.uFreq.value;
302 | const uAmp = deepUniforms.uAmp.value;
303 | const uPowY = deepUniforms.uPowY.value;
304 |
305 | const getX = p => Math.sin(p * Math.PI * uFreq.x + time) * uAmp.x;
306 | const getY = p =>
307 | Math.pow(p * uPowY.x, uPowY.y) +
308 | Math.sin(p * Math.PI * uFreq.y + time) * uAmp.y;
309 |
310 | let distortion = new THREE.Vector3(
311 | getX(progress) - getX(progress + 0.01),
312 | getY(progress) - getY(progress + 0.01),
313 | 0
314 | );
315 | let lookAtAmp = new THREE.Vector3(-2, -4, 0);
316 | let lookAtOffset = new THREE.Vector3(0, 0, -10);
317 | return distortion.multiply(lookAtAmp).add(lookAtOffset);
318 | }
319 | };
320 |
321 | const deepDistortionStill = {
322 | uniforms: deepUniforms,
323 | getDistortion: `
324 | uniform vec4 uFreq;
325 | uniform vec4 uAmp;
326 | uniform vec2 uPowY;
327 | float nsin(float val){
328 | return sin(val) * 0.5+0.5;
329 | }
330 |
331 | #define PI 3.14159265358979
332 | float getDistortionX(float progress){
333 | return
334 | (
335 | sin(progress * PI * uFreq.x ) * uAmp.x * 2.
336 |
337 | );
338 | }
339 | float getDistortionY(float progress){
340 | return
341 | (
342 | pow(abs(progress * uPowY.x),uPowY.y) + sin(progress * PI * uFreq.y ) * uAmp.y
343 | );
344 | }
345 | vec3 getDistortion(float progress){
346 | return vec3(
347 | getDistortionX(progress)-getDistortionX(0.02) ,
348 | getDistortionY(progress)- getDistortionY(0.05),
349 | 0.
350 | );
351 | }
352 | `
353 | };
354 | /**
355 |
356 | let tempUniforms ={};
357 | LongRacetempDistortion = {
358 | uniforms: tempUniforms,
359 | getDistortion: `
360 |
361 | #define PI 3.14159265358979
362 |
363 | vec3 getDistortion(float progress){
364 |
365 | float movementProgressFix = 0.02;
366 | return vec3(
367 | sin(progress * PI * 4.),
368 | 0.,
369 | 0.
370 | );
371 | }
372 | ` ,
373 | getJS: (progress,time)=>{
374 | let movementProgressFix = 0.02;
375 |
376 | // Uniforms
377 |
378 | let distortion = new THREE.Vector3(
379 | Math.sin(progress * Math.PI * 4.),
380 | 0.,
381 | 0.
382 | );
383 |
384 | let lookAtAmp = new THREE.Vector3(0.,0.,0.);
385 | let lookAtOffset = new THREE.Vector3(0.,0.,0.);
386 | return distortion.multiply(lookAtAmp).add(lookAtOffset);
387 | }
388 |
389 | }
390 |
391 |
392 | */
393 |
--------------------------------------------------------------------------------
/h5game/js/modernizr.js:
--------------------------------------------------------------------------------
1 | window.Modernizr=function(e,t,n){function r(e){b.cssText=e}function o(e,t){return r(S.join(e+";")+(t||""))}function a(e,t){return typeof e===t}function i(e,t){return!!~(""+e).indexOf(t)}function c(e,t){for(var r in e){var o=e[r];if(!i(o,"-")&&b[o]!==n)return"pfx"==t?o:!0}return!1}function s(e,t,r){for(var o in e){var i=t[e[o]];if(i!==n)return r===!1?e[o]:a(i,"function")?i.bind(r||t):i}return!1}function l(e,t,n){var r=e.charAt(0).toUpperCase()+e.slice(1),o=(e+" "+k.join(r+" ")+r).split(" ");return a(t,"string")||a(t,"undefined")?c(o,t):(o=(e+" "+T.join(r+" ")+r).split(" "),s(o,t,n))}function u(){m.input=function(n){for(var r=0,o=n.length;o>r;r++)M[n[r]]=n[r]in E;return M.list&&(M.list=!!t.createElement("datalist")&&!!e.HTMLDataListElement),M}("autocomplete autofocus list placeholder max min multiple pattern required step".split(" ")),m.inputtypes=function(e){for(var r,o,a,i=0,c=e.length;c>i;i++)E.setAttribute("type",o=e[i]),r="text"!==E.type,r&&(E.value=w,E.style.cssText="position:absolute;visibility:hidden;",/^range$/.test(o)&&E.style.WebkitAppearance!==n?(g.appendChild(E),a=t.defaultView,r=a.getComputedStyle&&"textfield"!==a.getComputedStyle(E,null).WebkitAppearance&&0!==E.offsetHeight,g.removeChild(E)):/^(search|tel)$/.test(o)||(r=/^(url|email)$/.test(o)?E.checkValidity&&E.checkValidity()===!1:E.value!=w)),P[e[i]]=!!r;return P}("search tel url email datetime date month week time datetime-local number range color".split(" "))}var f,d,p="2.8.3",m={},h=!0,g=t.documentElement,v="modernizr",y=t.createElement(v),b=y.style,E=t.createElement("input"),w=":)",x={}.toString,S=" -webkit- -moz- -o- -ms- ".split(" "),C="Webkit Moz O ms",k=C.split(" "),T=C.toLowerCase().split(" "),j={svg:"http://www.w3.org/2000/svg"},N={},P={},M={},A=[],L=A.slice,$=function(e,n,r,o){var a,i,c,s,l=t.createElement("div"),u=t.body,f=u||t.createElement("body");if(parseInt(r,10))for(;r--;)c=t.createElement("div"),c.id=o?o[r]:v+(r+1),l.appendChild(c);return a=["",'"].join(""),l.id=v,(u?l:f).innerHTML+=a,f.appendChild(l),u||(f.style.background="",f.style.overflow="hidden",s=g.style.overflow,g.style.overflow="hidden",g.appendChild(f)),i=n(l,e),u?l.parentNode.removeChild(l):(f.parentNode.removeChild(f),g.style.overflow=s),!!i},z=function(){function e(e,o){o=o||t.createElement(r[e]||"div"),e="on"+e;var i=e in o;return i||(o.setAttribute||(o=t.createElement("div")),o.setAttribute&&o.removeAttribute&&(o.setAttribute(e,""),i=a(o[e],"function"),a(o[e],"undefined")||(o[e]=n),o.removeAttribute(e))),o=null,i}var r={select:"input",change:"input",submit:"form",reset:"form",error:"img",load:"img",abort:"img"};return e}(),D={}.hasOwnProperty;d=a(D,"undefined")||a(D.call,"undefined")?function(e,t){return t in e&&a(e.constructor.prototype[t],"undefined")}:function(e,t){return D.call(e,t)},Function.prototype.bind||(Function.prototype.bind=function(e){var t=this;if("function"!=typeof t)throw new TypeError;var n=L.call(arguments,1),r=function(){if(this instanceof r){var o=function(){};o.prototype=t.prototype;var a=new o,i=t.apply(a,n.concat(L.call(arguments)));return Object(i)===i?i:a}return t.apply(e,n.concat(L.call(arguments)))};return r}),N.flexbox=function(){return l("flexWrap")},N.canvas=function(){var e=t.createElement("canvas");return!!e.getContext&&!!e.getContext("2d")},N.canvastext=function(){return!!m.canvas&&!!a(t.createElement("canvas").getContext("2d").fillText,"function")},N.webgl=function(){return!!e.WebGLRenderingContext},N.touch=function(){var n;return"ontouchstart"in e||e.DocumentTouch&&t instanceof DocumentTouch?n=!0:$(["@media (",S.join("touch-enabled),("),v,")","{#modernizr{top:9px;position:absolute}}"].join(""),function(e){n=9===e.offsetTop}),n},N.geolocation=function(){return"geolocation"in navigator},N.postmessage=function(){return!!e.postMessage},N.websqldatabase=function(){return!!e.openDatabase},N.indexedDB=function(){return!!l("indexedDB",e)},N.hashchange=function(){return z("hashchange",e)&&(t.documentMode===n||t.documentMode>7)},N.history=function(){return!!e.history&&!!history.pushState},N.draganddrop=function(){var e=t.createElement("div");return"draggable"in e||"ondragstart"in e&&"ondrop"in e},N.websockets=function(){return"WebSocket"in e||"MozWebSocket"in e},N.rgba=function(){return r("background-color:rgba(150,255,150,.5)"),i(b.backgroundColor,"rgba")},N.hsla=function(){return r("background-color:hsla(120,40%,100%,.5)"),i(b.backgroundColor,"rgba")||i(b.backgroundColor,"hsla")},N.multiplebgs=function(){return r("background:url(https://),url(https://),red url(https://)"),/(url\s*\(.*?){3}/.test(b.background)},N.backgroundsize=function(){return l("backgroundSize")},N.borderimage=function(){return l("borderImage")},N.borderradius=function(){return l("borderRadius")},N.boxshadow=function(){return l("boxShadow")},N.textshadow=function(){return""===t.createElement("div").style.textShadow},N.opacity=function(){return o("opacity:.55"),/^0.55$/.test(b.opacity)},N.cssanimations=function(){return l("animationName")},N.csscolumns=function(){return l("columnCount")},N.cssgradients=function(){var e="background-image:",t="gradient(linear,left top,right bottom,from(#9f9),to(white));",n="linear-gradient(left top,#9f9, white);";return r((e+"-webkit- ".split(" ").join(t+e)+S.join(n+e)).slice(0,-e.length)),i(b.backgroundImage,"gradient")},N.cssreflections=function(){return l("boxReflect")},N.csstransforms=function(){return!!l("transform")},N.csstransforms3d=function(){var e=!!l("perspective");return e&&"webkitPerspective"in g.style&&$("@media (transform-3d),(-webkit-transform-3d){#modernizr{left:9px;position:absolute;height:3px;}}",function(t){e=9===t.offsetLeft&&3===t.offsetHeight}),e},N.csstransitions=function(){return l("transition")},N.fontface=function(){var e;return $('@font-face {font-family:"font";src:url("https://")}',function(n,r){var o=t.getElementById("smodernizr"),a=o.sheet||o.styleSheet,i=a?a.cssRules&&a.cssRules[0]?a.cssRules[0].cssText:a.cssText||"":"";e=/src/i.test(i)&&0===i.indexOf(r.split(" ")[0])}),e},N.generatedcontent=function(){var e;return $(["#",v,"{font:0/0 a}#",v,':after{content:"',w,'";visibility:hidden;font:3px/1 a}'].join(""),function(t){e=t.offsetHeight>=3}),e},N.video=function(){var e=t.createElement("video"),n=!1;try{(n=!!e.canPlayType)&&(n=new Boolean(n),n.ogg=e.canPlayType('video/ogg; codecs="theora"').replace(/^no$/,""),n.h264=e.canPlayType('video/mp4; codecs="avc1.42E01E"').replace(/^no$/,""),n.webm=e.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/,""))}catch(r){}return n},N.audio=function(){var e=t.createElement("audio"),n=!1;try{(n=!!e.canPlayType)&&(n=new Boolean(n),n.ogg=e.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),n.mp3=e.canPlayType("audio/mpeg;").replace(/^no$/,""),n.wav=e.canPlayType('audio/wav; codecs="1"').replace(/^no$/,""),n.m4a=(e.canPlayType("audio/x-m4a;")||e.canPlayType("audio/aac;")).replace(/^no$/,""))}catch(r){}return n},N.localstorage=function(){try{return localStorage.setItem(v,v),localStorage.removeItem(v),!0}catch(e){return!1}},N.sessionstorage=function(){try{return sessionStorage.setItem(v,v),sessionStorage.removeItem(v),!0}catch(e){return!1}},N.webworkers=function(){return!!e.Worker},N.applicationcache=function(){return!!e.applicationCache},N.svg=function(){return!!t.createElementNS&&!!t.createElementNS(j.svg,"svg").createSVGRect},N.inlinesvg=function(){var e=t.createElement("div");return e.innerHTML="",(e.firstChild&&e.firstChild.namespaceURI)==j.svg},N.smil=function(){return!!t.createElementNS&&/SVGAnimate/.test(x.call(t.createElementNS(j.svg,"animate")))},N.svgclippaths=function(){return!!t.createElementNS&&/SVGClipPath/.test(x.call(t.createElementNS(j.svg,"clipPath")))};for(var F in N)d(N,F)&&(f=F.toLowerCase(),m[f]=N[F](),A.push((m[f]?"":"no-")+f));return m.input||u(),m.addTest=function(e,t){if("object"==typeof e)for(var r in e)d(e,r)&&m.addTest(r,e[r]);else{if(e=e.toLowerCase(),m[e]!==n)return m;t="function"==typeof t?t():t,"undefined"!=typeof h&&h&&(g.className+=" "+(t?"":"no-")+e),m[e]=t}return m},r(""),y=E=null,function(e,t){function n(e,t){var n=e.createElement("p"),r=e.getElementsByTagName("head")[0]||e.documentElement;return n.innerHTML="x",r.insertBefore(n.lastChild,r.firstChild)}function r(){var e=y.elements;return"string"==typeof e?e.split(" "):e}function o(e){var t=v[e[h]];return t||(t={},g++,e[h]=g,v[g]=t),t}function a(e,n,r){if(n||(n=t),u)return n.createElement(e);r||(r=o(n));var a;return a=r.cache[e]?r.cache[e].cloneNode():m.test(e)?(r.cache[e]=r.createElem(e)).cloneNode():r.createElem(e),!a.canHaveChildren||p.test(e)||a.tagUrn?a:r.frag.appendChild(a)}function i(e,n){if(e||(e=t),u)return e.createDocumentFragment();n=n||o(e);for(var a=n.frag.cloneNode(),i=0,c=r(),s=c.length;s>i;i++)a.createElement(c[i]);return a}function c(e,t){t.cache||(t.cache={},t.createElem=e.createElement,t.createFrag=e.createDocumentFragment,t.frag=t.createFrag()),e.createElement=function(n){return y.shivMethods?a(n,e,t):t.createElem(n)},e.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+r().join().replace(/[\w\-]+/g,function(e){return t.createElem(e),t.frag.createElement(e),'c("'+e+'")'})+");return n}")(y,t.frag)}function s(e){e||(e=t);var r=o(e);return y.shivCSS&&!l&&!r.hasCSS&&(r.hasCSS=!!n(e,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")),u||c(e,r),e}var l,u,f="3.7.0",d=e.html5||{},p=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,m=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,h="_html5shiv",g=0,v={};!function(){try{var e=t.createElement("a");e.innerHTML="",l="hidden"in e,u=1==e.childNodes.length||function(){t.createElement("a");var e=t.createDocumentFragment();return"undefined"==typeof e.cloneNode||"undefined"==typeof e.createDocumentFragment||"undefined"==typeof e.createElement}()}catch(n){l=!0,u=!0}}();var y={elements:d.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output progress section summary template time video",version:f,shivCSS:d.shivCSS!==!1,supportsUnknownElements:u,shivMethods:d.shivMethods!==!1,type:"default",shivDocument:s,createElement:a,createDocumentFragment:i};e.html5=y,s(t)}(this,t),m._version=p,m._prefixes=S,m._domPrefixes=T,m._cssomPrefixes=k,m.hasEvent=z,m.testProp=function(e){return c([e])},m.testAllProps=l,m.testStyles=$,m.prefixed=function(e,t,n){return t?l(e,t,n):l(e,"pfx")},g.className=g.className.replace(/(^|\s)no-js(\s|$)/,"$1$2")+(h?" js "+A.join(" "):""),m}(this,this.document),function(e,t,n){function r(e){return"[object Function]"==g.call(e)}function o(e){return"string"==typeof e}function a(){}function i(e){return!e||"loaded"==e||"complete"==e||"uninitialized"==e}function c(){var e=v.shift();y=1,e?e.t?m(function(){("c"==e.t?d.injectCss:d.injectJs)(e.s,0,e.a,e.x,e.e,1)},0):(e(),c()):y=0}function s(e,n,r,o,a,s,l){function u(t){if(!p&&i(f.readyState)&&(b.r=p=1,!y&&c(),f.onload=f.onreadystatechange=null,t)){"img"!=e&&m(function(){w.removeChild(f)},50);for(var r in T[n])T[n].hasOwnProperty(r)&&T[n][r].onload()}}var l=l||d.errorTimeout,f=t.createElement(e),p=0,g=0,b={t:r,s:n,e:a,a:s,x:l};1===T[n]&&(g=1,T[n]=[]),"object"==e?f.data=n:(f.src=n,f.type=e),f.width=f.height="0",f.onerror=f.onload=f.onreadystatechange=function(){u.call(this,g)},v.splice(o,0,b),"img"!=e&&(g||2===T[n]?(w.insertBefore(f,E?null:h),m(u,l)):T[n].push(f))}function l(e,t,n,r,a){return y=0,t=t||"j",o(e)?s("c"==t?S:x,e,t,this.i++,n,r,a):(v.splice(this.i++,0,e),1==v.length&&c()),this}function u(){var e=d;return e.loader={load:l,i:0},e}var f,d,p=t.documentElement,m=e.setTimeout,h=t.getElementsByTagName("script")[0],g={}.toString,v=[],y=0,b="MozAppearance"in p.style,E=b&&!!t.createRange().compareNode,w=E?p:h.parentNode,p=e.opera&&"[object Opera]"==g.call(e.opera),p=!!t.attachEvent&&!p,x=b?"object":p?"script":"img",S=p?"script":x,C=Array.isArray||function(e){return"[object Array]"==g.call(e)},k=[],T={},j={timeout:function(e,t){return t.length&&(e.timeout=t[0]),e}};d=function(e){function t(e){var t,n,r,e=e.split("!"),o=k.length,a=e.pop(),i=e.length,a={url:a,origUrl:a,prefixes:e};for(n=0;i>n;n++)r=e[n].split("="),(t=j[r.shift()])&&(a=t(a,r));for(n=0;o>n;n++)a=k[n](a);return a}function i(e,o,a,i,c){var s=t(e),l=s.autoCallback;s.url.split(".").pop().split("?").shift(),s.bypass||(o&&(o=r(o)?o:o[e]||o[i]||o[e.split("/").pop().split("?")[0]]),s.instead?s.instead(e,o,a,i,c):(T[s.url]?s.noexec=!0:T[s.url]=1,a.load(s.url,s.forceCSS||!s.forceJS&&"css"==s.url.split(".").pop().split("?").shift()?"c":n,s.noexec,s.attrs,s.timeout),(r(o)||r(l))&&a.load(function(){u(),o&&o(s.origUrl,c,i),l&&l(s.origUrl,c,i),T[s.url]=2})))}function c(e,t){function n(e,n){if(e){if(o(e))n||(f=function(){var e=[].slice.call(arguments);d.apply(this,e),p()}),i(e,f,t,0,l);else if(Object(e)===e)for(s in c=function(){var t,n=0;for(t in e)e.hasOwnProperty(t)&&n++;return n}(),e)e.hasOwnProperty(s)&&(!n&&!--c&&(r(f)?f=function(){var e=[].slice.call(arguments);d.apply(this,e),p()}:f[s]=function(e){return function(){var t=[].slice.call(arguments);e&&e.apply(this,t),p()}}(d[s])),i(e[s],f,t,s,l))}else!n&&p()}var c,s,l=!!e.test,u=e.load||e.both,f=e.callback||a,d=f,p=e.complete||a;n(l?e.yep:e.nope,!!u),u&&n(u)}var s,l,f=this.yepnope.loader;if(o(e))i(e,0,f,0);else if(C(e))for(s=0;s= 3 ) this._string[this._positions[2]] = pz - this._oz;
244 | return this;
245 | },
246 |
247 | /////////////////////////////////////////////
248 | //////////// Position / relative ////////////
249 | /////////////////////////////////////////////
250 | move : function(px,py,pz) {
251 | this._string[this._positions[0]] += px;
252 | this._string[this._positions[1]] += py;
253 | if ( arguments.length >= 3 ) this._string[this._positions[2]] += pz;
254 | return this;
255 | },
256 |
257 | /////////////////////////////////////////////
258 | //////////// Rotation / absolute ////////////
259 | /////////////////////////////////////////////
260 | rotationX : function(rx) {
261 | if ( arguments.length ) {
262 | this._string[this._positions[3]] = rx;
263 | return this;
264 | } else {
265 | return this._string[this._positions[3]];
266 | }
267 | },
268 | rotationY : function(ry) {
269 | if ( arguments.length ) {
270 | this._string[this._positions[4]] = ry;
271 | return this;
272 | } else {
273 | return this._string[this._positions[4]];
274 | }
275 | },
276 | rotationZ : function(rz) {
277 | if ( arguments.length ) {
278 | this._string[this._positions[5]] = rz;
279 | return this;
280 | } else {
281 | return this._string[this._positions[5]];
282 | }
283 | },
284 | rotation : function(rx,ry,rz) {
285 | this._string[this._positions[3]] = rx;
286 | this._string[this._positions[4]] = ry;
287 | this._string[this._positions[5]] = rz;
288 | return this;
289 | },
290 |
291 | /////////////////////////////////////////////
292 | //////////// Rotation / relative ////////////
293 | /////////////////////////////////////////////
294 | rotate : function(rx,ry,rz) {
295 | this._string[this._positions[3]] += rx;
296 | this._string[this._positions[4]] += ry;
297 | this._string[this._positions[5]] += rz;
298 | return this;
299 | },
300 |
301 | /////////////////////////////////////////////
302 | ///////////////// Scale //////////////////
303 | /////////////////////////////////////////////
304 | scaleX : function(sx) {
305 | if ( arguments.length ) {
306 | this._string[this._positions[6]] = sx;
307 | return this;
308 | } else {
309 | return this._string[this._positions[6]];
310 | }
311 | },
312 | scaleY : function(sy) {
313 | if ( arguments.length ) {
314 | this._string[this._positions[7]] = sy;
315 | return this;
316 | } else {
317 | return this._string[this._positions[7]];
318 | }
319 | },
320 | scaleZ : function(sz) {
321 | if ( arguments.length ) {
322 | this._string[this._positions[8]] = sz;
323 | return this;
324 | } else {
325 | return this._string[this._positions[8]];
326 | }
327 | },
328 | scale : function(sx,sy,sz) {
329 | switch(arguments.length){
330 | case 0:
331 | return this._string[this._positions[6]];
332 | case 1:
333 | this._string[this._positions[6]] = sx;
334 | this._string[this._positions[7]] = sx;
335 | this._string[this._positions[8]] = sx;
336 | return this;
337 | case 2:
338 | this._string[this._positions[6]] = sx;
339 | this._string[this._positions[7]] = sy;
340 | //this._string[this._positions[8]] = 1;
341 | return this;
342 | case 3:
343 | this._string[this._positions[6]] = sx;
344 | this._string[this._positions[7]] = sy;
345 | this._string[this._positions[8]] = sz;
346 | return this;
347 | }
348 | return this;
349 | },
350 |
351 | /////////////////////////////////////////////
352 | ///////////////// Origin //////////////////
353 | /////////////////////////////////////////////
354 | origin : function(ox,oy,oz) {
355 | // failed attempt at auto-centering the registration point of the object
356 | if ( typeof(ox) === "string" ) {
357 | /*
358 | switch(ox){
359 | case "center":
360 | this._string[this._positions[0]] = -this.offsetWidth>>1;
361 | this._string[this._positions[1]] = -this.offsetHeight>>1;
362 | debugger
363 | console.log("centering");
364 | break;
365 | }
366 | */
367 | var cs = window.getComputedStyle(this,null);
368 | console.log(cs);
369 | console.log("w:"+ cs.getPropertyValue("width") + " || h: " + cs.height );
370 | } else {
371 | if (arguments.length<3) oz = 0;
372 | this._string[this._positions[0]] += this._ox - ox;
373 | this._string[this._positions[1]] += this._oy - oy;
374 | this._string[this._positions[2]] += this._oz - oz;
375 | this._ox = ox;
376 | this._oy = oy;
377 | this._oz = oz;
378 | }
379 | return this;
380 | },
381 |
382 | /////////////////////////////////////////////
383 | //////////// Transform Origin /////////////
384 | /////////////////////////////////////////////
385 | transformOrigin : function(tx,ty) {
386 | this.style[ Sprite3D._browserPrefix + "TransformOrigin" ] = (Number(tx)?tx+"px":tx) + " " + (Number(ty)?ty+"px":ty);
387 | return this;
388 | },
389 |
390 | /////////////////////////////////////////////
391 | //////////// Transform String /////////////
392 | /////////////////////////////////////////////
393 | transformString : function(s) {
394 | var parts = s.toLowerCase().split(" "),
395 | numParts = parts.length,
396 | i = 0,
397 | strings = [],
398 | positions = [ 0,0,0, 0,0,0, 0,0,0 ],
399 | n = 0;
400 |
401 | for(i;i {
109 | const manager = new THREE.LoadingManager(resolve);
110 |
111 | const searchImage = new Image();
112 | const areaImage = new Image();
113 | assets.smaa = {};
114 | searchImage.addEventListener("load", function() {
115 | assets.smaa.search = this;
116 | manager.itemEnd("smaa-search");
117 | });
118 |
119 | areaImage.addEventListener("load", function() {
120 | assets.smaa.area = this;
121 | manager.itemEnd("smaa-area");
122 | });
123 | manager.itemStart("smaa-search");
124 | manager.itemStart("smaa-area");
125 |
126 | searchImage.src = POSTPROCESSING.SMAAEffect.searchImageDataURL;
127 | areaImage.src = POSTPROCESSING.SMAAEffect.areaImageDataURL;
128 | });
129 | }
130 | init() {
131 | this.initPasses();
132 | const options = this.options;
133 | this.road.init();
134 | this.leftCarLights.init();
135 |
136 | this.leftCarLights.mesh.position.setX(
137 | -options.roadWidth / 2 - options.islandWidth / 2
138 | );
139 | this.rightCarLights.init();
140 | this.rightCarLights.mesh.position.setX(
141 | options.roadWidth / 2 + options.islandWidth / 2
142 | );
143 | this.leftSticks.init();
144 | this.leftSticks.mesh.position.setX(
145 | -(options.roadWidth + options.islandWidth / 2)
146 | );
147 |
148 | this.container.addEventListener("mousedown", this.onMouseDown);
149 | this.container.addEventListener("mouseup", this.onMouseUp);
150 | this.container.addEventListener("mouseout", this.onMouseUp);
151 |
152 | this.tick();
153 | }
154 | onMouseDown(ev) {
155 | if (this.options.onSpeedUp) this.options.onSpeedUp(ev);
156 | this.fovTarget = this.options.fovSpeedUp;
157 | this.speedUpTarget = this.options.speedUp;
158 | }
159 | onMouseUp(ev) {
160 | if (this.options.onSlowDown) this.options.onSlowDown(ev);
161 | this.fovTarget = this.options.fov;
162 | this.speedUpTarget = 0;
163 | // this.speedupLerp = 0.1;
164 | }
165 | update(delta) {
166 | let lerpPercentage = Math.exp(-(-60 * Math.log2(1 - 0.1)) * delta);
167 | this.speedUp += lerp(
168 | this.speedUp,
169 | this.speedUpTarget,
170 | lerpPercentage,
171 | 0.00001
172 | );
173 | this.timeOffset += this.speedUp * delta;
174 |
175 | let time = this.clock.elapsedTime + this.timeOffset;
176 |
177 | this.rightCarLights.update(time);
178 | this.leftCarLights.update(time);
179 | this.leftSticks.update(time);
180 | this.road.update(time);
181 |
182 | let updateCamera = false;
183 | let fovChange = lerp(this.camera.fov, this.fovTarget, lerpPercentage);
184 | if (fovChange !== 0) {
185 | this.camera.fov += fovChange * delta * 6;
186 | updateCamera = true;
187 | }
188 |
189 | if (this.options.distortion.getJS) {
190 | const distortion = this.options.distortion.getJS(0.025, time);
191 |
192 | this.camera.lookAt(
193 | new THREE.Vector3(
194 | this.camera.position.x + distortion.x,
195 | this.camera.position.y + distortion.y,
196 | this.camera.position.z + distortion.z
197 | )
198 | );
199 | updateCamera = true;
200 | }
201 | if (updateCamera) {
202 | this.camera.updateProjectionMatrix();
203 | }
204 | }
205 | render(delta) {
206 | this.composer.render(delta);
207 | }
208 | dispose() {
209 | this.disposed = true;
210 | }
211 | setSize(width, height, updateStyles) {
212 | this.composer.setSize(width, height, updateStyles);
213 | }
214 | tick() {
215 | if (this.disposed || !this) return;
216 | if (resizeRendererToDisplaySize(this.renderer, this.setSize)) {
217 | const canvas = this.renderer.domElement;
218 | this.camera.aspect = canvas.clientWidth / canvas.clientHeight;
219 | this.camera.updateProjectionMatrix();
220 | }
221 | const delta = this.clock.getDelta();
222 | this.render(delta);
223 | this.update(delta);
224 | requestAnimationFrame(this.tick);
225 | }
226 | }
227 |
228 | const distortion_uniforms = {
229 | uDistortionX: new THREE.Uniform(new THREE.Vector2(80, 3)),
230 | uDistortionY: new THREE.Uniform(new THREE.Vector2(-40, 2.5))
231 | };
232 |
233 | const distortion_vertex = `
234 | #define PI 3.14159265358979
235 | uniform vec2 uDistortionX;
236 | uniform vec2 uDistortionY;
237 |
238 | float nsin(float val){
239 | return sin(val) * 0.5+0.5;
240 | }
241 | vec3 getDistortion(float progress){
242 | progress = clamp(progress, 0.,1.);
243 | float xAmp = uDistortionX.r;
244 | float xFreq = uDistortionX.g;
245 | float yAmp = uDistortionY.r;
246 | float yFreq = uDistortionY.g;
247 | return vec3(
248 | xAmp * nsin(progress* PI * xFreq - PI / 2. ) ,
249 | yAmp * nsin(progress * PI *yFreq - PI / 2. ) ,
250 | 0.
251 | );
252 | }
253 | `;
254 |
255 | const random = base => {
256 | if (Array.isArray(base)) return Math.random() * (base[1] - base[0]) + base[0];
257 | return Math.random() * base;
258 | };
259 | const pickRandom = arr => {
260 | if (Array.isArray(arr)) return arr[Math.floor(Math.random() * arr.length)];
261 | return arr;
262 | };
263 | function lerp(current, target, speed = 0.1, limit = 0.001) {
264 | let change = (target - current) * speed;
265 | if (Math.abs(change) < limit) {
266 | change = target - current;
267 | }
268 | return change;
269 | }
270 | class CarLights {
271 | constructor(webgl, options, colors, speed, fade) {
272 | this.webgl = webgl;
273 | this.options = options;
274 | this.colors = colors;
275 | this.speed = speed;
276 | this.fade = fade;
277 | }
278 | init() {
279 | const options = this.options;
280 | // Curve with length 1
281 | let curve = new THREE.LineCurve3(
282 | new THREE.Vector3(0, 0, 0),
283 | new THREE.Vector3(0, 0, -1)
284 | );
285 | // Tube with radius = 1
286 | let geometry = new THREE.TubeBufferGeometry(curve, 40, 1, 8, false);
287 |
288 | let instanced = new THREE.InstancedBufferGeometry().copy(geometry);
289 | instanced.maxInstancedCount = options.lightPairsPerRoadWay * 2;
290 |
291 | let laneWidth = options.roadWidth / options.lanesPerRoad;
292 |
293 | let aOffset = [];
294 | let aMetrics = [];
295 | let aColor = [];
296 |
297 | let colors = this.colors;
298 | if (Array.isArray(colors)) {
299 | colors = colors.map(c => new THREE.Color(c));
300 | } else {
301 | colors = new THREE.Color(colors);
302 | }
303 |
304 | for (let i = 0; i < options.lightPairsPerRoadWay; i++) {
305 | let radius = random(options.carLightsRadius);
306 | let length = random(options.carLightsLength);
307 | let speed = random(this.speed);
308 |
309 | let carLane = i % 3;
310 | let laneX = carLane * laneWidth - options.roadWidth / 2 + laneWidth / 2;
311 |
312 | let carWidth = random(options.carWidthPercentage) * laneWidth;
313 | // Drunk Driving
314 | let carShiftX = random(options.carShiftX) * laneWidth;
315 | // Both lights share same shiftX and lane;
316 | laneX += carShiftX;
317 |
318 | let offsetY = random(options.carFloorSeparation) + radius * 1.3;
319 |
320 | let offsetZ = -random(options.length);
321 |
322 | aOffset.push(laneX - carWidth / 2);
323 | aOffset.push(offsetY);
324 | aOffset.push(offsetZ);
325 |
326 | aOffset.push(laneX + carWidth / 2);
327 | aOffset.push(offsetY);
328 | aOffset.push(offsetZ);
329 |
330 | aMetrics.push(radius);
331 | aMetrics.push(length);
332 | aMetrics.push(speed);
333 |
334 | aMetrics.push(radius);
335 | aMetrics.push(length);
336 | aMetrics.push(speed);
337 |
338 | let color = pickRandom(colors);
339 | aColor.push(color.r);
340 | aColor.push(color.g);
341 | aColor.push(color.b);
342 |
343 | aColor.push(color.r);
344 | aColor.push(color.g);
345 | aColor.push(color.b);
346 | }
347 | instanced.addAttribute(
348 | "aOffset",
349 | new THREE.InstancedBufferAttribute(new Float32Array(aOffset), 3, false)
350 | );
351 | instanced.addAttribute(
352 | "aMetrics",
353 | new THREE.InstancedBufferAttribute(new Float32Array(aMetrics), 3, false)
354 | );
355 | instanced.addAttribute(
356 | "aColor",
357 | new THREE.InstancedBufferAttribute(new Float32Array(aColor), 3, false)
358 | );
359 | let material = new THREE.ShaderMaterial({
360 | fragmentShader: carLightsFragment,
361 | vertexShader: carLightsVertex,
362 | transparent: true,
363 | uniforms: Object.assign(
364 | {
365 | // uColor: new THREE.Uniform(new THREE.Color(this.color)),
366 | uTime: new THREE.Uniform(0),
367 | uTravelLength: new THREE.Uniform(options.length),
368 | uFade: new THREE.Uniform(this.fade)
369 | },
370 | this.webgl.fogUniforms,
371 | options.distortion.uniforms
372 | )
373 | });
374 | material.onBeforeCompile = shader => {
375 | shader.vertexShader = shader.vertexShader.replace(
376 | "#include ",
377 | options.distortion.getDistortion
378 | );
379 | console.log(shader.vertex);
380 | };
381 | let mesh = new THREE.Mesh(instanced, material);
382 | mesh.frustumCulled = false;
383 | this.webgl.scene.add(mesh);
384 | this.mesh = mesh;
385 | }
386 | update(time) {
387 | this.mesh.material.uniforms.uTime.value = time;
388 | }
389 | }
390 |
391 | const carLightsFragment = `
392 |
393 | #define USE_FOG;
394 | ${THREE.ShaderChunk["fog_pars_fragment"]}
395 | varying vec3 vColor;
396 | varying vec2 vUv;
397 | uniform vec2 uFade;
398 | void main() {
399 | vec3 color = vec3(vColor);
400 | float fadeStart = 0.4;
401 | float maxFade = 0.;
402 | float alpha = 1.;
403 |
404 | alpha = smoothstep(uFade.x, uFade.y, vUv.x);
405 | gl_FragColor = vec4(color,alpha);
406 | if (gl_FragColor.a < 0.0001) discard;
407 | ${THREE.ShaderChunk["fog_fragment"]}
408 | }
409 | `;
410 |
411 | const carLightsVertex = `
412 | #define USE_FOG;
413 | ${THREE.ShaderChunk["fog_pars_vertex"]}
414 | attribute vec3 aOffset;
415 | attribute vec3 aMetrics;
416 | attribute vec3 aColor;
417 |
418 |
419 |
420 | uniform float uTravelLength;
421 | uniform float uTime;
422 | uniform float uSpeed;
423 |
424 | varying vec2 vUv;
425 | varying vec3 vColor;
426 | #include
427 |
428 | void main() {
429 | vec3 transformed = position.xyz;
430 | float radius = aMetrics.r;
431 | float myLength = aMetrics.g;
432 | float speed = aMetrics.b;
433 |
434 | transformed.xy *= radius ;
435 | transformed.z *= myLength;
436 |
437 | // Add my length to make sure it loops after the lights hits the end
438 | transformed.z += myLength-mod( uTime *speed + aOffset.z, uTravelLength);
439 | transformed.xy += aOffset.xy;
440 |
441 |
442 | float progress = abs(transformed.z / uTravelLength);
443 | transformed.xyz += getDistortion(progress);
444 |
445 | vec4 mvPosition = modelViewMatrix * vec4(transformed,1.);
446 | gl_Position = projectionMatrix * mvPosition;
447 | vUv = uv;
448 | vColor = aColor;
449 | ${THREE.ShaderChunk["fog_vertex"]}
450 | }`;
451 |
452 | class LightsSticks {
453 | constructor(webgl, options) {
454 | this.webgl = webgl;
455 | this.options = options;
456 | }
457 | init() {
458 | const options = this.options;
459 | const geometry = new THREE.PlaneBufferGeometry(1, 1);
460 | let instanced = new THREE.InstancedBufferGeometry().copy(geometry);
461 | let totalSticks = options.totalSideLightSticks;
462 | instanced.maxInstancedCount = totalSticks;
463 |
464 | let stickoffset = options.length / (totalSticks - 1);
465 | const aOffset = [];
466 | const aColor = [];
467 | const aMetrics = [];
468 |
469 | let colors = options.colors.sticks;
470 | if (Array.isArray(colors)) {
471 | colors = colors.map(c => new THREE.Color(c));
472 | } else {
473 | colors = new THREE.Color(colors);
474 | }
475 |
476 | for (let i = 0; i < totalSticks; i++) {
477 | let width = random(options.lightStickWidth);
478 | let height = random(options.lightStickHeight);
479 | aOffset.push((i - 1) * stickoffset * 2 + stickoffset * Math.random());
480 |
481 | let color = pickRandom(colors);
482 | aColor.push(color.r);
483 | aColor.push(color.g);
484 | aColor.push(color.b);
485 |
486 | aMetrics.push(width);
487 | aMetrics.push(height);
488 | }
489 | instanced.addAttribute(
490 | "aOffset",
491 | new THREE.InstancedBufferAttribute(new Float32Array(aOffset), 1, false)
492 | );
493 | instanced.addAttribute(
494 | "aColor",
495 | new THREE.InstancedBufferAttribute(new Float32Array(aColor), 3, false)
496 | );
497 | instanced.addAttribute(
498 | "aMetrics",
499 | new THREE.InstancedBufferAttribute(new Float32Array(aMetrics), 2, false)
500 | );
501 | const material = new THREE.ShaderMaterial({
502 | fragmentShader: sideSticksFragment,
503 | vertexShader: sideSticksVertex,
504 | // This ones actually need double side
505 | side: THREE.DoubleSide,
506 | uniforms: Object.assign(
507 | {
508 | uTravelLength: new THREE.Uniform(options.length),
509 | uTime: new THREE.Uniform(0)
510 | },
511 | this.webgl.fogUniforms,
512 | options.distortion.uniforms
513 | )
514 | });
515 |
516 | material.onBeforeCompile = shader => {
517 | shader.vertexShader = shader.vertexShader.replace(
518 | "#include ",
519 | options.distortion.getDistortion
520 | );
521 | };
522 |
523 | const mesh = new THREE.Mesh(instanced, material);
524 | // The object is behind the camera before the vertex shader
525 | mesh.frustumCulled = false;
526 | // mesh.position.y = options.lightStickHeight / 2;
527 | this.webgl.scene.add(mesh);
528 | this.mesh = mesh;
529 | }
530 | update(time) {
531 | this.mesh.material.uniforms.uTime.value = time;
532 | }
533 | }
534 |
535 | const sideSticksVertex = `
536 | #define USE_FOG;
537 | ${THREE.ShaderChunk["fog_pars_vertex"]}
538 | attribute float aOffset;
539 | attribute vec3 aColor;
540 |
541 | attribute vec2 aMetrics;
542 |
543 | uniform float uTravelLength;
544 | uniform float uTime;
545 |
546 | varying vec3 vColor;
547 | mat4 rotationY( in float angle ) {
548 | return mat4( cos(angle), 0, sin(angle), 0,
549 | 0, 1.0, 0, 0,
550 | -sin(angle), 0, cos(angle), 0,
551 | 0, 0, 0, 1);
552 | }
553 |
554 |
555 |
556 | #include
557 | void main(){
558 | vec3 transformed = position.xyz;
559 | float width = aMetrics.x;
560 | float height = aMetrics.y;
561 |
562 | transformed.xy *= vec2(width,height);
563 | float time = mod(uTime * 60. *2. + aOffset , uTravelLength);
564 |
565 | transformed = (rotationY(3.14/2.) * vec4(transformed,1.)).xyz;
566 |
567 | transformed.z += - uTravelLength + time;
568 |
569 |
570 | float progress = abs(transformed.z / uTravelLength);
571 | transformed.xyz += getDistortion(progress);
572 |
573 | transformed.y += height /2.;
574 | transformed.x += -width/2.;
575 | vec4 mvPosition = modelViewMatrix * vec4(transformed,1.);
576 | gl_Position = projectionMatrix * mvPosition;
577 | vColor = aColor;
578 | ${THREE.ShaderChunk["fog_vertex"]}
579 | }
580 | `;
581 | const sideSticksFragment = `
582 | #define USE_FOG;
583 | ${THREE.ShaderChunk["fog_pars_fragment"]}
584 | varying vec3 vColor;
585 | void main(){
586 | vec3 color = vec3(vColor);
587 | gl_FragColor = vec4(color,1.);
588 | ${THREE.ShaderChunk["fog_fragment"]}
589 | }
590 | `;
591 |
592 | class Road {
593 | constructor(webgl, options) {
594 | this.webgl = webgl;
595 | this.options = options;
596 |
597 | this.uTime = new THREE.Uniform(0);
598 | }
599 | createIsland() {
600 | const options = this.options;
601 | let segments = 100;
602 | }
603 | // Side = 0 center, = 1 right = -1 left
604 | createPlane(side, width, isRoad) {
605 | const options = this.options;
606 | let segments = 100;
607 | const geometry = new THREE.PlaneBufferGeometry(
608 | isRoad ? options.roadWidth : options.islandWidth,
609 | options.length,
610 | 20,
611 | segments
612 | );
613 | let uniforms = {
614 | uTravelLength: new THREE.Uniform(options.length),
615 | uColor: new THREE.Uniform(
616 | new THREE.Color(
617 | isRoad ? options.colors.roadColor : options.colors.islandColor
618 | )
619 | ),
620 | uTime: this.uTime
621 | };
622 | if (isRoad) {
623 | uniforms = Object.assign(uniforms, {
624 | uLanes: new THREE.Uniform(options.lanesPerRoad),
625 | uBrokenLinesColor: new THREE.Uniform(
626 | new THREE.Color(options.colors.brokenLines)
627 | ),
628 | uShoulderLinesColor: new THREE.Uniform(
629 | new THREE.Color(options.colors.shoulderLines)
630 | ),
631 | uShoulderLinesWidthPercentage: new THREE.Uniform(
632 | options.shoulderLinesWidthPercentage
633 | ),
634 | uBrokenLinesLengthPercentage: new THREE.Uniform(
635 | options.brokenLinesLengthPercentage
636 | ),
637 | uBrokenLinesWidthPercentage: new THREE.Uniform(
638 | options.brokenLinesWidthPercentage
639 | )
640 | });
641 | }
642 | const material = new THREE.ShaderMaterial({
643 | fragmentShader: isRoad ? roadFragment : islandFragment,
644 | vertexShader: roadVertex,
645 | side: THREE.DoubleSide,
646 | uniforms: Object.assign(
647 | uniforms,
648 | this.webgl.fogUniforms,
649 | options.distortion.uniforms
650 | )
651 | });
652 |
653 | material.onBeforeCompile = shader => {
654 | shader.vertexShader = shader.vertexShader.replace(
655 | "#include ",
656 | options.distortion.getDistortion
657 | );
658 | };
659 | const mesh = new THREE.Mesh(geometry, material);
660 | mesh.rotation.x = -Math.PI / 2;
661 | // Push it half further away
662 | mesh.position.z = -options.length / 2;
663 | mesh.position.x +=
664 | (this.options.islandWidth / 2 + options.roadWidth / 2) * side;
665 | this.webgl.scene.add(mesh);
666 |
667 | return mesh;
668 | }
669 | init() {
670 | this.leftRoadWay = this.createPlane(-1, this.options.roadWidth, true);
671 | this.rightRoadWay = this.createPlane(1, this.options.roadWidth, true);
672 | this.island = this.createPlane(0, this.options.islandWidth, false);
673 | }
674 | update(time) {
675 | this.uTime.value = time;
676 | }
677 | }
678 |
679 | const roadBaseFragment = `
680 | #define USE_FOG;
681 | varying vec2 vUv;
682 | uniform vec3 uColor;
683 | uniform float uTime;
684 | #include
685 | ${THREE.ShaderChunk["fog_pars_fragment"]}
686 | void main() {
687 | vec2 uv = vUv;
688 | vec3 color = vec3(uColor);
689 |
690 | #include
691 |
692 | gl_FragColor = vec4(color,1.);
693 | ${THREE.ShaderChunk["fog_fragment"]}
694 | }
695 | `;
696 | const islandFragment = roadBaseFragment
697 | .replace("#include ", "")
698 | .replace("#include ", "");
699 | const roadMarkings_vars = `
700 | uniform float uLanes;
701 | uniform vec3 uBrokenLinesColor;
702 | uniform vec3 uShoulderLinesColor;
703 | uniform float uShoulderLinesWidthPercentage;
704 | uniform float uBrokenLinesWidthPercentage;
705 | uniform float uBrokenLinesLengthPercentage;
706 | highp float random(vec2 co)
707 | {
708 | highp float a = 12.9898;
709 | highp float b = 78.233;
710 | highp float c = 43758.5453;
711 | highp float dt= dot(co.xy ,vec2(a,b));
712 | highp float sn= mod(dt,3.14);
713 | return fract(sin(sn) * c);
714 | }
715 | `;
716 | const roadMarkings_fragment = `
717 |
718 | uv.y = mod(uv.y + uTime * 0.1,1.);
719 | float brokenLineWidth = 1. / uLanes * uBrokenLinesWidthPercentage;
720 | // How much % of the lane's space is empty
721 | float laneEmptySpace = 1. - uBrokenLinesLengthPercentage;
722 |
723 | // Horizontal * vertical offset
724 | float brokenLines = step(1.-brokenLineWidth * uLanes,fract(uv.x * uLanes)) * step(laneEmptySpace, fract(uv.y * 100.)) ;
725 | // Remove right-hand lines on the right-most lane
726 | brokenLines *= step(uv.x * uLanes,uLanes-1.);
727 | color = mix(color, uBrokenLinesColor, brokenLines);
728 |
729 |
730 | float shoulderLinesWidth = 1. / uLanes * uShoulderLinesWidthPercentage;
731 | float shoulderLines = step(1.-shoulderLinesWidth, uv.x) + step(uv.x, shoulderLinesWidth);
732 | color = mix(color, uBrokenLinesColor, shoulderLines);
733 |
734 | vec2 noiseFreq = vec2(4., 7000.);
735 | float roadNoise = random( floor(uv * noiseFreq)/noiseFreq ) * 0.02 - 0.01;
736 | color += roadNoise;
737 | `;
738 | const roadFragment = roadBaseFragment
739 | .replace("#include ", roadMarkings_fragment)
740 | .replace("#include ", roadMarkings_vars);
741 |
742 | const roadVertex = `
743 | #define USE_FOG;
744 | uniform float uTime;
745 | ${THREE.ShaderChunk["fog_pars_vertex"]}
746 |
747 | uniform float uTravelLength;
748 |
749 | varying vec2 vUv;
750 | #include
751 | void main() {
752 | vec3 transformed = position.xyz;
753 |
754 | vec3 distortion = getDistortion((transformed.y + uTravelLength / 2.) / uTravelLength);
755 | transformed.x += distortion.x;
756 | transformed.z += distortion.y;
757 | transformed.y += -1.*distortion.z;
758 |
759 | vec4 mvPosition = modelViewMatrix * vec4(transformed,1.);
760 | gl_Position = projectionMatrix * mvPosition;
761 | vUv = uv;
762 |
763 | ${THREE.ShaderChunk["fog_vertex"]}
764 | }`;
765 |
766 | function resizeRendererToDisplaySize(renderer, setSize) {
767 | const canvas = renderer.domElement;
768 | const width = canvas.clientWidth;
769 | const height = canvas.clientHeight;
770 | const needResize = canvas.width !== width || canvas.height !== height;
771 | if (needResize) {
772 | setSize(width, height, false);
773 | }
774 | return needResize;
775 | }
776 |
--------------------------------------------------------------------------------
/h5game/js/game.js:
--------------------------------------------------------------------------------
1 | /*================================================
2 |
3 | Polyfill
4 |
5 | ================================================*/
6 |
7 | (function(){ 'use strict';
8 |
9 | /*================================================
10 |
11 | Request Animation Frame
12 |
13 | ================================================*/
14 |
15 | var lastTime = 0;
16 | var vendors = [ 'webkit', 'moz' ];
17 | for( var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x ) {
18 | window.requestAnimationFrame = window[ vendors[ x ] + 'RequestAnimationFrame' ];
19 | window.cancelAnimationFrame = window[ vendors[ x ] + 'CancelAnimationFrame' ] || window[ vendors[ x ] + 'CancelRequestAnimationFrame' ];
20 | }
21 |
22 | if( !window.requestAnimationFrame ) {
23 | window.requestAnimationFrame = function( callback, element ) {
24 | var currTime = new Date().getTime();
25 | var timeToCall = Math.max( 0, 16 - ( currTime - lastTime ) );
26 | var id = window.setTimeout(
27 | function() {
28 | callback( currTime + timeToCall );
29 | }, timeToCall );
30 | lastTime = currTime + timeToCall;
31 | return id;
32 | }
33 | }
34 |
35 | if( !window.cancelAnimationFrame ) {
36 | window.cancelAnimationFrame = function( id ) {
37 | clearTimeout( id );
38 | }
39 | }
40 |
41 | })();
42 |
43 | /*================================================
44 |
45 | DOM Manipulation
46 |
47 | ================================================*/
48 |
49 | (function(){ 'use strict';
50 |
51 | function hasClass( elem, className ) {
52 | return new RegExp( ' ' + className + ' ' ).test( ' ' + elem.className + ' ' );
53 | };
54 |
55 | function addClass( elem, className ) {
56 | if( !hasClass(elem, className ) ) {
57 | elem.className += ' ' + className;
58 | }
59 | };
60 |
61 | function removeClass( elem, className ) {
62 | var newClass = ' ' + elem.className.replace( /[\t\r\n]/g, ' ' ) + ' ';
63 | if( hasClass( elem, className ) ) {
64 | while( newClass.indexOf(' ' + className + ' ' ) >= 0 ) {
65 | newClass = newClass.replace( ' ' + className + ' ', ' ' );
66 | }
67 | elem.className = newClass.replace( /^\s+|\s+$/g, '' );
68 | }
69 | };
70 |
71 | function toggleClass( elem, className ) {
72 | var newClass = ' ' + elem.className.replace( /[\t\r\n]/g, ' ' ) + ' ';
73 | if( hasClass(elem, className ) ) {
74 | while( newClass.indexOf( ' ' + className + ' ' ) >= 0 ) {
75 | newClass = newClass.replace( ' ' + className + ' ' , ' ' );
76 | }
77 | elem.className = newClass.replace( /^\s+|\s+$/g, '' );
78 | } else {
79 | elem.className += ' ' + className;
80 | }
81 | };
82 |
83 | })();
84 |
85 | /*================================================
86 |
87 | Core
88 |
89 | ================================================*/
90 |
91 | g = {};
92 |
93 | (function(){ 'use strict';
94 |
95 | /*================================================
96 |
97 | Math
98 |
99 | ================================================*/
100 |
101 | g.m = Math;
102 | g.mathProps = 'E LN10 LN2 LOG2E LOG10E PI SQRT1_2 SQRT2 abs acos asin atan ceil cos exp floor log round sin sqrt tan atan2 pow max min'.split( ' ' );
103 | for ( var i = 0; i < g.mathProps.length; i++ ) {
104 | g[ g.mathProps[ i ] ] = g.m[ g.mathProps[ i ] ];
105 | }
106 | g.m.TWO_PI = g.m.PI * 2;
107 |
108 | /*================================================
109 |
110 | Miscellaneous
111 |
112 | ================================================*/
113 |
114 | g.isset = function( prop ) {
115 | return typeof prop != 'undefined';
116 | };
117 |
118 | g.log = function() {
119 | if( g.isset( g.config ) && g.config.debug && window.console ){
120 | console.log( Array.prototype.slice.call( arguments ) );
121 | }
122 | };
123 |
124 | })();
125 |
126 | /*================================================
127 |
128 | Group
129 |
130 | ================================================*/
131 |
132 | (function(){ 'use strict';
133 |
134 | g.Group = function() {
135 | this.collection = [];
136 | this.length = 0;
137 | };
138 |
139 | g.Group.prototype.add = function( item ) {
140 | this.collection.push( item );
141 | this.length++;
142 | };
143 |
144 | g.Group.prototype.remove = function( index ) {
145 | if( index < this.length ) {
146 | this.collection.splice( index, 1 );
147 | this.length--;
148 | }
149 | };
150 |
151 | g.Group.prototype.empty = function() {
152 | this.collection.length = 0;
153 | this.length = 0;
154 | };
155 |
156 | g.Group.prototype.each = function( action, asc ) {
157 | var asc = asc || 0,
158 | i;
159 | if( asc ) {
160 | for( i = 0; i < this.length; i++ ) {
161 | this.collection[ i ][ action ]( i );
162 | }
163 | } else {
164 | i = this.length;
165 | while( i-- ) {
166 | this.collection[ i ][ action ]( i );
167 | }
168 | }
169 | };
170 |
171 | })();
172 |
173 | /*================================================
174 |
175 | Utilities
176 |
177 | ================================================*/
178 |
179 | (function(){ 'use strict';
180 |
181 | g.util = {};
182 |
183 | /*================================================
184 |
185 | Random
186 |
187 | ================================================*/
188 |
189 | g.util.rand = function( min, max ) {
190 | return g.m.random() * ( max - min ) + min;
191 | };
192 |
193 | g.util.randInt = function( min, max ) {
194 | return g.m.floor( g.m.random() * ( max - min + 1) ) + min;
195 | };
196 |
197 | }());
198 |
199 | /*================================================
200 |
201 | State
202 |
203 | ================================================*/
204 |
205 | (function(){ 'use strict';
206 |
207 | g.states = {};
208 |
209 | g.addState = function( state ) {
210 | g.states[ state.name ] = state;
211 | };
212 |
213 | g.setState = function( name ) {
214 | if( g.state ) {
215 | g.states[ g.state ].exit();
216 | }
217 | g.state = name;
218 | g.states[ g.state ].init();
219 | };
220 |
221 | g.currentState = function() {
222 | return g.states[ g.state ];
223 | };
224 |
225 | }());
226 |
227 | /*================================================
228 |
229 | Time
230 |
231 | ================================================*/
232 |
233 | (function(){ 'use strict';
234 |
235 | g.Time = function() {
236 | this.reset();
237 | }
238 |
239 | g.Time.prototype.reset = function() {
240 | this.now = Date.now();
241 | this.last = Date.now();
242 | this.delta = 60;
243 | this.ndelta = 1;
244 | this.elapsed = 0;
245 | this.nelapsed = 0;
246 | this.tick = 0;
247 | };
248 |
249 | g.Time.prototype.update = function() {
250 | this.now = Date.now();
251 | this.delta = this.now - this.last;
252 | this.ndelta = Math.min( Math.max( this.delta / ( 1000 / 60 ), 0.0001 ), 10 );
253 | this.elapsed += this.delta;
254 | this.nelapsed += this.ndelta;
255 | this.last = this.now;
256 | this.tick++;
257 | };
258 |
259 | })();
260 |
261 | /*================================================
262 |
263 | Grid Entity
264 |
265 | ================================================*/
266 |
267 | (function(){ 'use strict';
268 |
269 | g.Grid = function( cols, rows ) {
270 | this.cols = cols;
271 | this.rows = rows;
272 | this.tiles = [];
273 | for( var x = 0; x < cols; x++ ) {
274 | this.tiles[ x ] = [];
275 | for( var y = 0; y < rows; y++ ) {
276 | this.tiles[ x ].push( 'empty' );
277 | }
278 | }
279 | };
280 |
281 | g.Grid.prototype.get = function( x, y ) {
282 | return this.tiles[ x ][ y ];
283 | };
284 |
285 | g.Grid.prototype.set = function( x, y, val ) {
286 | this.tiles[ x ][ y ] = val;
287 | };
288 |
289 | })();
290 |
291 | /*================================================
292 |
293 | Board Tile Entity
294 |
295 | ================================================*/
296 |
297 | (function(){ 'use strict';
298 |
299 | g.BoardTile = function( opt ) {
300 | this.parentState = opt.parentState;
301 | this.parentGroup = opt.parentGroup;
302 | this.col = opt.col;
303 | this.row = opt.row;
304 | this.x = opt.x;
305 | this.y = opt.y;
306 | this.z = 0;
307 | this.w = opt.w;
308 | this.h = opt.h;
309 | this.elem = document.createElement( 'div' );
310 | this.elem.style.position = 'absolute';
311 | this.elem.className = 'tile';
312 | this.parentState.stageElem.appendChild( this.elem );
313 | this.classes = {
314 | pressed: 0,
315 | path: 0,
316 | up: 0,
317 | down: 0,
318 | left: 0,
319 | right: 0
320 | }
321 | this.updateDimensions();
322 | };
323 |
324 | g.BoardTile.prototype.update = function() {
325 | for( var k in this.classes ) {
326 | if( this.classes[ k ] ) {
327 | this.classes[ k ]--;
328 | }
329 | }
330 |
331 | if( this.parentState.food.tile.col == this.col || this.parentState.food.tile.row == this.row ) {
332 | this.classes.path = 1;
333 | if( this.col < this.parentState.food.tile.col ) {
334 | this.classes.right = 1;
335 | } else {
336 | this.classes.right = 0;
337 | }
338 | if( this.col > this.parentState.food.tile.col ) {
339 | this.classes.left = 1;
340 | } else {
341 | this.classes.left = 0;
342 | }
343 | if( this.row > this.parentState.food.tile.row ) {
344 | this.classes.up = 1;
345 | } else {
346 | this.classes.up = 0;
347 | }
348 | if( this.row < this.parentState.food.tile.row ) {
349 | this.classes.down = 1;
350 | } else {
351 | this.classes.down = 0;
352 | }
353 | } else {
354 | this.classes.path = 0;
355 | }
356 |
357 | if( this.parentState.food.eaten ) {
358 | this.classes.path = 0;
359 | }
360 | };
361 |
362 | g.BoardTile.prototype.updateDimensions = function() {
363 | this.x = this.col * this.parentState.tileWidth;
364 | this.y = this.row * this.parentState.tileHeight;
365 | this.w = this.parentState.tileWidth - this.parentState.spacing;
366 | this.h = this.parentState.tileHeight - this.parentState.spacing;
367 | this.elem.style.left = this.x + 'px';
368 | this.elem.style.top = this.y + 'px';
369 | this.elem.style.width = this.w + 'px';
370 | this.elem.style.height = this.h + 'px';
371 | };
372 |
373 | g.BoardTile.prototype.render = function() {
374 | var classString = '';
375 | for( var k in this.classes ) {
376 | if( this.classes[ k ] ) {
377 | classString += k + ' ';
378 | }
379 | }
380 | this.elem.className = 'tile ' + classString;
381 | };
382 |
383 | })();
384 |
385 | /*================================================
386 |
387 | Snake Tile Entity
388 |
389 | ================================================*/
390 |
391 | (function(){ 'use strict';
392 |
393 | g.SnakeTile = function( opt ) {
394 | this.parentState = opt.parentState;
395 | this.parentGroup = opt.parentGroup;
396 | this.col = opt.col;
397 | this.row = opt.row;
398 | this.x = opt.x;
399 | this.y = opt.y;
400 | this.w = opt.w;
401 | this.h = opt.h;
402 | this.color = null;
403 | this.scale = 1;
404 | this.rotation = 0;
405 | this.blur = 0;
406 | this.alpha = 1;
407 | this.borderRadius = 0;
408 | this.borderRadiusAmount = 0;
409 | this.elem = document.createElement( 'div' );
410 | this.elem.style.position = 'absolute';
411 | this.parentState.stageElem.appendChild( this.elem );
412 | };
413 |
414 | g.SnakeTile.prototype.update = function( i ) {
415 | this.x = this.col * this.parentState.tileWidth;
416 | this.y = this.row * this.parentState.tileHeight;
417 | if( i == 0 ) {
418 | this.color = '#fff';
419 | this.blur = this.parentState.dimAvg * 0.03 + Math.sin( this.parentState.time.elapsed / 200 ) * this.parentState.dimAvg * 0.015;
420 | if( this.parentState.snake.dir == 'n' ) {
421 | this.borderRadius = this.borderRadiusAmount + '% ' + this.borderRadiusAmount + '% 0 0';
422 | } else if( this.parentState.snake.dir == 's' ) {
423 | this.borderRadius = '0 0 ' + this.borderRadiusAmount + '% ' + this.borderRadiusAmount + '%';
424 | } else if( this.parentState.snake.dir == 'e' ) {
425 | this.borderRadius = '0 ' + this.borderRadiusAmount + '% ' + this.borderRadiusAmount + '% 0';
426 | } else if( this.parentState.snake.dir == 'w' ) {
427 | this.borderRadius = this.borderRadiusAmount + '% 0 0 ' + this.borderRadiusAmount + '%';
428 | }
429 | } else {
430 | this.color = '#fff';
431 | this.blur = 0;
432 | this.borderRadius = '0';
433 | }
434 | this.alpha = 1 - ( i / this.parentState.snake.tiles.length ) * 0.6;
435 | this.rotation = ( this.parentState.snake.justAteTick / this.parentState.snake.justAteTickMax ) * 90;
436 | this.scale = 1 + ( this.parentState.snake.justAteTick / this.parentState.snake.justAteTickMax ) * 1;
437 | };
438 |
439 | g.SnakeTile.prototype.updateDimensions = function() {
440 | this.w = this.parentState.tileWidth - this.parentState.spacing;
441 | this.h = this.parentState.tileHeight - this.parentState.spacing;
442 | };
443 |
444 | g.SnakeTile.prototype.render = function( i ) {
445 | this.elem.style.left = this.x + 'px';
446 | this.elem.style.top = this.y + 'px';
447 | this.elem.style.width = this.w + 'px';
448 | this.elem.style.height = this.h + 'px';
449 | this.elem.style.backgroundColor = 'rgba(255, 255, 255, ' + this.alpha + ')';
450 | this.elem.style.boxShadow = '0 0 ' + this.blur + 'px #fff';
451 | this.elem.style.borderRadius = this.borderRadius;
452 | };
453 |
454 | })();
455 |
456 | /*================================================
457 |
458 | Food Tile Entity
459 |
460 | ================================================*/
461 |
462 | (function(){ 'use strict';
463 |
464 | g.FoodTile = function( opt ) {
465 | this.parentState = opt.parentState;
466 | this.parentGroup = opt.parentGroup;
467 | this.col = opt.col;
468 | this.row = opt.row;
469 | this.x = opt.x;
470 | this.y = opt.y;
471 | this.w = opt.w;
472 | this.h = opt.h;
473 | this.blur = 0;
474 | this.scale = 1;
475 | this.hue = 100;
476 | this.opacity = 0;
477 | this.elem = document.createElement( 'div' );
478 | this.elem.style.position = 'absolute';
479 | this.parentState.stageElem.appendChild( this.elem );
480 | };
481 |
482 | g.FoodTile.prototype.update = function() {
483 | this.x = this.col * this.parentState.tileWidth;
484 | this.y = this.row * this.parentState.tileHeight;
485 | this.blur = this.parentState.dimAvg * 0.03 + Math.sin( this.parentState.time.elapsed / 200 ) * this.parentState.dimAvg * 0.015;
486 | this.scale = 0.8 + Math.sin( this.parentState.time.elapsed / 200 ) * 0.2;
487 |
488 | if( this.parentState.food.birthTick || this.parentState.food.deathTick ) {
489 | if( this.parentState.food.birthTick ) {
490 | this.opacity = 1 - ( this.parentState.food.birthTick / 1 ) * 1;
491 | } else {
492 | this.opacity = ( this.parentState.food.deathTick / 1 ) * 1;
493 | }
494 | } else {
495 | this.opacity = 1;
496 | }
497 | };
498 |
499 | g.FoodTile.prototype.updateDimensions = function() {
500 | this.w = this.parentState.tileWidth - this.parentState.spacing;
501 | this.h = this.parentState.tileHeight - this.parentState.spacing;
502 | };
503 |
504 | g.FoodTile.prototype.render = function() {
505 | this.elem.style.left = this.x + 'px';
506 | this.elem.style.top = this.y + 'px';
507 | this.elem.style.width = this.w + 'px';
508 | this.elem.style.height = this.h + 'px';
509 | this.elem.style[ Modernizr.prefixed( 'transform' ) ] = 'translateZ(0) scale(' + this.scale + ')';
510 | this.elem.style.backgroundColor = 'hsla(' + this.hue + ', 100%, 60%, 1)';
511 | this.elem.style.boxShadow = '0 0 ' + this.blur + 'px hsla(' + this.hue + ', 100%, 60%, 1)';
512 | this.elem.style.opacity = this.opacity;
513 | };
514 |
515 | })();
516 |
517 | /*================================================
518 |
519 | Snake Entity
520 |
521 | ================================================*/
522 |
523 | (function(){ 'use strict';
524 |
525 | g.Snake = function( opt ) {
526 | this.parentState = opt.parentState;
527 | this.dir = 'e',
528 | this.currDir = this.dir;
529 | this.tiles = [];
530 | for( var i = 0; i < 5; i++ ) {
531 | this.tiles.push( new g.SnakeTile({
532 | parentState: this.parentState,
533 | parentGroup: this.tiles,
534 | col: 8 - i,
535 | row: 3,
536 | x: ( 8 - i ) * opt.parentState.tileWidth,
537 | y: 3 * opt.parentState.tileHeight,
538 | w: opt.parentState.tileWidth - opt.parentState.spacing,
539 | h: opt.parentState.tileHeight - opt.parentState.spacing
540 | }));
541 | }
542 | this.last = 0;
543 | this.updateTick = 10;
544 | this.updateTickMax = this.updateTick;
545 | this.updateTickLimit = 3;
546 | this.updateTickChange = 0.2;
547 | this.deathFlag = 0;
548 | this.justAteTick = 0;
549 | this.justAteTickMax = 1;
550 | this.justAteTickChange = 0.05;
551 |
552 | // sync data grid of the play state
553 | var i = this.tiles.length;
554 |
555 | while( i-- ) {
556 | this.parentState.grid.set( this.tiles[ i ].col, this.tiles[ i ].row, 'snake' );
557 | }
558 | };
559 |
560 | g.Snake.prototype.updateDimensions = function() {
561 | var i = this.tiles.length;
562 | while( i-- ) {
563 | this.tiles[ i ].updateDimensions();
564 | }
565 | };
566 |
567 | g.Snake.prototype.update = function() {
568 | if( this.parentState.keys.up ) {
569 | if( this.dir != 's' && this.dir != 'n' && this.currDir != 's' && this.currDir != 'n' ) {
570 | this.dir = 'n';
571 | }
572 | } else if( this.parentState.keys.down) {
573 | if( this.dir != 'n' && this.dir != 's' && this.currDir != 'n' && this.currDir != 's' ) {
574 | this.dir = 's';
575 | }
576 | } else if( this.parentState.keys.right ) {
577 | if( this.dir != 'w' && this.dir != 'e' && this.currDir != 'w' && this.currDir != 'e' ) {
578 | this.dir = 'e';
579 | }
580 | } else if( this.parentState.keys.left ) {
581 | if( this.dir != 'e' && this.dir != 'w' && this.currDir != 'e' && this.currDir != 'w' ) {
582 | this.dir = 'w';
583 | }
584 | }
585 |
586 | this.parentState.keys.up = 0;
587 | this.parentState.keys.down = 0;
588 | this.parentState.keys.right = 0;
589 | this.parentState.keys.left = 0;
590 |
591 | this.updateTick += this.parentState.time.ndelta;
592 | if( this.updateTick >= this.updateTickMax ) {
593 | // reset the update timer to 0, or whatever leftover there is
594 | this.updateTick = ( this.updateTick - this.updateTickMax );
595 |
596 | // rotate snake block array
597 | this.tiles.unshift( new g.SnakeTile({
598 | parentState: this.parentState,
599 | parentGroup: this.tiles,
600 | col: this.tiles[ 0 ].col,
601 | row: this.tiles[ 0 ].row,
602 | x: this.tiles[ 0 ].col * this.parentState.tileWidth,
603 | y: this.tiles[ 0 ].row * this.parentState.tileHeight,
604 | w: this.parentState.tileWidth - this.parentState.spacing,
605 | h: this.parentState.tileHeight - this.parentState.spacing
606 | }));
607 | this.last = this.tiles.pop();
608 | this.parentState.stageElem.removeChild( this.last.elem );
609 |
610 | this.parentState.boardTiles.collection[ this.last.col + ( this.last.row * this.parentState.cols ) ].classes.pressed = 2;
611 |
612 | // sync data grid of the play state
613 | var i = this.tiles.length;
614 |
615 | while( i-- ) {
616 | this.parentState.grid.set( this.tiles[ i ].col, this.tiles[ i ].row, 'snake' );
617 | }
618 | this.parentState.grid.set( this.last.col, this.last.row, 'empty' );
619 |
620 |
621 | // move the snake's head
622 | if ( this.dir == 'n' ) {
623 | this.currDir = 'n';
624 | this.tiles[ 0 ].row -= 1;
625 | } else if( this.dir == 's' ) {
626 | this.currDir = 's';
627 | this.tiles[ 0 ].row += 1;
628 | } else if( this.dir == 'w' ) {
629 | this.currDir = 'w';
630 | this.tiles[ 0 ].col -= 1;
631 | } else if( this.dir == 'e' ) {
632 | this.currDir = 'e';
633 | this.tiles[ 0 ].col += 1;
634 | }
635 |
636 | // wrap walls
637 | this.wallFlag = false;
638 | if( this.tiles[ 0 ].col >= this.parentState.cols ) {
639 | this.tiles[ 0 ].col = 0;
640 | this.wallFlag = true;
641 | }
642 | if( this.tiles[ 0 ].col < 0 ) {
643 | this.tiles[ 0 ].col = this.parentState.cols - 1;
644 | this.wallFlag = true;
645 | }
646 | if( this.tiles[ 0 ].row >= this.parentState.rows ) {
647 | this.tiles[ 0 ].row = 0;
648 | this.wallFlag = true;
649 | }
650 | if( this.tiles[ 0 ].row < 0 ) {
651 | this.tiles[ 0 ].row = this.parentState.rows - 1;
652 | this.wallFlag = true;
653 | }
654 |
655 | // check death by eating self
656 | if( this.parentState.grid.get( this.tiles[ 0 ].col, this.tiles[ 0 ].row ) == 'snake' ) {
657 | this.deathFlag = 1;
658 | clearTimeout( this.foodCreateTimeout );
659 | }
660 |
661 | // check eating of food
662 | if( this.parentState.grid.get( this.tiles[ 0 ].col, this.tiles[ 0 ].row ) == 'food' ) {
663 | this.tiles.push( new g.SnakeTile({
664 | parentState: this.parentState,
665 | parentGroup: this.tiles,
666 | col: this.last.col,
667 | row: this.last.row,
668 | x: this.last.col * this.parentState.tileWidth,
669 | y: this.last.row * this.parentState.tileHeight,
670 | w: this.parentState.tileWidth - this.parentState.spacing,
671 | h: this.parentState.tileHeight - this.parentState.spacing
672 | }));
673 | if( this.updateTickMax - this.updateTickChange > this.updateTickLimit ) {
674 | this.updateTickMax -= this.updateTickChange;
675 | }
676 | this.parentState.score++;
677 | this.parentState.scoreElem.innerHTML = '已吃:'+this.parentState.score;
678 | this.justAteTick = this.justAteTickMax;
679 |
680 | this.parentState.food.eaten = 1;
681 | this.parentState.stageElem.removeChild( this.parentState.food.tile.elem );
682 |
683 | var _this = this;
684 |
685 | this.foodCreateTimeout = setTimeout( function() {
686 | _this.parentState.food = new g.Food({
687 | parentState: _this.parentState
688 | });
689 | }, 300);
690 | }
691 |
692 | // check death by eating self
693 | if( this.deathFlag ) {
694 | g.setState( 'play' );
695 | }
696 | }
697 |
698 | // update individual snake tiles
699 | var i = this.tiles.length;
700 | while( i-- ) {
701 | this.tiles[ i ].update( i );
702 | }
703 |
704 | if( this.justAteTick > 0 ) {
705 | this.justAteTick -= this.justAteTickChange;
706 | } else if( this.justAteTick < 0 ) {
707 | this.justAteTick = 0;
708 | }
709 | };
710 |
711 | g.Snake.prototype.render = function() {
712 | // render individual snake tiles
713 | var i = this.tiles.length;
714 | while( i-- ) {
715 | this.tiles[ i ].render( i );
716 | }
717 | };
718 |
719 | })();
720 |
721 | /*================================================
722 |
723 | Food Entity
724 |
725 | ================================================*/
726 |
727 | (function(){ 'use strict';
728 |
729 | g.Food = function( opt ) {
730 | this.parentState = opt.parentState;
731 | this.tile = new g.FoodTile({
732 | parentState: this.parentState,
733 | col: 0,
734 | row: 0,
735 | x: 0,
736 | y: 0,
737 | w: opt.parentState.tileWidth - opt.parentState.spacing,
738 | h: opt.parentState.tileHeight - opt.parentState.spacing
739 | });
740 | this.reset();
741 | this.eaten = 0;
742 | this.birthTick = 1;
743 | this.deathTick = 0;
744 | this.birthTickChange = 0.025;
745 | this.deathTickChange = 0.05;
746 | };
747 |
748 | g.Food.prototype.reset = function() {
749 | var empty = [];
750 | for( var x = 0; x < this.parentState.cols; x++) {
751 | for( var y = 0; y < this.parentState.rows; y++) {
752 | var tile = this.parentState.grid.get( x, y );
753 | if( tile == 'empty' ) {
754 | empty.push( { x: x, y: y } );
755 | }
756 | }
757 | }
758 | var newTile = empty[ g.util.randInt( 0, empty.length - 1 ) ];
759 | this.tile.col = newTile.x;
760 | this.tile.row = newTile.y;
761 | };
762 |
763 | g.Food.prototype.updateDimensions = function() {
764 | this.tile.updateDimensions();
765 | };
766 |
767 | g.Food.prototype.update = function() {
768 | // update food tile
769 | this.tile.update();
770 |
771 | if( this.birthTick > 0 ) {
772 | this.birthTick -= this.birthTickChange;
773 | } else if( this.birthTick < 0 ) {
774 | this.birthTick = 0;
775 | }
776 |
777 | // sync data grid of the play state
778 | this.parentState.grid.set( this.tile.col, this.tile.row, 'food' );
779 | };
780 |
781 | g.Food.prototype.render = function() {
782 | this.tile.render();
783 | };
784 |
785 | })();
786 |
787 | /*================================================
788 |
789 | Play State
790 |
791 | ================================================*/
792 |
793 | (function(){ 'use strict';
794 |
795 | function StatePlay() {
796 | this.name = 'play';
797 | }
798 |
799 | StatePlay.prototype.init = function() {
800 | this.scoreElem = document.querySelector( '.score' );
801 | this.stageElem = document.querySelector( '.stage' );
802 | this.dimLong = 28;
803 | this.dimShort = 16;
804 | this.padding = 0.25;
805 | this.boardTiles = new g.Group();
806 | this.keys = {};
807 | this.foodCreateTimeout = null;
808 | this.score = 0;
809 | this.scoreElem.innerHTML = '已吃:'+this.score;
810 | this.time = new g.Time();
811 | this.getDimensions();
812 | if( this.winWidth < this.winHeight ) {
813 | this.rows = this.dimLong;
814 | this.cols = this.dimShort;
815 | } else {
816 | this.rows = this.dimShort;
817 | this.cols = this.dimLong;
818 | }
819 | this.spacing = 1;
820 | this.grid = new g.Grid( this.cols, this.rows );
821 | this.resize();
822 | this.createBoardTiles();
823 | this.bindEvents();
824 | this.snake = new g.Snake({
825 | parentState: this
826 | });
827 | this.food = new g.Food({
828 | parentState: this
829 | });
830 | };
831 |
832 | StatePlay.prototype.getDimensions = function() {
833 | this.winWidth = window.innerWidth;
834 | this.winHeight = window.innerHeight;
835 | this.activeWidth = this.winWidth - ( this.winWidth * this.padding );
836 | this.activeHeight = this.winHeight - ( this.winHeight * this.padding );
837 | };
838 |
839 | StatePlay.prototype.resize = function() {
840 | var _this = g.currentState();
841 |
842 | _this.getDimensions();
843 |
844 | _this.stageRatio = _this.rows / _this.cols;
845 |
846 | if( _this.activeWidth > _this.activeHeight / _this.stageRatio ) {
847 | _this.stageHeight = _this.activeHeight;
848 | _this.stageElem.style.height = _this.stageHeight + 'px';
849 | _this.stageWidth = Math.floor( _this.stageHeight /_this.stageRatio );
850 | _this.stageElem.style.width = _this.stageWidth + 'px';
851 | } else {
852 | _this.stageWidth = _this.activeWidth;
853 | _this.stageElem.style.width = _this.stageWidth + 'px';
854 | _this.stageHeight = Math.floor( _this.stageWidth * _this.stageRatio );
855 | _this.stageElem.style.height = _this.stageHeight + 'px';
856 | }
857 |
858 | _this.tileWidth = ~~( _this.stageWidth / _this.cols );
859 | _this.tileHeight = ~~( _this.stageHeight / _this.rows );
860 | _this.dimAvg = ( _this.activeWidth + _this.activeHeight ) / 2;
861 | _this.spacing = Math.max( 1, ~~( _this.dimAvg * 0.0025 ) );
862 |
863 | _this.stageElem.style.marginTop = ( -_this.stageElem.offsetHeight / 2 ) + _this.headerHeight / 2 + 'px';
864 |
865 | _this.boardTiles.each( 'updateDimensions' );
866 | _this.snake !== undefined && _this.snake.updateDimensions();
867 | _this.food !== undefined && _this.food.updateDimensions();
868 | };
869 |
870 | StatePlay.prototype.createBoardTiles = function() {
871 | for( var y = 0; y < this.rows; y++ ) {
872 | for( var x = 0; x < this.cols; x++ ) {
873 | this.boardTiles.add( new g.BoardTile({
874 | parentState: this,
875 | parentGroup: this.boardTiles,
876 | col: x,
877 | row: y,
878 | x: x * this.tileWidth,
879 | y: y * this.tileHeight,
880 | w: this.tileWidth - this.spacing,
881 | h: this.tileHeight - this.spacing
882 | }));
883 | }
884 | }
885 | };
886 |
887 | StatePlay.prototype.upOn = function() { g.currentState().keys.up = 1; }
888 | StatePlay.prototype.downOn = function() { g.currentState().keys.down = 1; }
889 | StatePlay.prototype.rightOn = function() { g.currentState().keys.right = 1; }
890 | StatePlay.prototype.leftOn = function() { g.currentState().keys.left = 1; }
891 | StatePlay.prototype.upOff = function() { g.currentState().keys.up = 0; }
892 | StatePlay.prototype.downOff = function() { g.currentState().keys.down = 0; }
893 | StatePlay.prototype.rightOff = function() { g.currentState().keys.right = 0; }
894 | StatePlay.prototype.leftOff = function() { g.currentState().keys.left = 0; }
895 |
896 | StatePlay.prototype.keydown = function( e ) {
897 | e.preventDefault();
898 | var e = ( e.keyCode ? e.keyCode : e.which ),
899 | _this = g.currentState();
900 | if( e === 38 || e === 87 ) { _this.upOn(); }
901 | if( e === 39 || e === 68 ) { _this.rightOn(); }
902 | if( e === 40 || e === 83 ) { _this.downOn(); }
903 | if( e === 37 || e === 65 ) { _this.leftOn(); }
904 | };
905 |
906 | StatePlay.prototype.bindEvents = function() {
907 | var _this = g.currentState();
908 | window.addEventListener( 'keydown', _this.keydown, false );
909 | window.addEventListener( 'resize', _this.resize, false );
910 | };
911 |
912 | StatePlay.prototype.step = function() {
913 | this.boardTiles.each( 'update' );
914 | this.boardTiles.each( 'render' );
915 | this.snake.update();
916 | this.snake.render();
917 | this.food.update();
918 | this.food.render();
919 | this.time.update();
920 | };
921 |
922 | StatePlay.prototype.exit = function() {
923 | window.removeEventListener( 'keydown', this.keydown, false );
924 | window.removeEventListener( 'resize', this.resize, false );
925 | this.stageElem.innerHTML = '';
926 | this.grid.tiles = null;
927 | this.time = null;
928 | };
929 |
930 | g.addState( new StatePlay() );
931 |
932 | })();
933 |
934 | /*================================================
935 |
936 | Game
937 |
938 | ================================================*/
939 |
940 | (function(){ 'use strict';
941 |
942 | g.config = {
943 | title: 'Snakely',
944 | debug: window.location.hash == '#debug' ? 1 : 0,
945 | state: 'play'
946 | };
947 |
948 | g.setState( g.config.state );
949 |
950 | g.time = new g.Time();
951 |
952 | g.step = function() {
953 | requestAnimationFrame( g.step );
954 | g.states[ g.state ].step();
955 | g.time.update();
956 | };
957 |
958 | window.addEventListener( 'load', g.step, false );
959 |
960 | })();
--------------------------------------------------------------------------------