File tree 5 files changed +20
-6
lines changed
egui_demo_lib/src/apps/demo
5 files changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ impl Default for Painting {
12
12
fn default ( ) -> Self {
13
13
Self {
14
14
lines : Default :: default ( ) ,
15
- stroke : Stroke :: new ( 1 .0, Color32 :: LIGHT_BLUE ) ,
15
+ stroke : Stroke :: new ( 2 .0, Color32 :: LIGHT_BLUE ) , // Thin strokes looks bad on web
16
16
}
17
17
}
18
18
}
Original file line number Diff line number Diff line change @@ -8,6 +8,9 @@ All notable changes to the `egui_web` integration will be noted in this file.
8
8
### Added ⭐
9
9
* Added support for dragging and dropping files into the browser window.
10
10
11
+ ### Fixed 🐛
12
+ * Made text thicker and less pixelated.
13
+
11
14
12
15
## 0.13.0 - 2021-06-24
13
16
Original file line number Diff line number Diff line change @@ -367,7 +367,8 @@ impl crate::Painter for WebGlPainter {
367
367
}
368
368
369
369
let mut pixels: Vec < u8 > = Vec :: with_capacity ( texture. pixels . len ( ) * 4 ) ;
370
- for srgba in texture. srgba_pixels ( ) {
370
+ let font_gamma = 1.0 / 2.2 ; // HACK due to non-linear framebuffer blending.
371
+ for srgba in texture. srgba_pixels ( font_gamma) {
371
372
pixels. push ( srgba. r ( ) ) ;
372
373
pixels. push ( srgba. g ( ) ) ;
373
374
pixels. push ( srgba. b ( ) ) ;
Original file line number Diff line number Diff line change @@ -368,7 +368,8 @@ impl crate::Painter for WebGl2Painter {
368
368
}
369
369
370
370
let mut pixels: Vec < u8 > = Vec :: with_capacity ( texture. pixels . len ( ) * 4 ) ;
371
- for srgba in texture. srgba_pixels ( ) {
371
+ let font_gamma = 1.0 / 2.2 ; // HACK due to non-linear framebuffer blending.
372
+ for srgba in texture. srgba_pixels ( font_gamma) {
372
373
pixels. push ( srgba. r ( ) ) ;
373
374
pixels. push ( srgba. g ( ) ) ;
374
375
pixels. push ( srgba. b ( ) ) ;
Original file line number Diff line number Diff line change @@ -17,10 +17,19 @@ impl Texture {
17
17
}
18
18
19
19
/// Returns the textures as `sRGBA` premultiplied pixels, row by row, top to bottom.
20
- pub fn srgba_pixels ( & ' _ self ) -> impl Iterator < Item = super :: Color32 > + ' _ {
20
+ ///
21
+ /// `gamma` should normally be set to 1.0.
22
+ /// If you are having problems with egui text looking skinny and pixelated, try
23
+ /// setting a lower gamma, e.g. `0.5`.
24
+ pub fn srgba_pixels ( & ' _ self , gamma : f32 ) -> impl Iterator < Item = super :: Color32 > + ' _ {
21
25
use super :: Color32 ;
22
- let srgba_from_luminance_lut: Vec < Color32 > =
23
- ( 0 ..=255 ) . map ( Color32 :: from_white_alpha) . collect ( ) ;
26
+
27
+ let srgba_from_luminance_lut: Vec < Color32 > = ( 0 ..=255 )
28
+ . map ( |a| {
29
+ let a = super :: color:: linear_f32_from_linear_u8 ( a) . powf ( gamma) ;
30
+ super :: Rgba :: from_white_alpha ( a) . into ( )
31
+ } )
32
+ . collect ( ) ;
24
33
self . pixels
25
34
. iter ( )
26
35
. map ( move |& l| srgba_from_luminance_lut[ l as usize ] )
You can’t perform that action at this time.
0 commit comments