Created
July 21, 2016 08:28
-
-
Save cjmdaixi/8f84430073136eee0c0b0f90a593b72f to your computer and use it in GitHub Desktop.
Draw bezier curve smoothly between two points. Just like the curves in mind maps.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var c = document.getElementById("myCanvas"); | |
| var ctx = c.getContext("2d"); | |
| drawCurve(ctx, 100, 80, 0, 100); | |
| function drawCurve(ctx, x1, y1, x2, y2){ | |
| ctx.beginPath(); | |
| ctx.moveTo(x1, y1); | |
| ctx.bezierCurveTo((x1+x2)/2, y1, (x1+x2)/2, y2, x2, y2); | |
| ctx.stroke(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment