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
|
|
@ -99,12 +99,17 @@ impl<P: Pixel + Alpha> Sample for BrushStampGenerator<P> {
|
||||||
fn sample(&self, position: DVec2, area: DVec2) -> Option<P> {
|
fn sample(&self, position: DVec2, area: DVec2) -> Option<P> {
|
||||||
let position = self.transform.inverse().transform_point2(position);
|
let position = self.transform.inverse().transform_point2(position);
|
||||||
let area = self.transform.inverse().transform_vector2(area);
|
let area = self.transform.inverse().transform_vector2(area);
|
||||||
|
let aa_blur_radius = area.length() as f32 * 2.;
|
||||||
let center = DVec2::splat(0.5);
|
let center = DVec2::splat(0.5);
|
||||||
|
|
||||||
let distance = (position + area / 2. - center).length() as f32 * 2.;
|
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)
|
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 {
|
} else {
|
||||||
return None;
|
return None;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue