@@ -53,6 +53,14 @@ impl Color {
5353 a,
5454 }
5555 }
56+
57+ pub fn packet_u32 ( & self ) -> u32 {
58+ let r = self . r * 255.0 ;
59+ let g = self . g * 255.0 ;
60+ let b = self . b * 255.0 ;
61+ let a = self . a * 255.0 ;
62+ ( ( a as u32 ) << 24 ) | ( ( r as u32 ) << 16 ) | ( ( g as u32 ) << 8 ) | ( b as u32 )
63+ }
5664}
5765
5866#[ derive( Debug , Clone , Copy , Eq , PartialEq ) ]
@@ -184,6 +192,7 @@ pub struct TextRenderElement {
184192 pub size : f32 ,
185193 pub bold : bool ,
186194 pub text : String ,
195+ pub color : Color ,
187196}
188197
189198#[ derive( Debug , Clone ) ]
@@ -869,6 +878,8 @@ pub struct Label {
869878 pos : Point ,
870879 size : Size ,
871880 font_size : f32 ,
881+ text_justify : TextJustify ,
882+ color : Color ,
872883 text : String ,
873884 icon : String ,
874885 bold : bool ,
@@ -890,6 +901,8 @@ impl Label {
890901 pos : Point :: zero ( ) ,
891902 size : Size :: new ( 50.0 , 50.0 ) ,
892903 font_size : 13.0 ,
904+ text_justify : TextJustify :: Center ,
905+ color : Color :: new ( 1.0 , 1.0 , 1.0 , 1.0 ) ,
893906 text : String :: new ( ) ,
894907 icon : String :: new ( ) ,
895908 bold : false ,
@@ -929,6 +942,16 @@ impl Label {
929942 self
930943 }
931944
945+ pub fn color ( mut self , color : impl Into < Color > ) -> Self {
946+ self . color = color. into ( ) ;
947+ self
948+ }
949+
950+ pub fn text_justify ( mut self , text_justify : TextJustify ) -> Self {
951+ self . text_justify = text_justify;
952+ self
953+ }
954+
932955 pub fn text ( mut self , text : impl Into < String > ) -> Self {
933956 self . text = text. into ( ) ;
934957 self
@@ -951,10 +974,11 @@ impl Label {
951974 if !self . text . is_empty ( ) {
952975 layer. text . push ( TextRenderElement {
953976 rect,
954- text_justify : TextJustify :: Center ,
977+ text_justify : self . text_justify ,
955978 size : self . font_size ,
956979 bold : self . bold ,
957980 text : self . text . to_string ( ) ,
981+ color : self . color ,
958982 } ) ;
959983 }
960984
0 commit comments