Screen effect
How do I make an screen effect?
With pixi.js. What is a screen effect? How do you make a screen effect? This script and codes were developed by Toshiyuki TAKAHASHI on 30 September 2022, Friday.
Screen effect - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Screen effect</title> <script src="https://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> <div id="pixistage"></div> <script src='http://cdnjs.cloudflare.com/ajax/libs/pixi.js/2.2.7/pixi.js'></script> <script src="js/index.js"></script>
</body>
</html>
Screen effect - Script Codes CSS Codes
body { background: #000;
}
#pixistage { width: 600px; height: 400px; position: absolute; left: 50%; top: 50%; margin: -200px 0 0 -300px;
}
Screen effect - Script Codes JS Codes
WebFontConfig = { google: { families: [ 'Lato:900:latin' ] }
};
(function() { // Load Google Fonts 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); // Properties var properties = { 'width': 600, 'height': 400, 'word': 'HELLO\nWORLD!!', 'currentText': '', 'size': 80, 'blur': 4 } // Text Objects var textObj = { 'red': createText(properties.currentText, '#FF0000', properties.size), 'green': createText(properties.currentText, '#00FF00', properties.size), 'blue': createText(properties.currentText, '#0000FF', properties.size) } // Pixi.js Init var stage = new PIXI.Stage(0x000000); var renderer = PIXI.autoDetectRenderer(properties.width, properties.height); document.getElementById('pixistage').appendChild(renderer.view); // Blur Filter var filter = new PIXI.BlurFilter(); filter.blur = properties.blur; // Mouseup Event stage.mouseup = function() { buildText(); } // Create Text Oobjects for (var key in textObj){ textObj[key].filters = [filter]; stage.addChild(textObj[key]); } function createText(text, color, size) { var style = {font:'bold ' + size + 'pt Lato', align: 'center', fill: color}; var to = new PIXI.Text(text, style); to.anchor.x = 0.5; to.anchor.y = 0.5; to.position.x = properties.width/2; to.position.y = properties.height/2; to.blendMode = PIXI.blendModes.SCREEN; return to; } // Animation function animate(){ var max = 1.5, min = -1.5; for (var key in textObj){ filter.blur = properties.blur * getRandom(1, 3); textObj[key].filters = [filter]; textObj[key].position.x = properties.width/2 + getRandom(min, max); } renderer.render(stage); requestAnimFrame(animate); } animate(); // Get Random Number function getRandom(min, max) { return Math.random() * (max - min + 1) + min; } // Build Text var timerID; function buildText(){ properties.currentText = ''; if(timerID) crearInterval(timerID); timerID = setInterval(function(){ //console.log(textObj[key].text); if(properties.currentText === properties.word) { crearInterval(timerID); return; } properties.currentText = properties.word.substr(0, properties.currentText.length+1); for (var key in textObj){ textObj[key].setText(properties.currentText); } }, 250); } buildText();
})();
Developer | Toshiyuki TAKAHASHI |
Username | gau |
Uploaded | September 30, 2022 |
Rating | 4 |
Size | 3,008 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 |
No nest max-width | 2,919 Kb |
Gau9000 | 6,137 Kb |
Blue light button | 4,035 Kb |
SVG Stroke Animation | 2,996 Kb |
STAR WARS OPENING CSS | 3,014 Kb |
Vue.js and Responsive | 2,333 Kb |
Eliminate a gap from inline and inline-block | 2,345 Kb |
Bxslider hover test | 2,103 Kb |
OpenType features for body text | 3,498 Kb |
Fixed line-height space | 4,617 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 |
A cube | KyleDavidE | 18,627 Kb |
A Pen by lizz | Lizz | 10,068 Kb |
Slider css only | Armandobau | 2,161 Kb |
How to add Css Fold Notes In Blogger By Askwithloud.com | Askwithloud | 2,280 Kb |
Virtual vinyl | Davidpanik | 3,474 Kb |
Elephants Full screen site | Orrinward | 3,981 Kb |
CSS Variables | Jdsteinbach | 4,759 Kb |
SCSS Unit Conversion | Jakob-e | 8,210 Kb |
3D-box | Parthviroja | 2,346 Kb |
Wip elementary os navbar | Nickcolley | 2,993 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!