Enchanted
How do I make an enchanted?
Parallax on canvas. . What is a enchanted? How do you make a enchanted? This script and codes were developed by Tiffany Rayside on 13 June 2022, Monday.
Enchanted - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Enchanted</title> <script src="http://s.codepen.io/assets/libs/modernizr.js" type="text/javascript"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <!-- Move mouse around image layers to control camera views !-->
<body>
<div id="canvas"> <canvas id="canv" width="960" height="600"></canvas>
</div>
</body>
<!-- Responsive canvas - resize !--> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Enchanted - Script Codes CSS Codes
body{ width:100%; background:hsla(0,0%,0%,1); margin:0; overflow:hidden;
}
#canvas{ width:100%; height:90vh; background-color:hsla(0,0%,0%,1); position:absolute; padding-left:6vw; padding-top:3vh; overflow: hidden;
}
canvas{ background:hsla(0,0%,0%,1); width:80%; padding-left:5vw; padding-top:2vw;
}
Enchanted - Script Codes JS Codes
var msX = 0; //mouse x
var msY = 0; //mouse y
var c; //canvas
var $$; //context
var imgs; //images
var ready = 0; //images loaded / ready counter
var prevX = 0.5; //previous x
var prevY = 0.5; //previous y
function init() { var imglay = new Image(); imglay.src = "http://i61.tinypic.com/245lres.jpg"; //layer4 (background) imglay.onload = function() {ready++}; var imglay2 = new Image(); imglay2.src = "http://i61.tinypic.com/v5yj45.jpg"; //layer3 imglay2.onload = function() {ready++}; var imglay3= new Image(); imglay3.src = "http://i61.tinypic.com/14idg21.jpg"; //layer2 imglay3.onload = function() {ready++}; var imglay4 = new Image(); imglay4.src = "http://oi57.tinypic.com/2enb9ll.jpg "; //layer 1 (foreground) imglay4.onload = function() {ready++}; imgs = [ imglay, imglay2, imglay3, imglay4]; // document.addEventListener('mousemove',function(e){ var offset = $('#canvas').offset(); msX = e.pageX - offset.left; msY = e.pageY - offset.top; }); c = document.getElementById('canv'); $$ = c.getContext('2d'); w = c.width; h = c.height; render();
}
function render() { $$.fillStyle = "rgba(0,0,0,1)"; $$.fillRect(0, 0, 960, 600); prevX += (Math.min(Math.max((msX/960), 0.12), 0.88) - prevX) * .2; prevY += (Math.min(Math.max((msY/600), 0.12), 0.88) - prevY) * .2; var offx = -(3200-960) * prevX; var offy = -(900-650) * prevY; //50 more than actual height so image base is not shown (depends on the type of image used for layer 1 - in this case, the single tree - it's just a tree, so the base is transparent, showing the black of the canvas. if I used the flowers for layer1, I could set offy to -900-600, which is the actual height of the canvas bc its base is not transparent) var iarray = ready / imgs.length; if(iarray == 1) { try { var l = imgs.length; for(var i = 0; i < l; ++i) { var scale = 0.7 + i/10; $$.drawImage(imgs[i], Math.round(offx*scale), Math.round(offy*scale), Math.round(3200*scale), Math.round(900 * scale)); } } catch(e) { } } else { $$.fillStyle = '#fff'; $$.font = 'italic 14px sans-serif'; $$.textBaseline = 'top'; $$.fillText ('ready: ' + Math.floor(iarray * 100) + "%", 0, 0); } window.requestAnimationFrame(render);
}
init();
Developer | Tiffany Rayside |
Username | tmrDevelops |
Uploaded | June 13, 2022 |
Rating | 4.5 |
Size | 2,861 Kb |
Views | 44,528 |
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 |
Legions | 3,557 Kb |
LED Marquee | 3,769 Kb |
Topiary | 2,501 Kb |
Widgets | 13,771 Kb |
Breakout | 2,618 Kb |
Fly-Out Nav | 4,196 Kb |
Super Mega | 19,728 Kb |
Fav Wave | 2,334 Kb |
The Underground | 2,696 Kb |
Cellophane | 3,196 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 |
ASCII triangle image overlay | Mitchdot | 2,200 Kb |
Profile box | Daniesy | 2,766 Kb |
Another brick in the wall | Fivera | 1,955 Kb |
Jquery 2d character movement | Drewtadams | 4,291 Kb |
Login-ng-modal | Heedoo | 3,566 Kb |
Filter inputs | Rowinf | 1,721 Kb |
FreeCodeCamp - Simon Game | Ivhed | 8,481 Kb |
Cake | Kennyname | 7,220 Kb |
RequestAnimationFrame | Martin-banks | 2,541 Kb |
Particle Motion trajectories | Sniejadlik | 5,899 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!