1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-28 07:23:13 -04:00

egui_web: make text thicker and less pixelated (#640)

Closes https://github.com/emilk/egui/issues/516
This commit is contained in:
Emil Ernerfeldt
2021-08-21 21:18:00 +02:00
committed by GitHub
parent 12fd4906de
commit 91bdf9ba6e
5 changed files with 20 additions and 6 deletions

View File

@@ -17,10 +17,19 @@ impl Texture {
}
/// Returns the textures as `sRGBA` premultiplied pixels, row by row, top to bottom.
pub fn srgba_pixels(&'_ self) -> impl Iterator<Item = super::Color32> + '_ {
///
/// `gamma` should normally be set to 1.0.
/// If you are having problems with egui text looking skinny and pixelated, try
/// setting a lower gamma, e.g. `0.5`.
pub fn srgba_pixels(&'_ self, gamma: f32) -> impl Iterator<Item = super::Color32> + '_ {
use super::Color32;
let srgba_from_luminance_lut: Vec<Color32> =
(0..=255).map(Color32::from_white_alpha).collect();
let srgba_from_luminance_lut: Vec<Color32> = (0..=255)
.map(|a| {
let a = super::color::linear_f32_from_linear_u8(a).powf(gamma);
super::Rgba::from_white_alpha(a).into()
})
.collect();
self.pixels
.iter()
.map(move |&l| srgba_from_luminance_lut[l as usize])