Click for star burst
How do I make an click for star burst?
Star burst on click in canvas using pixi.js. What is a click for star burst? How do you make a click for star burst? This script and codes were developed by David Hartley on 18 November 2022, Friday.
Click for star burst - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Click for star burst</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.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! */ body { overflow: hidden; background: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/167451/1797393.png) no-repeat center center fixed; background-size: cover; text-align: center;
} </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body> <canvas id="canvas">No HTML5 canvas support.</canvas> <script src='https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/pixi.js/2.0.0/pixi.js'></script> <script src="js/index.js"></script>
</body>
</html>
Click for star burst - Script Codes CSS Codes
body { overflow: hidden; background: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/167451/1797393.png) no-repeat center center fixed; background-size: cover; text-align: center;
}
Click for star burst - Script Codes JS Codes
(function() { console.clear(); var stage = new PIXI.Stage(); var renderer = PIXI.autoDetectRecommendedRenderer(window.innerWidth, window.innerHeight, {view: document.getElementById("canvas"), transparent: true} ); var starTexture = PIXI.Texture.fromImage("https://s3-us-west-2.amazonaws.com/s.cdpn.io/167451/Feedbin-Icon-star.svg"); var colours = [ 0x3498db, // Blue 0x9b59b6, // Purple 0xf1c40f, // Yellow 0xd35400, // Orange 0xfA2323 // Red ]; var starPool = []; for (var i=0; i<20; i++) { var star = new PIXI.Sprite(starTexture); star.anchor.x = star.anchor.y = 0.5; star.visible = false; star.scaleDecay = 0; star.alphaDecay = 0; star.speed = 0; star.velocity = { x: 0, y: 0 }; starPool[i] = star; stage.addChild(star); } var starBurst = function(x, y) { var tint = colours[Math.floor(Math.random() * colours.length)]; for (var i=0; i<starPool.length; i++) { var star = starPool[i]; star.tint = tint; star.scale.x = star.scale.y = (Math.random() * 0.8) + 0.2; star.scaleDecay = (Math.random() * 0.05) + 0.05; star.alpha = (Math.random() * 0.2) + 0.8; star.alphaDecay = (Math.random() * 2) + 1; star.rotation = 2 * Math.random() * Math.PI; star.x = Math.cos(star.rotation) * 10 + x; star.y = Math.sin(star.rotation) * 10 + y; star.speed = (Math.random() * 30) + 20; star.velocity.x = star.speed * Math.cos(star.rotation); star.velocity.y = star.speed * Math.sin(star.rotation); star.visible = true; } }; var updateStars = function(delta) { for (var i=0; i<starPool.length; i++) { var star = starPool[i]; if (star.visible) { star.alpha -= star.alphaDecay * delta; star.scale.x -= star.scaleDecay * delta; star.scale.y -= star.scaleDecay * delta; star.x += star.velocity.x * delta; star.y += star.velocity.y * delta; if (star.alpha < 0 || star.scale.x < 0) { star.visible = false; } } } }; stage.mousedown = stage.touchstart = function(interactionData) { starBurst(interactionData.global.x, interactionData.global.y); }; var lastTime = null; var animate = function(timestamp) { if (lastTime === null) { lastTime = timestamp; } var delta = (timestamp - lastTime) / 1000; lastTime = timestamp; updateStars(delta); renderer.render(stage); requestAnimationFrame(animate); }; requestAnimationFrame(animate);
})();
Developer | David Hartley |
Username | davidhartley |
Uploaded | November 18, 2022 |
Rating | 3 |
Size | 2,868 Kb |
Views | 30,360 |
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 |
A Pen by David Hartley | 1,830 Kb |
PIXI.blendModes.ADD bug | 2,684 Kb |
Fire Emitter - remixed | 3,194 Kb |
Pixi.js Clouds Shader | 3,491 Kb |
PixiJS Shaders | 2,901 Kb |
SVG Retro Tile Pattern | 2,090 Kb |
Sunny | 3,674 Kb |
Generative Art | 2,624 Kb |
Paint Flick | 4,193 Kb |
Progress bars | 3,727 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 |
Clock Face Idea | Chrisburnell | 3,196 Kb |
Subscription Newsletter - Before inlining | Bradstrong | 7,526 Kb |
Dribbble Template | ExtremelyGinger | 2,204 Kb |
A vuejs widget | Chrgl86 | 2,869 Kb |
Test | Dviate | 2,668 Kb |
Scroll effect with text with help from Skrollr | Luxonglassing | 2,935 Kb |
Update CSS Variables with JS | Wesbos | 2,335 Kb |
Flexbox Grid - equal height | DaveOrDead | 2,855 Kb |
Add This API | ThatGuySam | 2,848 Kb |
Jstam.com Home Page | Jstam | 10,558 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!