mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-08-04 13:30:48 +00:00
Hide edge aliasing of hard brushes with a blur (#1189)
* [𝘀𝗽𝗿] initial version Created using spr 1.3.4 * Formatting Created using spr 1.3.4 * Rename aa to blur + add comment Created using spr 1.3.4
This commit is contained in:
parent
0bd96bee1d
commit
cef1cf7587
1 changed files with 6 additions and 1 deletions
|
@ -99,12 +99,17 @@ impl<P: Pixel + Alpha> Sample for BrushStampGenerator<P> {
|
|||
fn sample(&self, position: DVec2, area: DVec2) -> Option<P> {
|
||||
let position = self.transform.inverse().transform_point2(position);
|
||||
let area = self.transform.inverse().transform_vector2(area);
|
||||
let aa_blur_radius = area.length() as f32 * 2.;
|
||||
let center = DVec2::splat(0.5);
|
||||
|
||||
let distance = (position + area / 2. - center).length() as f32 * 2.;
|
||||
|
||||
let result = if distance < 1. {
|
||||
let edge_opacity = 1. - (1. - aa_blur_radius).powf(self.feather_exponent);
|
||||
let result = if distance < 1. - aa_blur_radius {
|
||||
1. - distance.powf(self.feather_exponent)
|
||||
} else if distance < 1. {
|
||||
// TODO: Replace this with a proper analytical AA implementation
|
||||
edge_opacity * ((1. - distance) / aa_blur_radius)
|
||||
} else {
|
||||
return None;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue