Animate SVG Gradient
How do I make an animate svg gradient?
SVG gradient animation using RaphaelJS and Greensock Animation Platforms colorProps plugin and onUpdate callback. What is a animate svg gradient? How do you make a animate svg gradient? This script and codes were developed by Rodrigo Hernando on 18 November 2022, Friday.
Animate SVG Gradient - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Animate SVG Gradient</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <h2> SVG Gradient Animation using RaphaelJS and <br>Greensock Animation Platform
</h2>
<button id="btn1">Animate Gradient</button><button id="btn2">Reverse Gradient</button> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/gsap/latest/TweenMax.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/gsap/latest/plugins/ColorPropsPlugin.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.2/raphael-min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Animate SVG Gradient - Script Codes CSS Codes
body
{ margin:0; background:#000; font:bold 16px "Trebuchet MS", Arial, Helvetica, sans-serif;; color:#fff;
}
button
{ font:14px "Trebuchet MS", Arial, Helvetica, sans-serif; padding:3px;
}
h2
{ text-align:center;
}
Animate SVG Gradient - Script Codes JS Codes
var btn1 = $("#btn1"), btn2 = $("#btn2"), //tween the properties of this object to apply the colors to the SVG object colorObj = {a:'#f00',b:'#f00'}, t = TweenLite.to(colorObj, 2,{ colorProps:{a:'#f0f', b:'#00f'}, onUpdate:upFn, paused:true }); //raphael elements paper = Raphael(10,150,400,200), rectangle = paper.rect(0,0,400,200, 10);
rectangle.attr("fill",'45-rgb(255,0,0)-rgb(255,0,0)-rgb(255,0,0)');
function upFn()
{ console.log(colorObj.a); rectangle.attr("fill",'45-rgb(255,0,0)-' + colorObj.a + '-' + colorObj.b);
}
btn1.click(function()
{ t.play();
});
btn2.click(function()
{ t.reverse();
});
Developer | Rodrigo Hernando |
Username | rhernando |
Uploaded | November 18, 2022 |
Rating | 3.5 |
Size | 2,239 Kb |
Views | 48,576 |
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 |
Toggle Tween Direction | 2,325 Kb |
Z Index Tween | 2,138 Kb |
Simple Interactive 3D Cube | 2,985 Kb |
Circular Progress Bar | 4,985 Kb |
Cross-Browser Flip Card | 2,396 Kb |
Simple Slider Powered by GreenSock | 4,573 Kb |
Simple Drop Down Menu | 3,342 Kb |
Greensock Swipe Slides | 4,201 Kb |
Update tween progress with Draggable | 2,695 Kb |
Greensock 3D Preloader Spinner | 2,373 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 |
See Through | Larrygeams | 77,410 Kb |
CSS Patterns | Alyda | 3,953 Kb |
Drawing a Terminal with CSS | Lachlanjc | 3,185 Kb |
Login with flip 3d animation | Mariusbalaj | 3,014 Kb |
Canvas Background Effect | Sonick | 3,513 Kb |
Vanilla modal window | Jasonhowmans | 3,554 Kb |
Donut Chart example - MorrisJS | Capelo | 2,385 Kb |
JS Beispiel getElementsByClassName 3 | HSZG-Frontend-Kurs | 1,988 Kb |
Border-radius animation | Yukulele | 2,480 Kb |
Light Switch | Bartuc | 4,933 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!