Better function for undercurl (#733)

* Better function for undercurl

* Setting lower alpha

* underline alpha in line-frag

* make undercurl alpha background independent

* Improved Shader

* Old Rasterization

Co-authored-by: Roland Fredenhagen <git@modprog.de>
This commit is contained in:
Roland FredenhagenandRoland Fredenhagen authored and GitHub committed 2021-04-30 09:19:43 -07:00
1 parent 0316dfeb83
commit 7b274d460e
2 files changed
+5 -5

No files matched your search

+3 -3
View File
@@ -880,7 +880,7 @@ impl<T: Texture2d> GlyphCache<T> {
let wave_height =
self.metrics.cell_size.height - (cell_rect.origin.y + self.metrics.descender_row);
let half_height = (wave_height as f32 / 2.).max(1.);
let half_height = (wave_height as f32 / 4.).max(1.);
let y =
(cell_rect.origin.y + self.metrics.descender_row) as usize - half_height as usize;
@@ -889,11 +889,11 @@ impl<T: Texture2d> GlyphCache<T> {
let pixel = buffer.pixel_mut(x, y);
let (current, _, _, _) = SrgbaPixel::with_srgba_u32(*pixel).as_rgba();
let value = current.saturating_add(val);
*pixel = SrgbaPixel::rgba(value, value, value, 0xff).as_srgba32();
*pixel = SrgbaPixel::rgba(value, value, value, value).as_srgba32();
}
for x in 0..self.metrics.cell_size.width as usize {
let vertical = wave_height as f32 * (x as f32 * x_factor).cos();
let vertical = -half_height * (x as f32 * x_factor).sin() + half_height;
let v1 = vertical.floor();
let v2 = vertical.ceil();
+2 -2
View File
@@ -23,9 +23,9 @@ void main() {
vec4 under_color = sample_texture(atlas_nearest_sampler, o_underline);
if (under_color.a != 0.0) {
// if the underline glyph isn't transparent in this position then
// we take the underline color, otherwise we'll leave the color
// we overlay the underline color, otherwise we'll leave the color
// at the background color.
color = o_underline_color;
color = color * (1.0 - under_color) + under_color * o_underline_color;
}
// Similar to the above: if the cursor texture isn't transparent