CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com

# Thread: How to make lines smooth

1. ## How to make lines smooth

Does anyone know an algorithm to smooth lines and curves drawn with a free hand tool? Like in all professional graphics applications, when drawing with a pen, lines and curves are automatically adjusted to look better.

I searched the Internet and couldn't find anything so I figured I ask here before I start experimenting on my own. How to determine from a set of X Y coordinates given by a MouseMove event what the user intended to draw ie. a single line, a set of lines, a circle etc.

2. ## Re: How to make lines smooth

I think the technique is called "Antialiasing". You can do a google search for antialiasing algorithms.

3. ## Re: How to make lines smooth

No, I don't think it is antialiasing. It is a bit more complex than that. Try drawing a circle with the pen in MS Paint for example and one in Flash and see how the one drawn in Flash is automaticaly adjusted so it has no visible angles.

I don't know if there is a specific term for this. It is not just the color blending of antialiasing, the points that define a curve or a line for example are automatically adjusted to achieve a round, smooth shape rather than a jagged one. Antialiasing is done on top of this.

4. ## Re: How to make lines smooth

As I understand there is a particular equation for a curve you want to generate. Thus the coordinates of the points are calculated using this equation. If you alter the equation you will have a completely new curve with different coordinates.

The question is are you trying to find out the best fit equation for a curve for a given range of parameters ? or are you trying to smooth out the already formed curve equation? The latter is called anti-aliasing. I thought you wanted the latter.

For a circle it is the same equation whether used by MS-PAINT or Flash. For the smoothness they definitely use anti-aliasing.

5. ## Re: How to make lines smooth

I want to use a similar algorithm for a similar (graphics) application. So yes, the result is a different curve, a smoother one. This is not antialiasing. I said a circle drawn with a pen tool, free-hand, not an ellipse tool.

I'm sorry if I can't explain better as I see you didn't understand what I wanted to know. I'm waiting for other ideas, no offense but I don't want to keep arguing with you about antialiasing

6. ## Re: How to make lines smooth

I hope you Know VB6..

on This thread there's some VB6 code and a lot of discussion covering this topic...

Hope this helps...

7. ## Re: How to make lines smooth

How to determine from a set of X Y coordinates given by a MouseMove event what the user intended to draw ie. a single line, a set of lines, a circle etc.
This can be called antialiasing if your intention is not to find the best fit curve (a regular curve) for the curve beign drawn but to make the curve appear to be a smooth (regular) curve. This is called curve fitting or more specifically interpolation. Image processing requires both antialiasing and curve fitting to enhance the display of a high resolution image in a low resolution display technology. go here for a demo.
Try drawing a circle with the pen in MS Paint for example and one in Flash and see how the one drawn in Flash is automaticaly adjusted so it has no visible angles.
Flash's approach is vector graphics as opposed to ms paint's approach (raster). Thus, Flash tries to think in terms of basic polygons from lines to complex curves.
Last edited by kumaresh_ana; January 2nd, 2007 at 06:47 AM.

8. Member
Join Date
Oct 1999
Location
ks
Posts
502

## Re: How to make lines smooth

you might want to google "bezier curves". it is the mathematics
behind the curve smoothing functionality in paint and many graphics
routines.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•