Snap.svg Mask faces
How do I make an snap.svg mask faces?
What is a snap.svg mask faces? How do you make a snap.svg mask faces? This script and codes were developed by B. on 21 December 2022, Wednesday.
Snap.svg Mask faces - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Snap.svg Mask faces</title> <meta name="viewport" content="width=device-width, minimum-scale=1.0"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <style> /* NOTE: The styles were added inline because Prefixfree needs access to your styles and they must be inlined if they are on local disk! */ svg { position: fixed; will-change: all;
}
svg image { will-change: all;
} </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body> <script src='https://cdnjs.cloudflare.com/ajax/libs/snap.svg/0.4.1/snap.svg-min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Snap.svg Mask faces - Script Codes CSS Codes
svg { position: fixed; will-change: all;
}
svg image { will-change: all;
}
Snap.svg Mask faces - Script Codes JS Codes
;(function(){ //"use strict"; var root = window || this; // init Snap var s = Snap(1000, 1000); // snap.svg with requestAnimationFrame because of fps http://www.newicon.net/svg-animation-snapsvg/ if (!root.requestAnimFrame) { root.requestAnimFrame = (function(){ return root.requestAnimationFrame || root.webkitRequestAnimationFrame || root.mozRequestAnimationFrame || function(callback) { root.setTimeout(callback, 1000 / 60); }; })(); } // ez anim loop var animate = { frame: 0, updateFrame: 0, imageArray: [ 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/16721/dev-1.jpg', 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/16721/dev-2.jpg', 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/16721/dev-3.jpg', 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/16721/dev-4.jpg', 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/16721/dev-5.jpg', 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/16721/dev-1.jpg', 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/16721/dev-2.jpg', 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/16721/dev-3.jpg', 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/16721/dev-4.jpg', 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/16721/dev-5.jpg', 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/16721/dev-1.jpg', 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/16721/dev-2.jpg', 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/16721/dev-3.jpg', 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/16721/dev-4.jpg'], loop: function( timestamp ){ animate.update(); animate.render(); root.requestAnimFrame( animate.loop ); }, init: function(){ // do any set up here, grab up selections, etc // Store all images in array // Define all polygons to snap var polygon1 = s.polygon(0, 301.8, 384.46, 0, 445.53, 402.87, 0, 301.8); var polygon2 = s.polygon(445.53, 402.87, 384.9, 0, 533.36, 43.51, 445.53, 402.87); var polygon3 = s.polygon(445.53, 402.87, 533.36, 43.51, 690.96, 347.66, 445.53, 402.87); var polygon4 = s.polygon(690.96, 347.66, 533.36, 43.51, 757.71, 12.89, 690.96, 347.66); var polygon5 = s.polygon(690.96, 347.66, 757.71, 12.89, 986.58, 373.76, 690.96, 347.66); var polygon6 = s.polygon(928.36, 570, 690.96, 347.66, 986.58, 373.76, 928.36, 570); var polygon7 = s.polygon(636.75, 950.95, 690.96, 347.66, 928.36, 570, 636.75, 950.95); var polygon8 = s.polygon(502.95, 696.46, 690.96, 347.66, 636.75, 950.95, 502.95, 696.46); var polygon9 = s.polygon(445.53, 402.87, 690.96, 347.66, 502.95, 696.46, 445.53, 402.87); var polygon10 = s.polygon(294.46, 713.36, 445.53, 402.87, 502.95, 696.46, 294.46, 713.36); var polygon11 = s.polygon(294.46, 713.36, 502.95, 696.46, 345.51, 918.6, 294.46, 713.36); var polygon12 = s.polygon(345.51, 918.6, 502.95, 696.46, 636.75, 950.95, 345.51, 918.6); var polygon13 = s.polygon(112.43, 539.38, 445.53, 402.87, 294.46, 713.36, 112.43, 539.38); var polygon14 = s.polygon(0, 301.8, 445.53, 402.87, 112.43, 539.38, 0, 301.8); // Select all polygons var allPolygons = s.selectAll("polygon"); allPolygons.forEach(function(el) { // adds attribute of fill: white - enables masking el.attr({ fill: 'white', }); }); // Get all images from array animate.imageArray.forEach(function (el, i) { // Define each img as image via snap var img = s.image(el, 0, -50, 1000, 1000); // adds attributte and polygon mask with index img.attr({ width:'100%', height:'100%', mask: allPolygons[i], }); //console.log(img); }); // bind a resize helper just cuz // $(window).resize(function() { // this.resize(); // }.bind(this)); // then request our first animation loop root.requestAnimFrame( animate.loop ); }, update: function(){ // you can calculate stuff here // track the frame ++animate.frame; }, render: function(){ //Per frame if(animate.frame % 6 == 0 || animate.frame % 10 == 0){ animate.updateRefs(); } }, randomImages: function() { var images = s.selectAll("image"), shuffled = animate.shuffleArray(images), sliced, total = 5; return shuffled.splice(0, animate.randomNumber(1, total)); }, updateRefs: function(){ //animate.imageArray[1]; var slicedArray = animate.randomImages(); slicedArray.forEach(function (el, i) { //console.log(el.node.attributes.href.nodeValue); el.node.attributes.href.nodeValue = animate.imageArray[animate.randomNumber(0, animate.imageArray.length-1)]; }); }, shuffleArray: function(input) { for (var i = input.length-1; i >=0; i--) { var randomIndex = Math.floor(Math.random()*(i+1)); var itemAtIndex = input[randomIndex]; input[randomIndex] = input[i]; input[i] = itemAtIndex; } return input; }, randomNumber: function(min, max) { if (max == null) { max = min; min = 0; } return min + Math.floor(Math.random() * (max - min + 1)); } }; animate.resize = function(){ //console.log('resizing!'); // this is where you do fancypants stuff based on window widths etc if you need it }; // initialise the loop animate.init();
}).call(this);
Developer | B. |
Username | wearebold |
Uploaded | December 21, 2022 |
Rating | 3 |
Size | 3,545 Kb |
Views | 26,312 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Alerts | 2,726 Kb |
Particle Earth Map | 5,106 Kb |
Center the Unknow | 2,434 Kb |
Simple CSS3 Button | 2,571 Kb |
Slide Content Module | 6,634 Kb |
Simple Slick Sync Slider | 5,946 Kb |
Simple Push Menu | 3,455 Kb |
Slick Slider with Vimeo API - froogaloop | 3,822 Kb |
Instagram Feed with Lightbox2 | 2,895 Kb |
Simple Accordion | 3,683 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
BenU Maintenance Site | Ksherman | 4,893 Kb |
Growing Root - Scroll control - CANVAS | Cjonasw | 2,342 Kb |
Css3 slide | Nakome | 3,190 Kb |
Part 19 Bootstrap split button dropdown | Venkatesha | 1,601 Kb |
Gradients | Karpovsystems | 2,394 Kb |
RPG Style Text Dialogue | Odylic | 2,635 Kb |
Apple website | Jds317 | 1,835 Kb |
Pruebas de d3.js | Juanmanuelcarnerero | 2,485 Kb |
Day 1 - Portfolio | Chpecson | 3,532 Kb |
Popover Example | Seanboom | 2,429 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!