{"id":532,"date":"2020-04-01T14:21:12","date_gmt":"2020-04-01T14:21:12","guid":{"rendered":"http:\/\/diffuse-write-ups\/?p=514"},"modified":"2021-10-03T08:21:42","modified_gmt":"2021-10-03T08:21:42","slug":"move-eased-dot-along-a-curve","status":"publish","type":"post","link":"https:\/\/potatodie.nl\/diffuse-write-ups\/move-eased-dot-along-a-curve\/","title":{"rendered":"Move eased dot along a curve"},"content":{"rendered":"\n<div class=\"wp-block-group alignwide\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<p class=\"description\">Demonstration of the effect of timing functions on an animation, using a Bezier curve controller.<\/p>\n\n\n\n<p>How to use: Drag the handles (green dots) of the control below to adjust the way the red dot runs its loop. It starts and ends in its &#8216;home&#8217;, but the speed may vary, and the dot may even temporarily go backwards. <\/p>\n\n\n\n<div class=\"anim-control-demo\">\n            <div class=\"anim-container circular-path\">\n                <svg id=\"dot-on-circular-path\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"90 50 550 480\">\n   <g>\n      <path id=\"curve\" d=\"m 617.17669,285.81225 c 0,118.76378 -152.93059,215.04084 -341.58001,215.04084 -188.649431,0 -175.51459,-91.97835 -175.51459,-210.74213 0,-118.76379 -13.134841,-219.339539 175.51459,-219.339538 188.64942,0 341.58001,96.277058 341.58001,215.040828 z\" style=\"fill: none; stroke: #fff; stroke-width: 2\"><\/path>\n      <circle r=\"20\" cx=\"617\" cy=\"286\" id=\"home\" style=\"fill: #ddd\"><\/circle>\n      <circle r=\"16\" cx=\"617\" cy=\"286\" style=\"fill: #fefefe\"><\/circle>\n      <circle r=\"16\" cy=\"0\" cx=\"0\" id=\"dot\" style=\"fill: #dd1819\"><\/circle>\n   <\/g>\n<\/svg>\n            <\/div>\n            \n            <div id=\"bezier-controller-container\"><\/div>\n        <\/div>\n<\/div><\/div>\n\n\n\n<p>In the Bezier curve, perceived as a graph, the horizontal axis shows the time passed, on a scale of zero (at the start) to one (at the end point). The vertical axis shows the progress in distance covered, also from zero (no progress) to one (loop completed), although progress can dive below zero or exceed the value 1.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The CSS analogue<\/h3>\n\n\n\n<p>Perhaps you know Lea Verou&#8217;s cubic <a href=\"https:\/\/cubic-bezier.com\">Bezier tool<\/a> for CSS transitions and animations. In our case, the Bezier curve influences a JavaScript animation, instead of a CSS animation.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Open paths<\/h3>\n\n\n\n<p>The curve does not have to be a closed path. However, for a curve that does not end where it has started it makes no sense to define a timing function with undershoot (values smaller than zero) or overshoot (values larger than 1). Therefor in this case the value is clipped to the interval [0, 1].<\/p>\n\n\n\n<p>Let&#8217;s try that out on the path used before in <a href=\"https:\/\/potatodie.nl\/diffuse-write-ups\/move-a-dot-along-a-path\/\">Move a dot along a path<\/a>.<\/p>\n\n\n\n<div class=\"anim-control-demo\">\n            <div class=\"anim-container bumpy-path\">\n                <svg id=\"dot-on-bumpy-path\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 700 200\">\n  <path id=\"curve\" d=\"M 29.928125,119.32884 C 59.868756,78.85387 99.789596,30.283895 138.66049,30.104515 c 80.46172,-0.37133 90.87185,137.794285 140.7729,129.699295 40.35037,-6.54568 49.90105,-80.94994 86.53937,-78.86548 33.24073,1.89117 22.2547,70.77048 73.14399,70.77048 39.92084,0 58.65264,-56.66496 99.80211,-56.66496 49.90105,0 69.86147,80.94995 99.8021,48.56997\" style=\"fill: none; stroke: #000; stroke-width: 1\"><\/path>\n  <circle r=\"10\" cy=\"0\" cx=\"0\" id=\"dot\" style=\"fill: #dd1819\"><\/circle>\n<\/svg>\n            <\/div>\n            \n            <div id=\"bezier-controller-container-2\"><\/div>\n        <\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Ease sound<\/h2>\n\n\n\n<p>In the same vein, sound variables may be treated. See <a href=\"https:\/\/potatodie.nl\/lab\/portamento\/\">this experiment<\/a> to play with easing the frequency of a note, creating a portamento.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Demonstration of the effect of timing functions on an animation, using a Bezier curve controller. How to use: Drag the handles (green dots) of the control below to adjust the way the red dot runs its loop. It starts and ends in its &#8216;home&#8217;, but the speed may vary, and the dot may even temporarily [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22,50,20,7],"tags":[31,33,15,34],"class_list":["post-532","post","type-post","status-publish","format-standard","hentry","category-animation","category-graphics","category-javascript","category-web-development","tag-bezier","tag-easing","tag-svg","tag-timing-function"],"acf":[],"_links":{"self":[{"href":"https:\/\/potatodie.nl\/diffuse-write-ups\/wp-json\/wp\/v2\/posts\/532","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/potatodie.nl\/diffuse-write-ups\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/potatodie.nl\/diffuse-write-ups\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/potatodie.nl\/diffuse-write-ups\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/potatodie.nl\/diffuse-write-ups\/wp-json\/wp\/v2\/comments?post=532"}],"version-history":[{"count":2,"href":"https:\/\/potatodie.nl\/diffuse-write-ups\/wp-json\/wp\/v2\/posts\/532\/revisions"}],"predecessor-version":[{"id":571,"href":"https:\/\/potatodie.nl\/diffuse-write-ups\/wp-json\/wp\/v2\/posts\/532\/revisions\/571"}],"wp:attachment":[{"href":"https:\/\/potatodie.nl\/diffuse-write-ups\/wp-json\/wp\/v2\/media?parent=532"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/potatodie.nl\/diffuse-write-ups\/wp-json\/wp\/v2\/categories?post=532"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/potatodie.nl\/diffuse-write-ups\/wp-json\/wp\/v2\/tags?post=532"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}