Advertisement
Guest User

HadiGans

a guest
Jan 19th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 7.58 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en" >
  3.  
  4. <head>
  5.   <meta charset="UTF-8">
  6.   <title>Hacked by Hadi</title>
  7.   <link href='https://fonts.googleapis.com/css?family=Raleway:200,400,800' rel='stylesheet' type='text/css'>
  8.     <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">
  9.  
  10.   <link rel='stylesheet prefetch' href='https://www.marcoguglie.it/Codepen/AnimatedHeaderBg/demo-1/css/demo.css'>
  11.  
  12.  
  13.  
  14. </head>
  15.  
  16. <body>
  17.  
  18.   <div id="large-header" class="large-header">
  19.   <canvas id="demo-canvas"></canvas>
  20.     <h1 class="main-title">HaCKeD By Hadi<br><span class="thin">YouR SeCURitY GeT DowN</span></h1>
  21. </div>
  22.   <script src='https://www.marcoguglie.it/Codepen/AnimatedHeaderBg/demo-1/js/EasePack.min.js'></script>
  23. <script src='https://www.marcoguglie.it/Codepen/AnimatedHeaderBg/demo-1/js/rAF.js'></script>
  24. <script src='https://www.marcoguglie.it/Codepen/AnimatedHeaderBg/demo-1/js/TweenLite.min.js'></script>
  25.  
  26. <style>
  27. /* Header */
  28. .large-header {
  29.   position: relative;
  30.   width: 100%;
  31.   background: #333;
  32.   overflow: hidden;
  33.   background-size: cover;
  34.   background-position: center center;
  35.   z-index: 1;
  36. }
  37. #large-header {
  38.   background-image: url("https://www.marcoguglie.it/Codepen/AnimatedHeaderBg/demo-1/img/demo-1-bg.jpg");
  39. }
  40. .main-title {
  41.   position: absolute;
  42.   margin: 0;
  43.   padding: 0;
  44.   color: #f9f1e9;
  45.   text-align: center;
  46.   top: 50%;
  47.   left: 50%;
  48.   -webkit-transform: translate3d(-50%, -50%, 0);
  49.   transform: translate3d(-50%, -50%, 0);
  50. }
  51. .demo-1 .main-title {
  52.   text-transform: uppercase;
  53.   font-size: 7.2em;
  54.   letter-spacing: 0.1em;
  55. }
  56. .main-title .thin {
  57.   font-weight: 200;
  58. }
  59. @media only screen and (max-width: 768px) {
  60.   .demo-1 .main-title {
  61.     font-size: 3em;
  62.   }
  63. }
  64. </style>
  65.  
  66. <script type="text/javascript">
  67. (function() {
  68.  
  69.     var width, height, largeHeader, canvas, ctx, points, target, animateHeader = true;
  70.  
  71.     // Main
  72.     initHeader();
  73.     initAnimation();
  74.     addListeners();
  75.  
  76.     function initHeader() {
  77.         width = window.innerWidth;
  78.         height = window.innerHeight;
  79.         target = {x: width/2, y: height/2};
  80.  
  81.         largeHeader = document.getElementById('large-header');
  82.         largeHeader.style.height = height+'px';
  83.  
  84.         canvas = document.getElementById('demo-canvas');
  85.         canvas.width = width;
  86.         canvas.height = height;
  87.         ctx = canvas.getContext('2d');
  88.  
  89.         // create points
  90.         points = [];
  91.         for(var x = 0; x < width; x = x + width/20) {
  92.            for(var y = 0; y < height; y = y + height/20) {
  93.                var px = x + Math.random()*width/20;
  94.                var py = y + Math.random()*height/20;
  95.                var p = {x: px, originX: px, y: py, originY: py };
  96.                points.push(p);
  97.            }
  98.        }
  99.  
  100.        // for each point find the 5 closest points
  101.        for(var i = 0; i < points.length; i++) {
  102.            var closest = [];
  103.            var p1 = points[i];
  104.            for(var j = 0; j < points.length; j++) {
  105.                var p2 = points[j]
  106.                if(!(p1 == p2)) {
  107.                    var placed = false;
  108.                    for(var k = 0; k < 5; k++) {
  109.                        if(!placed) {
  110.                            if(closest[k] == undefined) {
  111.                                closest[k] = p2;
  112.                                placed = true;
  113.                            }
  114.                        }
  115.                    }
  116.  
  117.                    for(var k = 0; k < 5; k++) {
  118.                        if(!placed) {
  119.                            if(getDistance(p1, p2) < getDistance(p1, closest[k])) {
  120.                                closest[k] = p2;
  121.                                placed = true;
  122.                            }
  123.                        }
  124.                    }
  125.                }
  126.            }
  127.            p1.closest = closest;
  128.        }
  129.  
  130.        // assign a circle to each point
  131.        for(var i in points) {
  132.            var c = new Circle(points[i], 2+Math.random()*2, 'rgba(255,255,255,0.3)');
  133.            points[i].circle = c;
  134.        }
  135.    }
  136.  
  137.    // Event handling
  138.    function addListeners() {
  139.        if(!('ontouchstart' in window)) {
  140.            window.addEventListener('mousemove', mouseMove);
  141.        }
  142.        window.addEventListener('scroll', scrollCheck);
  143.        window.addEventListener('resize', resize);
  144.    }
  145.  
  146.    function mouseMove(e) {
  147.        var posx = posy = 0;
  148.        if (e.pageX || e.pageY) {
  149.            posx = e.pageX;
  150.            posy = e.pageY;
  151.        }
  152.        else if (e.clientX || e.clientY)    {
  153.            posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
  154.            posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
  155.        }
  156.        target.x = posx;
  157.        target.y = posy;
  158.    }
  159.  
  160.    function scrollCheck() {
  161.        if(document.body.scrollTop > height) animateHeader = false;
  162.         else animateHeader = true;
  163.     }
  164.  
  165.     function resize() {
  166.         width = window.innerWidth;
  167.         height = window.innerHeight;
  168.         largeHeader.style.height = height+'px';
  169.         canvas.width = width;
  170.         canvas.height = height;
  171.     }
  172.  
  173.     // animation
  174.     function initAnimation() {
  175.         animate();
  176.         for(var i in points) {
  177.             shiftPoint(points[i]);
  178.         }
  179.     }
  180.  
  181.     function animate() {
  182.         if(animateHeader) {
  183.             ctx.clearRect(0,0,width,height);
  184.             for(var i in points) {
  185.                 // detect points in range
  186.                 if(Math.abs(getDistance(target, points[i])) < 4000) {
  187.                    points[i].active = 0.3;
  188.                    points[i].circle.active = 0.6;
  189.                } else if(Math.abs(getDistance(target, points[i])) < 20000) {
  190.                    points[i].active = 0.1;
  191.                    points[i].circle.active = 0.3;
  192.                } else if(Math.abs(getDistance(target, points[i])) < 40000) {
  193.                    points[i].active = 0.02;
  194.                    points[i].circle.active = 0.1;
  195.                } else {
  196.                    points[i].active = 0;
  197.                    points[i].circle.active = 0;
  198.                }
  199.  
  200.                drawLines(points[i]);
  201.                points[i].circle.draw();
  202.            }
  203.        }
  204.        requestAnimationFrame(animate);
  205.    }
  206.  
  207.    function shiftPoint(p) {
  208.        TweenLite.to(p, 1+1*Math.random(), {x:p.originX-50+Math.random()*100,
  209.            y: p.originY-50+Math.random()*100, ease:Circ.easeInOut,
  210.            onComplete: function() {
  211.                shiftPoint(p);
  212.            }});
  213.    }
  214.  
  215.    // Canvas manipulation
  216.    function drawLines(p) {
  217.        if(!p.active) return;
  218.        for(var i in p.closest) {
  219.            ctx.beginPath();
  220.            ctx.moveTo(p.x, p.y);
  221.            ctx.lineTo(p.closest[i].x, p.closest[i].y);
  222.            ctx.strokeStyle = 'rgba(156,217,249,'+ p.active+')';
  223.            ctx.stroke();
  224.        }
  225.    }
  226.  
  227.    function Circle(pos,rad,color) {
  228.        var _this = this;
  229.  
  230.        // constructor
  231.        (function() {
  232.            _this.pos = pos || null;
  233.            _this.radius = rad || null;
  234.            _this.color = color || null;
  235.        })();
  236.  
  237.        this.draw = function() {
  238.            if(!_this.active) return;
  239.            ctx.beginPath();
  240.            ctx.arc(_this.pos.x, _this.pos.y, _this.radius, 0, 2 * Math.PI, false);
  241.            ctx.fillStyle = 'rgba(156,217,249,'+ _this.active+')';
  242.            ctx.fill();
  243.        };
  244.    }
  245.  
  246.    // Util
  247.    function getDistance(p1, p2) {
  248.        return Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2);
  249.    }
  250.    
  251. })();
  252. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement