HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URLs added here will be added as <link>
s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
Search for and use JavaScript packages from npm here. By selecting a package, an import
statement will be added to the top of the JavaScript editor for this package.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<svg id="ad" width="400" height="400">
<g id="meshAContainer">
<rect x="0" y="0" width="400" height="400" fill="#efefef"/>
</g>
<g id="screen1">
<text id="text1" x="200" y="130" width="400"
class="base-font"
font-weight="100"
font-size="40"
fill="#686868"
text-anchor="middle">
Screens
</text>
<text id="text2" x="200" y="300" width="400"
class="base-font"
font-weight="100"
font-size="40"
fill="#686868"
text-anchor="middle">
SVG
</text>
</g>
<text id="text3"
class="base-font"
font-weight="100"
font-size="50"
fill="white"
text-anchor="middle"
opacity="0">
<tspan x="200" y="180">Make SVG</tspan>
<tspan x="200" y="250">a Snap!</tspan>
</text>
<g id="heart" transform="translate(200, 200)">
<path id="heart-shape" fill="#0DAE8A" d="M14.803-28.95c-5.879,0-11.119,2.418-14.547,6.192c-3.428-3.774-8.668-6.192-14.547-6.192c-10.329,0-23.453,4.75-23.453,23.75s38,35.414,38,35.414s38-16.414,38-35.414S25.133-28.95,14.803-28.95"/>
</g>
<g id="burst" transform="translate(200, 200)" opacity="0">
<polygon fill="#FFFFFF" points="0.451,0.063 149.256,-214.94 227.256,-214.94 "/>
<polygon fill="#FFFFFF" points="0.451,0.063 49.256,-214.94 77.256,-214.94 "/>
<polygon fill="#FFFFFF" points="0.451,0.063 -78.328,-214.94 -50.744,-212.273 "/>
<polygon fill="#FFFFFF" points="0.451,0.063 -113.661,209.06 -86.077,211.727 "/>
<polygon fill="#FFFFFF" points="0.451,0.063 -239.41,-214.94 -213.41,-135.607 "/>
<polygon fill="#FFFFFF" points="0.451,0.063 -239.41,-39 -213.41,10.334 "/>
<polygon fill="#FFFFFF" points="0.451,0.063 -239.41,101 -213.41,130.334 "/>
<polygon fill="#FFFFFF" points="0.451,0.063 215.697,21.383 241.697,50.717 "/>
<polygon fill="#FFFFFF" points="0.451,0.063 215.697,-88.617 241.697,-59.283 "/>
<polygon fill="#FFFFFF" points="0.451,0.063 208.691,137.42 207.805,194.354 "/>
<polygon fill="#FFFFFF" points="0.451,0.063 95.256,211.727 61.923,240.194 "/>
</g>
<g id="resolve" opacity="0">
<g id="replay-btn" transform="translate(345, 10)">
<rect fill="transparent" width="48" height="49.5"/>
<path fill="#cccccc" d="M25.207,9.594V4.082L12.793,11.25l12.415,7.168v-5.792C31.57,13.466,36.5,18.912,36.5,25.5
c0,7.168-5.832,13-13,13s-13-5.832-13-13c0-0.565,0.049-1.118,0.119-1.664l-2.922-0.717C7.58,23.898,7.5,24.689,7.5,25.5
c0,8.822,7.178,16,16,16s16-7.178,16-16C39.5,17.255,33.229,10.449,25.207,9.594z"/>
</g>
<text id="text4"
font-weight="100"
fill="#02225d"
text-anchor="middle">
<tspan x="200" y="100"
class="base-font"
font-size="46">
with
</tspan>
<tspan x="200" y="160"
class="snap-font"
font-size="70">
Snap.svg
</tspan>
</text>
<g id="learn-btn" transform="translate(10, 350)">
<path fill="#0B9B87" d="M147.129,37.886c0,3.156-2.558,5.714-5.714,5.714H5.714C2.558,43.6,0,41.042,0,37.886V8.175
c0-3.156,2.558-5.714,5.714-5.714h135.702c3.156,0,5.714,2.558,5.714,5.714V37.886z"/>
<path fill="#10B29C" d="M147.129,35.425c0,3.156-2.558,5.714-5.714,5.714H5.714C2.558,41.139,0,38.581,0,35.425V5.714
C0,2.558,2.558,0,5.714,0h135.702c3.156,0,5.714,2.558,5.714,5.714V35.425z"/>
<text x="10" y="30"
fill="#FFFFFF"
class="base-font"
font-size="22.6026">
Learn More
</text>
</g>
<g id="snap-logo" transform="translate(200, 260)">
<path id="snap-logo-bottom" fill="#192350" d="M39.197,39.001c0.061,0.246,0.121,0.492,0.182,0.738c-12.801,6.518-39.257,19.54-39.257,19.54
s-31.604-14.952-38.953-18.708c6.5-3.264,13.001-6.529,19.502-9.792c6.328,3.094,12.655,6.187,18.985,9.281
c6.617-3.305,13.03-6.509,19.442-9.712C25.797,33.232,32.497,36.116,39.197,39.001z"/>
<path id="snap-logo-right" fill="#03A69A" d="M39.331-54.922c-0.436-0.191-12.519,6.201-18.125,9.588c0,11.23,0,22.46,0,34.096
C15.45-8.229-33.891,16.743-40.257,20.134c0.058,6.744,0.117,13.489,0.175,20.233c0.417,0.068,0.834,0.136,1.25,0.204
c6.5-3.264,72.753-37.591,78.221-40.492C39.369-18.255,39.35-36.588,39.331-54.922z"/>
<path id="snap-logo-top" fill="#1E2A5A" d="M39.331-54.922c-5.606,3.387-12.519,6.201-18.126,9.588c-7.193-3.185-14.386-6.371-21.719-9.617
c-7.287,3.21-14.6,6.432-21.914,9.654c-5.869-2.958-11.739-5.916-17.609-8.874c-0.039-0.239-0.078-0.478-0.117-0.717
c12.766-6.485,25.531-12.969,38.297-19.454C11.437-68.06,26.037-61.204,39.331-54.922z"/>
<path id="snap-logo-left" fill="#133F68" d="M-22.676-11.256c0-3.489,0-6.949,0-10.408c0-7.878,0.198-15.755,0.346-23.633
c-5.869-2.958-11.788-5.916-17.658-8.874c0.003,11.317-0.018,22.635-0.015,33.952c-0.034,6.737-0.081,13.474-0.114,20.21
c5.781,2.841,52.704,26.952,59.219,30.356c6.7,2.884,13.397,5.769,20.096,8.654c0.029-6.258,0.134-12.516,0.163-18.773
C33.044,16.882-15.406-7.438-22.676-11.256z"/>
</g>
<g id="adobe-logo" transform="translate(350, 340)">
<polygon fill="#787878" points="22.447,0 35.605,0 35.605,31.389 "/>
<polygon fill="#787878" points="13.172,0 0,0 0,31.389 "/>
<polygon fill="#787878" points="17.809,11.565 26.195,31.387 20.698,31.387 18.189,25.074 12.049,25.074 "/>
<g>
<path fill="#787878" d="M38.294,0c0.843,0,1.515,0.678,1.515,1.524c0,0.859-0.672,1.538-1.521,1.538S36.75,2.383,36.75,1.524
C36.75,0.677,37.438,0,38.288,0H38.294z M38.287,0.259c-0.675,0-1.217,0.567-1.217,1.27c0,0.707,0.542,1.271,1.224,1.271
c0.672,0.007,1.212-0.566,1.212-1.271c0-0.702-0.54-1.27-1.212-1.27H38.287z M38.01,2.414H37.7V0.716
c0.144-0.025,0.285-0.049,0.512-0.049c0.271,0,0.442,0.053,0.556,0.141c0.094,0.068,0.146,0.188,0.146,0.346
c0,0.22-0.142,0.363-0.33,0.411v0.017c0.149,0.026,0.245,0.161,0.277,0.414c0.042,0.265,0.077,0.367,0.105,0.419h-0.311
c-0.039-0.052-0.075-0.207-0.112-0.435c-0.035-0.201-0.146-0.286-0.356-0.286h-0.179v0.721L38.01,2.414L38.01,2.414z M38.01,1.458
h0.185c0.221,0,0.406-0.074,0.406-0.271c0-0.15-0.107-0.285-0.392-0.285c-0.093,0-0.152,0-0.197,0.005v0.552L38.01,1.458
L38.01,1.458z"/>
</g>
<path fill="#787878" d="M4.782,44.511L4.366,42.05c-0.123-0.715-0.271-1.823-0.382-2.59H3.941c-0.124,0.771-0.294,1.914-0.42,2.596
l-0.449,2.456L4.782,44.511L4.782,44.511z M2.847,46.12l-0.541,2.732h-2.01l2.501-11.373h2.457l2.271,11.373H5.507l-0.53-2.732
H2.847z"/>
<path fill="#787878" d="M12.086,43.77c0-0.147,0-0.329-0.03-0.492c-0.078-0.561-0.381-1.067-0.863-1.067
c-0.818,0-1.125,1.188-1.125,2.575c0,1.599,0.437,2.51,1.096,2.51c0.309,0,0.662-0.157,0.854-0.826
c0.045-0.131,0.069-0.314,0.069-0.523L12.086,43.77L12.086,43.77z M14.148,37.174v9.318c0,0.743,0.037,1.647,0.067,2.359h-1.779
l-0.119-0.947h-0.041c-0.298,0.583-0.948,1.086-1.721,1.086c-1.702,0-2.547-1.874-2.547-4.238c0-2.877,1.263-4.275,2.629-4.275
c0.711,0,1.182,0.346,1.415,0.852h0.034v-4.152h2.062C14.148,37.177,14.148,37.174,14.148,37.174z"/>
<path fill="#787878" d="M18.428,47.415c0.782,0,0.982-1.474,0.982-2.697c0-1.159-0.2-2.67-1.018-2.67
c-0.869,0-1.054,1.511-1.054,2.67c0,1.402,0.232,2.697,1.071,2.697H18.428z M18.387,48.989c-1.889,0-3.081-1.522-3.081-4.238
c0-2.963,1.529-4.275,3.127-4.275c1.877,0,3.05,1.592,3.05,4.232c0,3.393-1.838,4.281-3.076,4.281H18.387z"/>
<path fill="#787878" d="M24.692,45.907c0,0.204,0.035,0.399,0.078,0.525c0.206,0.693,0.561,0.863,0.837,0.863
c0.795,0,1.12-1.004,1.12-2.612c0-1.462-0.343-2.472-1.129-2.472c-0.392,0-0.72,0.423-0.832,0.877
c-0.039,0.142-0.074,0.363-0.074,0.521C24.692,43.609,24.692,45.907,24.692,45.907z M22.634,37.174h2.058v4.293h0.032
c0.406-0.634,0.945-0.994,1.731-0.994c1.55,0,2.331,1.758,2.331,4.049c0,2.91-1.168,4.467-2.67,4.467
c-0.723,0-1.199-0.32-1.631-1.123h-0.042l-0.112,0.986h-1.765c0.03-0.688,0.069-1.616,0.069-2.359v-9.318L22.634,37.174
L22.634,37.174z"/>
<path fill="#787878" d="M33.712,43.945c0.007-1.161-0.328-1.976-0.982-1.976c-0.749,0-1.064,1.094-1.088,1.976H33.712z
M31.635,45.393c0.024,1.49,0.811,1.978,1.788,1.978c0.623,0,1.153-0.135,1.545-0.287l0.282,1.474
c-0.548,0.238-1.393,0.383-2.201,0.383c-2.211,0-3.411-1.498-3.411-4.067c0-2.759,1.394-4.408,3.221-4.408
c1.769,0,2.748,1.458,2.748,3.85c0,0.545-0.026,0.85-0.063,1.093L31.635,45.393z"/>
</g>
</g>
<rect id="cover" width="400" height="400" fill="#efefef"/>
</svg>
<script type="text/javascript">
WebFontConfig = {
google: { families: [ 'Source+Sans+Pro::latin', 'Open+Sans:300:latin' ] }
};
(function() {
var wf = document.createElement('script');
wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
'://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
wf.type = 'text/javascript';
wf.async = 'true';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(wf, s);
})(); </script>
@import 'compass/css3';
.base-font{
font-family: 'Open Sans', serif;
}
.snap-font{
font-family: 'Source Sans Pro', serif;
}
body{
margin: 0;
cursor: pointer;
text-align: center;
}
text{
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
svg{
@include transform-origin(top, left);
@include transform(scale(1));
margin: auto;
}
#learn-btn{
cursor: pointer;
path, text{
@include transform(translateY(0));
}
&:hover{
path{
&:first-child{
fill: #076656;
}
}
path{
&:nth-child(2){
fill: #7cd1c2;
}
}
text{
fill: #0a9a87;
}
};
&:active{
path{
&:nth-child(2){
@include transform(translateY(2px));
}
}
text{
@include transform(translateY(2px));
}
}
}
#replay-btn{
&:hover{
opacity: 0.5;
};
}
/*
* Snap.svg Display Ad
* Built using Snap.svg (snapsvg.io) @Snapsvg
* Design by Yohei Shimomae @yoheis
* & CJ Gammon @cjgammon
*/
/**
* Defines the Flat Surface Shader namespace.
* @author Matthew Wagerfield
*/
FSS = {
FRONT : 0,
BACK : 1,
DOUBLE : 2,
SVGNS : 'http://www.w3.org/2000/svg'
};
/**
* @class Array
* @author Matthew Wagerfield
*/
FSS.Array = typeof Float32Array === 'function' ? Float32Array : Array;
/**
* @class Utils
* @author Matthew Wagerfield
*/
FSS.Utils = {
isNumber: function(value) {
return !isNaN(parseFloat(value)) && isFinite(value);
}
};
/**
* Request Animation Frame Polyfill.
* @author Paul Irish
* @see https://gist.github.com/paulirish/1579671
*/
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame'] || window[vendors[x]+'CancelRequestAnimationFrame'];
}
if (!window.requestAnimationFrame) {
window.requestAnimationFrame = function(callback, element) {
var currentTime = new Date().getTime();
var timeToCall = Math.max(0, 16 - (currentTime - lastTime));
var id = window.setTimeout(function() {
callback(currentTime + timeToCall);
}, timeToCall);
lastTime = currentTime + timeToCall;
return id;
};
}
if (!window.cancelAnimationFrame) {
window.cancelAnimationFrame = function(id) {
clearTimeout(id);
};
}
}());
/**
* @object Math Augmentation
* @author Matthew Wagerfield
*/
Math.PIM2 = Math.PI*2;
Math.PID2 = Math.PI/2;
Math.randomInRange = function(min, max) {
return min + (max - min) * Math.random();
};
Math.clamp = function(value, min, max) {
value = Math.max(value, min);
value = Math.min(value, max);
return value;
};
/**
* @object Vector3
* @author Matthew Wagerfield
*/
FSS.Vector3 = {
create: function(x, y, z) {
var vector = new FSS.Array(3);
this.set(vector, x, y, z);
return vector;
},
clone: function(a) {
var vector = this.create();
this.copy(vector, a);
return vector;
},
set: function(target, x, y, z) {
target[0] = x || 0;
target[1] = y || 0;
target[2] = z || 0;
return this;
},
setX: function(target, x) {
target[0] = x || 0;
return this;
},
setY: function(target, y) {
target[1] = y || 0;
return this;
},
setZ: function(target, z) {
target[2] = z || 0;
return this;
},
copy: function(target, a) {
target[0] = a[0];
target[1] = a[1];
target[2] = a[2];
return this;
},
add: function(target, a) {
target[0] += a[0];
target[1] += a[1];
target[2] += a[2];
return this;
},
addVectors: function(target, a, b) {
target[0] = a[0] + b[0];
target[1] = a[1] + b[1];
target[2] = a[2] + b[2];
return this;
},
addScalar: function(target, s) {
target[0] += s;
target[1] += s;
target[2] += s;
return this;
},
subtract: function(target, a) {
target[0] -= a[0];
target[1] -= a[1];
target[2] -= a[2];
return this;
},
subtractVectors: function(target, a, b) {
target[0] = a[0] - b[0];
target[1] = a[1] - b[1];
target[2] = a[2] - b[2];
return this;
},
subtractScalar: function(target, s) {
target[0] -= s;
target[1] -= s;
target[2] -= s;
return this;
},
multiply: function(target, a) {
target[0] *= a[0];
target[1] *= a[1];
target[2] *= a[2];
return this;
},
multiplyVectors: function(target, a, b) {
target[0] = a[0] * b[0];
target[1] = a[1] * b[1];
target[2] = a[2] * b[2];
return this;
},
multiplyScalar: function(target, s) {
target[0] *= s;
target[1] *= s;
target[2] *= s;
return this;
},
divide: function(target, a) {
target[0] /= a[0];
target[1] /= a[1];
target[2] /= a[2];
return this;
},
divideVectors: function(target, a, b) {
target[0] = a[0] / b[0];
target[1] = a[1] / b[1];
target[2] = a[2] / b[2];
return this;
},
divideScalar: function(target, s) {
if (s !== 0) {
target[0] /= s;
target[1] /= s;
target[2] /= s;
} else {
target[0] = 0;
target[1] = 0;
target[2] = 0;
}
return this;
},
cross: function(target, a) {
var x = target[0];
var y = target[1];
var z = target[2];
target[0] = y*a[2] - z*a[1];
target[1] = z*a[0] - x*a[2];
target[2] = x*a[1] - y*a[0];
return this;
},
crossVectors: function(target, a, b) {
target[0] = a[1]*b[2] - a[2]*b[1];
target[1] = a[2]*b[0] - a[0]*b[2];
target[2] = a[0]*b[1] - a[1]*b[0];
return this;
},
min: function(target, value) {
if (target[0] < value) { target[0] = value; }
if (target[1] < value) { target[1] = value; }
if (target[2] < value) { target[2] = value; }
return this;
},
max: function(target, value) {
if (target[0] > value) { target[0] = value; }
if (target[1] > value) { target[1] = value; }
if (target[2] > value) { target[2] = value; }
return this;
},
clamp: function(target, min, max) {
this.min(target, min);
this.max(target, max);
return this;
},
limit: function(target, min, max) {
var length = this.length(target);
if (min !== null && length < min) {
this.setLength(target, min);
} else if (max !== null && length > max) {
this.setLength(target, max);
}
return this;
},
dot: function(a, b) {
return a[0]*b[0] + a[1]*b[1] + a[2]*b[2];
},
normalise: function(target) {
return this.divideScalar(target, this.length(target));
},
negate: function(target) {
return this.multiplyScalar(target, -1);
},
distanceSquared: function(a, b) {
var dx = a[0] - b[0];
var dy = a[1] - b[1];
var dz = a[2] - b[2];
return dx*dx + dy*dy + dz*dz;
},
distance: function(a, b) {
return Math.sqrt(this.distanceSquared(a, b));
},
lengthSquared: function(a) {
return a[0]*a[0] + a[1]*a[1] + a[2]*a[2];
},
length: function(a) {
return Math.sqrt(this.lengthSquared(a));
},
setLength: function(target, l) {
var length = this.length(target);
if (length !== 0 && l !== length) {
this.multiplyScalar(target, l / length);
}
return this;
}
};
/**
* @object Vector4
* @author Matthew Wagerfield
*/
FSS.Vector4 = {
create: function(x, y, z, w) {
var vector = new FSS.Array(4);
this.set(vector, x, y, z);
return vector;
},
set: function(target, x, y, z, w) {
target[0] = x || 0;
target[1] = y || 0;
target[2] = z || 0;
target[3] = w || 0;
return this;
},
setX: function(target, x) {
target[0] = x || 0;
return this;
},
setY: function(target, y) {
target[1] = y || 0;
return this;
},
setZ: function(target, z) {
target[2] = z || 0;
return this;
},
setW: function(target, w) {
target[3] = w || 0;
return this;
},
add: function(target, a) {
target[0] += a[0];
target[1] += a[1];
target[2] += a[2];
target[3] += a[3];
return this;
},
multiplyVectors: function(target, a, b) {
target[0] = a[0] * b[0];
target[1] = a[1] * b[1];
target[2] = a[2] * b[2];
target[3] = a[3] * b[3];
return this;
},
multiplyScalar: function(target, s) {
target[0] *= s;
target[1] *= s;
target[2] *= s;
target[3] *= s;
return this;
},
min: function(target, value) {
if (target[0] < value) { target[0] = value; }
if (target[1] < value) { target[1] = value; }
if (target[2] < value) { target[2] = value; }
if (target[3] < value) { target[3] = value; }
return this;
},
max: function(target, value) {
if (target[0] > value) { target[0] = value; }
if (target[1] > value) { target[1] = value; }
if (target[2] > value) { target[2] = value; }
if (target[3] > value) { target[3] = value; }
return this;
},
clamp: function(target, min, max) {
this.min(target, min);
this.max(target, max);
return this;
}
};
/**
* @class Color
* @author Matthew Wagerfield
*/
FSS.Color = function(hex, opacity) {
this.rgba = FSS.Vector4.create();
this.hex = hex || '#000000';
this.opacity = FSS.Utils.isNumber(opacity) ? opacity : 1;
this.set(this.hex, this.opacity);
};
FSS.Color.prototype = {
set: function(hex, opacity) {
hex = hex.replace('#', '');
var size = hex.length / 3;
this.rgba[0] = parseInt(hex.substring(size*0, size*1), 16) / 255;
this.rgba[1] = parseInt(hex.substring(size*1, size*2), 16) / 255;
this.rgba[2] = parseInt(hex.substring(size*2, size*3), 16) / 255;
this.rgba[3] = FSS.Utils.isNumber(opacity) ? opacity : this.rgba[3];
return this;
},
hexify: function(channel) {
var hex = Math.ceil(channel*255).toString(16);
if (hex.length === 1) { hex = '0' + hex; }
return hex;
},
format: function() {
var r = this.hexify(this.rgba[0]);
var g = this.hexify(this.rgba[1]);
var b = this.hexify(this.rgba[2]);
this.hex = '#' + r + g + b;
return this.hex;
}
};
/**
* @class Object
* @author Matthew Wagerfield
*/
FSS.Object = function() {
this.position = FSS.Vector3.create();
};
FSS.Object.prototype = {
setPosition: function(x, y, z) {
FSS.Vector3.set(this.position, x, y, z);
return this;
}
};
/**
* @class Light
* @author Matthew Wagerfield
*/
FSS.Light = function(ambient, diffuse) {
FSS.Object.call(this);
this.ambient = new FSS.Color(ambient || '#FFFFFF');
this.diffuse = new FSS.Color(diffuse || '#FFFFFF');
this.ray = FSS.Vector3.create();
};
FSS.Light.prototype = Object.create(FSS.Object.prototype);
/**
* @class Vertex
* @author Matthew Wagerfield
*/
FSS.Vertex = function(x, y, z) {
this.position = FSS.Vector3.create(x, y, z);
};
FSS.Vertex.prototype = {
setPosition: function(x, y, z) {
FSS.Vector3.set(this.position, x, y, z);
return this;
}
};
/**
* @class Triangle
* @author Matthew Wagerfield
*/
FSS.Triangle = function(a, b, c, s, material) {
this.a = a || new FSS.Vertex();
this.b = b || new FSS.Vertex();
this.c = c || new FSS.Vertex();
this.vertices = [this.a, this.b, this.c];
this.u = FSS.Vector3.create();
this.v = FSS.Vector3.create();
this.centroid = FSS.Vector3.create();
this.normal = FSS.Vector3.create();
this.material = material || new FSS.Material();this.color = new FSS.Color();
this.polygon = s.polygon();
this.polygon.attr({
'stroke-linejoin': 'round',
'stroke-miterlimit': 1,
'stroke-width': 1
});
this.computeCentroid();
this.computeNormal();
};
FSS.Triangle.prototype = {
computeCentroid: function() {
this.centroid[0] = this.a.position[0] + this.b.position[0] + this.c.position[0];
this.centroid[1] = this.a.position[1] + this.b.position[1] + this.c.position[1];
this.centroid[2] = this.a.position[2] + this.b.position[2] + this.c.position[2];
FSS.Vector3.divideScalar(this.centroid, 3);
return this;
},
computeNormal: function() {
FSS.Vector3.subtractVectors(this.u, this.b.position, this.a.position);
FSS.Vector3.subtractVectors(this.v, this.c.position, this.a.position);
FSS.Vector3.crossVectors(this.normal, this.u, this.v);
FSS.Vector3.normalise(this.normal);
return this;
}
};
/**
* @class Geometry
* @author Matthew Wagerfield
*/
FSS.Geometry = function() {
this.vertices = [];
this.triangles = [];
this.dirty = false;
};
FSS.Geometry.prototype = {
update: function() {
if (this.dirty) {
var t,triangle;
for (t = this.triangles.length - 1; t >= 0; t--) {
triangle = this.triangles[t];
triangle.computeCentroid();
triangle.computeNormal();
}
this.dirty = false;
}
return this;
}
};
/**
* @class Plane
* @author Matthew Wagerfield
*/
FSS.Plane = function(width, height, segments, slices, s, material) {
FSS.Geometry.call(this);
this.width = width || 100;
this.height = height || 100;
this.segments = segments || 4;
this.slices = slices || 4;
this.segmentWidth = this.width / this.segments;
this.sliceHeight = this.height / this.slices;
// Cache Variables
var x, y, v0, v1, v2, v3,
vertex, triangle, vertices = [],
offsetX = this.width * -0.5,
offsetY = this.height * 0.5;
// Add Vertices
for (x = 0; x <= this.segments; x++) {
vertices.push([]);
for (y = 0; y <= this.slices; y++) {
vertex = new FSS.Vertex(offsetX + x*this.segmentWidth, offsetY - y*this.sliceHeight);
vertices[x].push(vertex);
this.vertices.push(vertex);
}
}
// Add Triangles
for (x = 0; x < this.segments; x++) {
for (y = 0; y < this.slices; y++) {
v0 = vertices[x+0][y+0];
v1 = vertices[x+0][y+1];
v2 = vertices[x+1][y+0];
v3 = vertices[x+1][y+1];
t0 = new FSS.Triangle(v0, v1, v2, s, material);
t1 = new FSS.Triangle(v2, v1, v3, s, material);
this.triangles.push(t0, t1);
}
}
};
FSS.Plane.prototype = Object.create(FSS.Geometry.prototype);
/**
* @class Material
* @author Matthew Wagerfield
*/
FSS.Material = function(ambient, diffuse) {
this.ambient = new FSS.Color(ambient || '#444444');
this.diffuse = new FSS.Color(diffuse || '#FFFFFF');
this.slave = new FSS.Color();
};
/**
* @class Mesh
* @author Matthew Wagerfield
*/
FSS.Mesh = function(geometry, material) {
FSS.Object.call(this);
this.geometry = geometry || new FSS.Geometry();
this.material = material || new FSS.Material();
this.side = FSS.FRONT;
this.visible = true;
};
FSS.Mesh.prototype = Object.create(FSS.Object.prototype);
FSS.Mesh.prototype.update = function(lights, calculate) {
var t,triangle, l,light, illuminance;
// Update Geometry
this.geometry.update();
// Calculate the triangle colors
if (calculate) {
// Iterate through Triangles
for (t = this.geometry.triangles.length - 1; t >= 0; t--) {
triangle = this.geometry.triangles[t];
// Reset Triangle Color
FSS.Vector4.set(triangle.color.rgba);
// Iterate through Lights
for (l = lights.length - 1; l >= 0; l--) {
light = lights[l];
// Calculate Illuminance
FSS.Vector3.subtractVectors(light.ray, light.position, triangle.centroid);
FSS.Vector3.normalise(light.ray);
illuminance = FSS.Vector3.dot(triangle.normal, light.ray);
if (this.side === FSS.FRONT) {
illuminance = Math.max(illuminance, 0);
} else if (this.side === FSS.BACK) {
illuminance = Math.abs(Math.min(illuminance, 0));
} else if (this.side === FSS.DOUBLE) {
illuminance = Math.max(Math.abs(illuminance), 0);
}
// Calculate Ambient Light
FSS.Vector4.multiplyVectors(triangle.material.slave.rgba, triangle.material.ambient.rgba, light.ambient.rgba);
FSS.Vector4.add(triangle.color.rgba, triangle.material.slave.rgba);
// Calculate Diffuse Light
FSS.Vector4.multiplyVectors(triangle.material.slave.rgba, triangle.material.diffuse.rgba, light.diffuse.rgba);
FSS.Vector4.multiplyScalar(triangle.material.slave.rgba, illuminance);
FSS.Vector4.add(triangle.color.rgba, triangle.material.slave.rgba);
}
// Clamp & Format Color
FSS.Vector4.clamp(triangle.color.rgba, 0, 1);
}
}
return this;
};
/**
* @class Scene
* @author Matthew Wagerfield
*/
FSS.Scene = function() {
this.meshes = [];
this.lights = [];
};
FSS.Scene.prototype = {
add: function(object) {
if (object instanceof FSS.Mesh && !~this.meshes.indexOf(object)) {
this.meshes.push(object);
} else if (object instanceof FSS.Light && !~this.lights.indexOf(object)) {
this.lights.push(object);
}
return this;
},
remove: function(object) {
if (object instanceof FSS.Mesh && ~this.meshes.indexOf(object)) {
this.meshes.splice(this.meshes.indexOf(object), 1);
} else if (object instanceof FSS.Light && ~this.lights.indexOf(object)) {
this.lights.splice(this.lights.indexOf(object), 1);
}
return this;
}
};
/**
* @class Renderer
* @author Matthew Wagerfield
*/
FSS.Renderer = function() {
this.width = 0;
this.height = 0;
this.halfWidth = 0;
this.halfHeight = 0;
};
FSS.Renderer.prototype = {
setSize: function(width, height) {
if (this.width === width && this.height === height) return;
this.width = width;
this.height = height;
this.halfWidth = this.width * 0.5;
this.halfHeight = this.height * 0.5;
return this;
},
clear: function() {
return this;
},
render: function(scene) {
return this;
}
};
/**
* @class SVG Renderer
* @author Matthew Wagerfield
*/
FSS.SVGRenderer = function(s) {
FSS.Renderer.call(this);
this.element = s.g();
};
FSS.SVGRenderer.prototype = Object.create(FSS.Renderer.prototype);
FSS.SVGRenderer.prototype.setSize = function(width, height) {
FSS.Renderer.prototype.setSize.call(this, width, height);
return this;
};
FSS.SVGRenderer.prototype.clear = function() {
FSS.Renderer.prototype.clear.call(this);
for (var i = this.element.childNodes.length - 1; i >= 0; i--) {
this.element.removeChild(this.element.childNodes[i]);
}
return this;
};
FSS.SVGRenderer.prototype.render = function(scene) {
FSS.Renderer.prototype.render.call(this, scene);
var m,mesh, t,triangle, points, style;
// Update Meshes
for (m = scene.meshes.length - 1; m >= 0; m--) {
mesh = scene.meshes[m];
if (mesh.visible) {
mesh.update(scene.lights, true);
// Render Triangles
for (t = mesh.geometry.triangles.length - 1; t >= 0; t--) {
triangle = mesh.geometry.triangles[t];
if (triangle.polygon.parent() !== this.element) {
this.element.append(triangle.polygon);
}
points = this.formatPoint(triangle.a)+' ';
points += this.formatPoint(triangle.b)+' ';
points += this.formatPoint(triangle.c);
style = this.formatStyle(triangle.color.format());
triangle.polygon.attr({
points: points,
style: style,
fill: triangle.color.format()
});
}
}
}
return this;
};
FSS.SVGRenderer.prototype.formatPoint = function(vertex) {
return (this.halfWidth+vertex.position[0])+','+(this.halfHeight-vertex.position[1]);
};
FSS.SVGRenderer.prototype.formatStyle = function(color) {
var style = 'fill:'+color+';';
style += 'stroke:'+color+';';
return style;
};
/**
* Banner Ad Classes
**/
/**
* @class Heart
* @author CJ Gammon
*/
var Heart = function (s, x, y) {var instance = this,
heart,
heartMatrix,
totalMaskVertices = 50;
this.el = s.select("#heart");
heart = this.el.select('#heart-shape');
instance.maskElement = s.path(getPath(totalMaskVertices));
instance.el.attr({
clipPath: instance.maskElement
});
this.animFill = function (f, dur) {
heart.animate({
fill: f
}, 200);
}
this.setFill = function (f, dur) {
heart.attr({
fill: f
}, 200);
}
this.animScale = function (scale, dur) {
dur = dur ? dur : 300;
this.matrix = new Snap.Matrix();
this.matrix.translate(x, y);
this.matrix.scale(scale);
this.el.animate({
transform: this.matrix.toTransformString()
}, dur, mina.bounce);
}
this.setScale = function (scale, dur) {
dur = dur ? dur : 300;
this.matrix = new Snap.Matrix();
this.matrix.translate(x, y);
this.matrix.scale(scale, scale, 0, 0);
this.el.attr({
transform: this.matrix.toTransformString()
});
}
this.mask = function () {
var n = totalMaskVertices;
instance.maskElement.attr({
d: getPath(n)
});
function updatePath() {
n -= 1;
instance.maskElement.attr({
d: getPath(n)
});
if (n > 0) {
setTimeout(updatePath, 10);
}
}
setTimeout(updatePath, 10);
}
this.unmask = function () {
instance.maskElement.attr({
d: getPath(totalMaskVertices)
});
}
function getPath(n) {
var pathString,
i,
_x,
_y;
pathString = "M0 0";
for (i = 0; i < n + 1; i += 1) {
a = 2 * Math.PI * i / totalMaskVertices;
a += Math.PI;
_x = Math.sin(a) * 50;
_y = Math.cos(a) * 50;
pathString += "L" + _x + " " + _y;
}
pathString += "Z";
return pathString;
}
}
/**
* @class Device
* @author CJ Gammon
*/
var Device = function (s, x, y) {
var instance = this;
this.el = s.g();
this.matrix = new Snap.Matrix();
this.matrix.translate(x, y);
this.el.transform(this.matrix.toTransformString());
this.keyboardMatrix = new Snap.Matrix();
this.keyboardMatrix.translate(0, 70);
instance.maskElement = s.polygon();
instance.maskElement.toDefs();
addBack();
addScreen();
//addGloss();
addKeyboard();
function addBack() {
instance.back = s.rect(0, 0, 0, 0);
instance.back.attr({
fill: '#696969'
});
instance.el.append(instance.back);
}
function addScreen() {
instance.scr = s.rect(0, 0, 0, 0);
instance.scr.attr({
fill: "#09ae8a"
});
instance.el.append(instance.scr);
}
function addKeyboard() {
var p1,
p2;
instance.keyboard = s.g();
instance.keyboard.transform(instance.keyboardMatrix.toTransformString());
p1 = s.polygon('-103.324,0 -135.324,32 136.676,32 104.676,0 ');
p1.attr({
fill: '#818181'
});
p2 = s.polygon('127.774,40 -128.226,40 -136.226,32 135.774,32 ');
p2.attr({
fill: '#676767'
});
instance.keyboard.append(p1);
instance.keyboard.append(p2);
instance.el.append(instance.keyboard);
}
function addGloss() {
instance.gl = s.rect(0, 0, 0, 0);
instance.gl.attr({
opacity: 0.2,
fill: "white",
clipPath: instance.maskElement
});
instance.el.append(instance.gl);
}
this.hideKeyboard = function () {
this.keyboardMatrix = new Snap.Matrix();
instance.keyboardMatrix.translate(0, 50);
instance.keyboardMatrix.scale(0.01, 0.01, 0, 0);
instance.keyboard.animate({
opacity: 0,
transform: instance.keyboardMatrix.toTransformString()
}, 100);
}
this.showKeyboard = function () {
this.keyboardMatrix = new Snap.Matrix();
instance.keyboardMatrix.translate(0, 70);
instance.keyboardMatrix.scale(1, 1, 0, 0);
instance.keyboard.attr({
opacity: 1,
transform: instance.keyboardMatrix.toTransformString()
});
}
this.setScreen = function(w, h) {
this.scr.attr({
x: -w / 2,
y: -h / 2,
width: w,
height: h
});
}
this.setBack = function (w, h) {
this.back.attr({
x: -w / 2,
y: -h / 2,
width: w,
height: h
});
}
this.setScale = function (scale) {
this.matrix.scale(scale, scale, 0, 0);
this.el.transform(this.matrix.toTransformString());
}
this.animScreen = function(w, h) {
this.scr.animate({
x: -w / 2,
y: -h / 2,
width: w,
height: h
}, 100);
}
this.animBack = function (w, h) {
this.back.animate({
x: -w / 2,
y: -h / 2,
width: w,
height: h
}, 100);
}
this.animRotation = function (r) {
instance.matrix.rotate(r, 0, 0);
instance.el.animate({
transform: instance.matrix.toTransformString()
}, 100, mina.easeIn);
}
this.animScale = function (scale, dur, ease) {
dur = dur ? dur : 100;
ease = ease ? ease : mina.easeout;
this.matrix.scale(scale, scale, 0, 0);
this.el.animate({
transform: this.matrix.toTransformString()
}, dur, ease);
}
this.animOpacity = function (opacity, dur) {
dur = dur ? dur : 200;
this.el.animate({
opacity: opacity
}, dur);
}
this.setOpacity = function (opacity) {
this.el.attr({
opacity: opacity
});
}
}
/**
* @class Burst
* @author CJ Gammon
*/
var Burst = function (s, x, y) {
var instance = this,
polygons,
mask,
maskCircle,
maskBg;
this.el = s.select("#burst");
mask = s.g();
mask.toDefs();
maskBg = s.rect(-200, -200, 400, 400);
maskBg.attr({
fill: 'white'
});
mask.append(maskBg);
maskCircle = s.circle(0, 0, 30);
mask.append(maskCircle);
this.el.attr({
mask: mask
});
this.anim = function () {
this.el.animate({
opacity: 1
}, 100);
maskCircle.animate({
transform: 'scale(6)'
}, 300);
setTimeout(function () {
instance.el.animate({
opacity: 0
}, 100);
}, 300)
}
this.reset = function () {
maskCircle.attr({
transform: 'scale(1)'
});
}
}
/**
* @class Mesh
* @author CJ Gammon
*/
var Mesh = function (s, container, colorA, colorB) {
var instance = this,
_width = 440,
_height = 440,
now,
start = Date.now(),
renderer,
scene,
geometry,
material,
mesh,
light;
instance.animating = false;
instance.init = function () {
renderer = new FSS.SVGRenderer(s);
renderer.setSize(_width, _height);
renderer.element.transform('translate(-20, -20)'); //keep edges from showing
instance.el = renderer.element;
container.append(renderer.element);
scene = new FSS.Scene();
material = new FSS.Material(colorA, colorB);
geometry = new FSS.Plane(_width, _height, 10, 10, s, material);
mesh = new FSS.Mesh(geometry, material);
scene.add(mesh);
light = new FSS.Light('#eeeeee', '#eeeeee');
light.setPosition(300*Math.sin(0.001), 200*Math.cos(0.0005), 100);
scene.add(light);
now = Date.now() - start;
tweakMesh();
distortMesh();
renderer.render(scene);
}
instance.start = function () {
instance.animating = true;
animate();
}
instance.stop = function () {
instance.animating = false;
}
instance.setColor = function (colorA, colorB) {
var i;
material = new FSS.Material(colorA, colorB);
for (i = geometry.triangles.length - 1; i > -1; i -= 1) {
geometry.triangles[i].material = material;
}
animate();
}
instance.rippleColor = function (colorA, colorB) {
var i;
material = new FSS.Material(colorA, colorB);
function colorTriangle(j) {
geometry.triangles[j].material = material;
if (j == 0) {
setTimeout(function () {
animate();
}, 10); //force clear
}
}
for (i = geometry.triangles.length - 1; i > -1; i -= 1) {
var speed = 200 + Math.sin(0.1 + Math.abs(geometry.triangles[i].centroid[0] / geometry.triangles[i].centroid[1])) * 100;
setTimeout(colorTriangle, speed * 2, i);
}
}
function tweakMesh() {
var v, vertex;
for (v = geometry.vertices.length - 1; v >= 0; v--) {
vertex = geometry.vertices[v];
vertex.anchor = FSS.Vector3.clone(vertex.position);
vertex.step = FSS.Vector3.create(
Math.randomInRange(0.2, 1.0),
Math.randomInRange(0.2, 1.0),
Math.randomInRange(0.2, 1.0)
);
vertex.time = Math.randomInRange(0, Math.PIM2);
}
}
function distortMesh() {
var v,
vertex,
ox, oy, oz,
offset = 10 / 2;
for (v = geometry.vertices.length - 1; v >= 0; v--) {
vertex = geometry.vertices[v];
ox = Math.sin(vertex.time + vertex.step[0] * now * 0.002);
oy = Math.cos(vertex.time + vertex.step[1] * now * 0.002);
oz = Math.sin(vertex.time + vertex.step[2] * now * 0.002);
FSS.Vector3.set(vertex.position,
0.2 * geometry.segmentWidth * ox,
0.1 * geometry.sliceHeight * oy,
0.7 * offset * oz - offset);
FSS.Vector3.add(vertex.position, vertex.anchor);
}
geometry.dirty = true;
}
function animate() {
now = Date.now() - start;
if (mobilecheck() !== true) {
distortMesh();
}
renderer.render(scene);
if (instance.animating !== false) {
requestAnimationFrame(animate);
}
}
instance.init();
}
/**
* @class Logo
* @author CJ Gammon
*/
var Logo = function (s) {
var instance = this,
logo,
parts = [
['top', 0, 20],
['left', 20, 0],
['bottom', 0, -20],
['right', -20, 0]
],
components = [],
i = 0,
k = 0,
isLogoAnimated = false,
isCrocAnimated = false,
isCroc2Animated = false;
logo = s.select("#snap-logo");
for (i = 0; i < parts.length; i++) {
var el = parts[i]
elid = el[0];
element = logo.select("#snap-logo-" + elid);
element.attr({opacity:0, transform: "t" + (el[1]) + "," + (el[2])});
components.push(element);
}
function animateEach() {
if (!components[k]) {
return;
}
components[k].animate({
transform: "t" + (0) + "," + (0),
opacity: 1
}, 250, mina.easeout);
setTimeout(animateEach, 150);
k++;
};
this.animate = function () {
setTimeout(animateEach, 150);
}
this.show = function () {
var i;
for (i = 0; i < components.length; i += 1) {
components[i].attr({
transform: "t" + (0) + "," + (0),
opacity: 1
});
}
}
};
/**
* @class App
* @author CJ Gammon
*/
var App = function () {
var instance = this;
this.started = false;
this.init = function () {
var timeline,
ad,
s,
cover,
device,
heart,
burst,
screen1,
text1,
text2,
text3,
text4,
resolveScreen,
logo,
meshA,
meshAContainer,
replaycount = 0,
replayBtn,
WIDTH = 400,
HEIGHT = 400,
WHITE = "#ffffff",
GREEN = "#09ae8a";
this.started = true;
ad = document.getElementById('ad');
s = new Snap("#ad");
cover = s.select('#cover');
meshAContainer = s.select('#meshAContainer');
screen1 = s.select('#screen1');
text1 = s.select('#text1');
text2 = s.select('#text2');
text3 = s.select('#text3');
text4 = s.select('#text4');
replayBtn = s.select('#replay-btn');
resolveScreen = s.select('#resolve');
logo = new Logo(s);
//handle_RESIZE();
//window.addEventListener('resize', handle_RESIZE);
ad.addEventListener('click', handle_CLICK);
replayBtn.click(replay_CLICK);
addMeshA();
cover.remove();
addHeart();
addComputer();
addBurst();
function addHeart() {
heart = new Heart(s, WIDTH / 2, HEIGHT / 2);
}
function addComputer() {
device = new Device(s, WIDTH / 2, HEIGHT / 2);
device.setScreen(192, 112);
device.setBack(208, 148);
device.setScale(0.1);
text2.after(device.el);
}
function addBurst() {
burst = new Burst(s);
}
function addMeshA() {
meshA = new Mesh(s, meshAContainer, '#afafaf', '#afafaf');
}
function addMeshB() {
meshA.el.remove();
meshB = new Mesh(s, meshBContainer, '#09ae8a', '#777777');
}
function showMeshB() {
if (mobilecheck() !== true) {
meshB.start();
}
}
function showComputer() {
text1.animate({y: 80}, 100);
text2.animate({y: 350}, 100);
device.animScale(10, 300, mina.bounce);
heart.animFill(WHITE);
}
function toTablet() {
device.animRotation(-90);
device.animScreen(76, 100);
device.animBack(92, 132);
heart.animScale(0.5, 200);
}
function toPhone() {
device.hideKeyboard();
device.animScreen(48, 76);
device.animBack(56, 100);
heart.animScale(0.3);
}
function rotate() {
device.animRotation(90);
heart.animScale(0.4);
}
function zoom() {
meshA.stop();
device.animScale(10, 600);
heart.animScale(4, 600);
burst.anim();
}
function greenMesh() {
meshA.setColor('#09ae8a', '#777777');
if (mobilecheck() !== true) {
meshA.start();
}
device.animOpacity(0, 200);
screen1.animate({
opacity: 0
}, 100);
}
function maskReveal() {
heart.mask();
}
function showText3() {
device.setScale(0.01);
text3.animate({
opacity: 1
}, 200);
}
function hideText3() {
text3.animate({
opacity: 0
}, 200);
if (mobilecheck() !== true) {
meshA.rippleColor('#afafaf', '#afafaf');
} else {
meshA.setColor('#afafaf', '#afafaf');
}
}
function resolve() {
resolveScreen.animate({
opacity: 1
}, 200);
}
function stop() {
logo.animate();
meshA.stop();
}
function reset() {
resolveScreen.attr({
opacity: 0
});
screen1.attr({
opacity: 1
});
text1.attr({y: 130});
text2.attr({y: 300});
heart.setScale(1);
heart.setFill('#0DAE8A');
heart.unmask();
device.setOpacity(1);
device.setScreen(192, 112);
device.setBack(208, 148);
device.showKeyboard();
meshA.start();
burst.reset();
}
function replay_CLICK(e) {
e.stopPropagation();
replaycount += 1;
//ga('send', 'event', 'button', 'click', 'replay', replaycount);
reset();
run();
}
function handle_CLICK(e) {
//ga('send', 'event', 'button', 'click', 'ad');
top.window.location.href = 'http://snapsvg.io/';
}
function handle_RESIZE() {
var _w = window.innerWidth,
scale = _w / 400;
ad.style.webkitTransform = 'scale(' + scale + ')';
ad.style.MozTransform = 'scale(' + scale + ')';
ad.style.msTransform = 'scale(' + scale + ')';
ad.style.oTransform = 'scale(' + scale + ')';
ad.style.transform = 'scale(' + scale + ')';
}
function run() {
if (mobilecheck() !== true) {
meshA.start();
}
setTimeout(showComputer, 2000);
setTimeout(toPhone, 3000);
setTimeout(rotate, 4000);
setTimeout(toTablet, 5000);
setTimeout(zoom, 6000);
setTimeout(greenMesh, 6300);
setTimeout(maskReveal, 6700);
setTimeout(showText3, 7000);
setTimeout(hideText3, 10000);
setTimeout(resolve, 10500);
setTimeout(stop, 10900);
}
function basic() {
screen1.attr({opacity: 0});
heart.el.attr({opacity: 0});
replayBtn.attr({opacity: 0});
logo.show();
text4.select('tspan').attr({opacity: 0});
text4.select('tspan:nth-child(2)').attr({y: 120});
resolveScreen.attr({opacity: 1});
}
run();
}
}
window.mobilecheck = function () {
return false;
};
var app = new App();
app.init();
//legal info
//============================================================
//
// Copyright (C) 2013 Matthew Wagerfield
//
// Twitter: https://twitter.com/mwagerfield
//
// Permission is hereby granted, free of charge, to any
// person obtaining a copy of this software and associated
// documentation files (the "Software"), to deal in the
// Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute,
// sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do
// so, subject to the following conditions:
//
// The above copyright notice and this permission notice
// shall be included in all copies or substantial portions
// of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY
// OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
// EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
// AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
// OR OTHER DEALINGS IN THE SOFTWARE.
//
//============================================================
Also see: Tab Triggers