Greensock Bezier Morph
How do I make an greensock bezier morph?
A little experiment to animate the elements from one bezier curve to another using Greensock Animation Platform.. What is a greensock bezier morph? How do you make a greensock bezier morph? This script and codes were developed by Rodrigo Hernando on 16 November 2022, Wednesday.
Greensock Bezier Morph - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Greensock Bezier Morph</title> <script src="https://s.codepen.io/assets/libs/modernizr.js" type="text/javascript"></script> <link rel="stylesheet" href="css/style.css">
</head>
<body> <h2> Greensock Bezier Morph
</h2>
<div class="marker" id="rotate"></div>
<div class="marker" id="rotate2"></div> <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/1.19.1/TweenMax.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Greensock Bezier Morph - Script Codes CSS Codes
body
{ background:#222; margin:0;
}
h2
{ font:34px "Trebuchet MS", Arial, Helvetica, sans-serif; color:#FFF; text-align:center;
}
.div1, .div2, .marker
{ width:10px; height:10px; background:#00f; position:absolute; margin-top:100px; margin-left:70px;
}
.marker
{ background:none;
Greensock Bezier Morph - Script Codes JS Codes
var path1 = [{x:0, y:0},{x:100, y:100},{x:200,y:0},{x:300,y:100},{x:400,y:0}], path2 = [{x:0,y:0},{x:100,y:-50},{x:200,y:400},{x:300,y:300},{x:400,y:400}], curve1 = [], point1, curve2 = [], point2, dot1, rotate = $("div#rotate"),rotate2 = $("div#rotate2"), amount = 50, tween1 = TweenMax.to(rotate, amount, { bezier: { values:path1, autoRotate:true }, paused:true, ease:Linear.easeNone }), tween2 = TweenMax.to(rotate2, amount, { bezier: { values:path2, autoRotate:true }, paused:true, ease:Linear.easeNone }), count = 0;
TweenMax.set(rotate, {x:0,y:0,rotation:0});
TweenMax.set(rotate2, {x:0,y:0,rotation:0});
for(var i = 0; i <= amount; i++)
{ dot1 = $('<div />' ,{id:'dot1-' + i}).addClass('div1').appendTo('body'); tween1.time(i); tween2.time(i); point1 = {x:rotate[0]._gsTransform.x, y:rotate[0]._gsTransform.y, rotation:(rotate[0]._gsTransform.rotation)}; point2 = {x:rotate2[0]._gsTransform.x, y:rotate2[0]._gsTransform.y, rotation:(rotate2[0]._gsTransform.rotation)}; curve1.push(point1); curve2.push(point2); TweenMax.set($("div#dot1-"+i), {x:point1.x, y:point1.y, rotation:point1.rotation+'_short', delay:.05*i});
}
setTimeout(function()
{ morphBezier();
},(amount*.05*1000) + 500);
function morphBezier()
{ $.each($("div.div1"),function(index,element) { TweenMax.to(element, 1, {x:curve2[index].x, y:curve2[index].y, rotation:curve2[index].rotation+'_short', repeat:-1, yoyo:true, repeatDelay:1}); });
}
Developer | Rodrigo Hernando |
Username | rhernando |
Uploaded | November 16, 2022 |
Rating | 3.5 |
Size | 2,463 Kb |
Views | 66,792 |
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 |
Bezier Animation with straight paths | 2,087 Kb |
Circular Progress Bar | 4,985 Kb |
Simple Dragging Direction | 2,374 Kb |
Auto scroll to element offset 2 | 2,620 Kb |
Spinning Images | 2,279 Kb |
GSAP Scramble Text Plugin | 2,521 Kb |
Draggable add element | 2,378 Kb |
Circular Bezier | 2,696 Kb |
Auto scroll to element offset | 2,549 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 |
Electric worm | Jeffibacache | 2,377 Kb |
Collapsing Widget | Er40 | 4,279 Kb |
HTML5 Video Autoplay | Zivcos | 1,352 Kb |
12 DAYS OF XMAS | Proto78 | 2,313 Kb |
Pure CSS Tooltip | APinix | 2,815 Kb |
Reading Grid | Tappily | 4,306 Kb |
Weather App | Kw7oe | 3,162 Kb |
Acorrdian 2016 | Milanodituti | 3,720 Kb |
TestTube CSS | EZPK | 2,710 Kb |
Michelle, submit your photography to Unsplash. | Zaneriley | 3,368 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!