~eliasnaur/gio

3 2

Drawing a cubic bezier curve

Details
Message ID
<1576551949.1768.0@smtp.gmail.com>
DKIM signature
pass
Download raw message
Can someone help me with an example code for drawing a cubic bezier 
curve.
Something like https://www.algosome.com/articles/images/bezier-curve.jpg

Rajiv
Details
Message ID
<BZ7LZPDOBVQM.EI0S4V2OUW3Q@toolbox>
In-Reply-To
<1576551949.1768.0@smtp.gmail.com> (view parent)
DKIM signature
pass
Download raw message
On Tue Dec 17, 2019 at 8:05 AM Rajiv Kanchan wrote:
> 
> Can someone help me with an example code for drawing a cubic bezier 
> curve.
> Something like https://www.algosome.com/articles/images/bezier-curve.jpg
> 

You can't draw a bezier curve directly with the graphics primitives gio
provides today. What you can do is create and fill an outline bounded by
bezier curves. See for example

	https://git.sr.ht/~eliasnaur/gio/tree/master/op/clip/clip.go#L318

where 4 cubic beziers are used to construct a disc.

-- elias
Details
Message ID
<1576987849.1768.2@smtp.gmail.com>
In-Reply-To
<BZ7LZPDOBVQM.EI0S4V2OUW3Q@toolbox> (view parent)
DKIM signature
pass
Download raw message
What am I doing wrong here. I am trying to display a triangle, but I 
get a shape with more than 3 sides.
https://gist.github.com/rythmkraze/b88d4714c87e9303892f08984c135d24
Details
Message ID
<BZBZHREQE43O.2NK2CSTS6BEBF@toolbox>
In-Reply-To
<1576987849.1768.2@smtp.gmail.com> (view parent)
DKIM signature
pass
Download raw message
On Sun Dec 22, 2019 at 9:10 AM, Rajiv Kanchan wrote:
> What am I doing wrong here. I am trying to display a triangle, but I
> get a shape with more than 3 sides.
> https://gist.github.com/rythmkraze/b88d4714c87e9303892f08984c135d24
>

Note that Gio uses relative coordinates for the path commands. Your
program seems to create a path equivalent of

	<path d="m150 0 l75 200 l225 200 z" />

-- elias