<p>Yes, this will work. You'll want to have the length of the gradient be short, like 0.5-1 pixels. As long as it produces a slight region of falloff around the edges of the shape, it will suffice for antialiasing.</p>
<p>A somewhat more efficient approach than literally stamping out zillions of brushes would be to evaluate the distance of each pixel center (in the area being drawn) to the shape being drawn, such as a line, stroke, rectangle, etc. and then applying the gradient as a function based on the distance. That's how the classic <a href="https://developer.nvidia.com/gpugems/gpugems2/part-iii-high-quality-rendering/chapter-22-fast-prefiltered-lines" rel="nofollow noreferrer">Fast Prefiltered Lines</a> article works.</p>

CC BY-SA 4.0
2021-07-21T18:22:18.887Z
Thanks -- why do you suggest a short gradient of 0.5 - 1 pixels? I would think that a large gradient could be a parameterized effect/style of the brush, and as long as there is a gradient of any length that ends with an alpha off 0, it would be antialiased, is that an appropriate assumption?
johnbakers
CC BY-SA 4.0
2021-07-21T18:31:50.730Z
For antialiasing you don't want it to be too blurry - you want a sharp but smooth appearance. You can certainly do a longer gradient if you wish to have the blurry appearance, but I wouldn't call it antialiasing at that point, I'd call it blurring.
Nathan Reed
CC BY-SA 4.0
2021-07-21T16:47:14.470Z
2021-07-21T16:47:14.470Z
Nathan Reed
<p>I'm new to programming raster graphics and trying to build a simple app, and I want to make sure lines have a smooth anti-aliased look. I am wondering if this can be achieved simply by having a brush that stamps circle gradients that look like this, where the outer color could be any color but most importantly an alpha of 0:</p>
<p><a href="https://i.sstatic.net/h3qGu.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/h3qGu.png" alt="enter image description here" /></a></p>
<p>In other words, does a simple gradient satisfy the needs of anti-aliasing or is there a more complex algorithm involved?</p>

<antialiasing>
Is a simple circle gradient enough to make an anti-aliased brush?
johnbakers
# Is a simple circle gradient enough to make an anti-aliased brush?

(Asked by: username_0 on 2021-07-21)

I'm new to programming raster graphics and trying to build a simple app, and I want to make sure lines have a smooth anti-aliased look. I am wondering if this can be achieved simply by having a brush that stamps circle gradients that look like this, where the outer color could be any color but most importantly an alpha of 0:

[![enter image description here](https://i.sstatic.net/h3qGu.png)](https://i.sstatic.net/h3qGu.png)

In other words, does a simple gradient satisfy the needs of anti-aliasing or is there a more complex algorithm involved?

**Tags:** antialiasing


---

## 1 answers

### Answer by username_1 on 2021-07-21. Score: 1 | Accepted answer

Yes, this will work. You'll want to have the length of the gradient be short, like 0.5-1 pixels. As long as it produces a slight region of falloff around the edges of the shape, it will suffice for antialiasing.

A somewhat more efficient approach than literally stamping out zillions of brushes would be to evaluate the distance of each pixel center (in the area being drawn) to the shape being drawn, such as a line, stroke, rectangle, etc. and then applying the gradient as a function based on the distance. That's how the classic [Fast Prefiltered Lines](https://developer.nvidia.com/gpugems/gpugems2/part-iii-high-quality-rendering/chapter-22-fast-prefiltered-lines) article works.

> **Comments:**
> **username_0**: Thanks -- why do you suggest a short gradient of 0.5 - 1 pixels? I would think that a large gradient could be a parameterized effect/style of the brush, and as long as there is a gradient of any length that ends with an alpha off 0, it would be antialiased, is that an appropriate assumption?  
> **username_1**: For antialiasing you don't want it to be too blurry - you want a sharp but smooth appearance. You can certainly do a longer gradient if you wish to have the blurry appearance, but I wouldn't call it antialiasing at that point, I'd call it blurring.  

---

