# OSDev.org

The Place to Start for Operating System Developers
 It is currently Fri Feb 03, 2023 5:47 pm

 All times are UTC - 6 hours

 Page 1 of 1 [ 6 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: How to draw a Bézier curve?Posted: Wed Nov 30, 2022 10:04 am
 Member

Joined: Tue Jun 07, 2022 11:23 am
Posts: 75
Location: France
Hi all!

Im tryting to get a ttf font onto my os, which requires bézier curves. But I don't know how to start to drawing it on the screen, I already read the wikipedia article and googled, but they all just say how to draw one with maths, not how to calculate each pixel.

Can anyone provide a pointer/tell me how?

Thanks!

_________________
https://github.com/cheyao/Achieve-Core

Top

 Post subject: Re: How to draw a Bézier curve?Posted: Wed Nov 30, 2022 11:58 am
 Member

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4525
Location: Chichester, UK
Top

 Post subject: Re: How to draw a Bézier curve?Posted: Thu Dec 01, 2022 8:54 am
 Member

Joined: Tue Jun 07, 2022 11:23 am
Posts: 75
Location: France
iansjack wrote:
https://www.algosome.com/articles/continuous-bezier-curve-line.html

Thanks!

_________________
https://github.com/cheyao/Achieve-Core

Top

 Post subject: Re: How to draw a Bézier curve?Posted: Thu Dec 01, 2022 10:53 am
 Member

Joined: Wed Aug 30, 2017 8:24 am
Posts: 1420
I'm not sure how much that article helps. It only talks about how to combine two cubic Bezier curves in such a way as to be smooth.

Anyway, Wikipedia alludes to the solution: You bisect the curve and check if the result is flat enough to be approximated by a straight line, or round enough to be approximated by a circle segment. If not you bisect the part you can't draw outright again. Rasterizing a straight line can be done with Bresenham's algorithm, and there is a circle variant of it, so I won't dwell on it. You can Google if you want. The question is: How do you calculate the flatness criterion? I don't know, but when I search for "Bezier curve flatness" online, I find this article: https://www.joshondesign.com/2018/07/11/bezier-curves. And it talks exactly about drawing Bezier curves by piecewise linear approximation. So exactly what you want to do. OK, it is in Javascript and you need it in C, but that hurdle can be overcome, right?

_________________
Carpe diem!

Top

 Post subject: Re: How to draw a Bézier curve?Posted: Fri Dec 02, 2022 10:00 am
 Member

Joined: Tue Jun 07, 2022 11:23 am
Posts: 75
Location: France
nullplan wrote:
I'm not sure how much that article helps. It only talks about how to combine two cubic Bezier curves in such a way as to be smooth.

Anyway, Wikipedia alludes to the solution: You bisect the curve and check if the result is flat enough to be approximated by a straight line, or round enough to be approximated by a circle segment. If not you bisect the part you can't draw outright again. Rasterizing a straight line can be done with Bresenham's algorithm, and there is a circle variant of it, so I won't dwell on it. You can Google if you want. The question is: How do you calculate the flatness criterion? I don't know, but when I search for "Bezier curve flatness" online, I find this article: https://www.joshondesign.com/2018/07/11/bezier-curves. And it talks exactly about drawing Bezier curves by piecewise linear approximation. So exactly what you want to do. OK, it is in Javascript and you need it in C, but that hurdle can be overcome, right?

Ahh yea that is exactly what I was looking for, thanks for the solution!

_________________
https://github.com/cheyao/Achieve-Core

Top

 Post subject: Re: How to draw a Bézier curve?Posted: Sat Dec 24, 2022 6:25 pm

Joined: Sat Apr 30, 2022 5:57 am
Posts: 18
Here's a really informative video I watched a while ago on the topic: https://youtu.be/aVwxzDHniEw

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 6 posts ]

 All times are UTC - 6 hours

#### Who is online

Users browsing this forum: No registered users and 8 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ Operating System Development    OS Development    OS Design & Theory    Announcements, Test Requests, & Job openings Everything Else    General Programming    General Ramblings    Auto-Delete Forum OSDev.org    OSDev Wiki    About this site