How to close path of two parallel quadratic Bezier curves where each starts with a MoveTo tag

amachree tamunoemi

I am implementing Sankey Diagram from scratch with using VueJS and SVG, I am now faced with difficulties to close paths of two parallel quadratic Bezier curve paths from nodes to nodes.

Where for example through additional calculations I obtained the following paths

path_1 = "M 35 20.39692701664535 q 162.53571428571428 0 325.07142857142856 64.01601512483994"

path_2 = "M 35 107.65044814340591 q 162.53571428571428 0 325.07142857142856 64.01601512483994"

The paths are combined this way, thinking it will work but it fails

<g>
 <template v-for="(point,index) in sankeyNode">
  <template v-for="(pnode, idex) in Object.entries(point)">
   <template v-for="(paths,idx) in pnode[1].paths" v-if="pnode[1].hasOwnProperty('paths')">
    <g style="stroke-width:1;"  stroke="black" fill="pink" :stroke-opacity="0.3">
     <path :d="paths[0]+' '+paths[1]+' Z'" />
    </g>
   </template>
  </template>
 </template>
</g>

These two paths are parallel to each other but I would love to make them a close path so that I can fill the combined paths and would look like the image below

enter image description here

Currently when the paths are combined it looks this way

enter image description here

I have tried the following with using the image below for illustration

enter image description here

Now when I get to "Point A" which is end of Path2, I tried to add a Vertical lineto to "Point B" so that from "Point B" I can form a Quadratic Bezier curve to "Point E" and close the path of CABE and also do the same for Path1 by adding a Vertical lineto from "Point C to E" then from point E formed a Quadratic Bezier curve to Point F and close the path of GCEF.

My attempt didn't work and I am rereading the SVG docs to find a clue on how to solve this..

Please I need someone to give me a clue on how to solve this problem. Thanks

enxaneta

Since both paths begin to the left I had to reverse the second path so that it begins from the right. Next I joined the 2 d attributes for the paths and replaced the M command of the second path with L (line). Also I've closed the path by adding the z command at the end. I hope this is what you need.

<svg viewBox="0 0 400 200">

<path d = "M 35 20.39692701664535 q 162.53571428571428 0 325.07142857142856 64.01601512483994
           L360.07142857142856,171.66646326824585Q197.53571428571428,107.65044814340591 35,107.65044814340591
           z"/>

</svg>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Drawing random paths with quadratic bezier curves

SVG: reverse cubic and quadratic bezier curves

Biciycle wheel path and bezier curves

How to get path of Bezier curves with coordinates of decimal value

How to draw each section of the blue Bezier curves with different color?

How to connect multiple bezier curves?

Finding Points on a Quadratic Bezier Curve Path

Bezier close path not getting filled

How to convert quadratic bezier curve code into cubic bezier curve?

How to prevent loops in cubic Bezier curves

Understanding how to draw SVG bezier curves by example

how to use bezier curves in cytoscape.js

WPF path description for a sine curve using bezier curves

Is there an easy way to connect the tangents of two overlapping Bezier curves?

Quadratic bezier curve math

How to compute the intersection between a quadratic bezier curve and a horizontal line?

How to calculate the third control point of a Quadratic Bezier Curve?

How could I add these annotation to this quadratic Bezier curve?

How to find a point (if any) on quadratic Bezier with a given tangent direction?

Subdivide Bezier Curves

Bezier curves in Unity

How to clip a UIView with a bezier path?

How to draw a curve in Bezier Path?

How to create bezier curves for an arc with different start and end tangent slopes

How to detect collision between object made of bezier curves and a circle?

How to Draw Shapes using Bezier Curves in a Flutter CustomPainter

How to expand shape created from a lot of bezier curves (JavaScript and canvas)

How to find two strings that are close to each other

Animating between two bezier path shapes