File tree 2 files changed +41
-16
lines changed
2 files changed +41
-16
lines changed Original file line number Diff line number Diff line change @@ -5,14 +5,48 @@ import snow.api.buffers.*;
5
5
6
6
class CharAttr {
7
7
public var char : Int ;
8
- public var fg : Color ;
9
- public var bg : Uint8Array ;
8
+
9
+ public var fg (get , set ): Color ;
10
+ private var _fg : Color ;
11
+
12
+ public var bg (get , set ): Uint8Array ;
13
+ private var _bg : Uint8Array ;
14
+
10
15
public var attr : Int ;
11
16
12
17
public function new () {
13
18
char = 0 ;
14
- fg = new Color ();
15
- bg = new Uint8Array (3 );
19
+ _fg = new Color ();
20
+ _bg = new Uint8Array (3 );
16
21
attr = 0 ;
17
22
}
23
+
24
+ public inline function get_fg (): Color {
25
+ return _fg ;
26
+ }
27
+
28
+ public inline function set_fg (color : Color ): Color {
29
+ _fg .r = color .r ;
30
+ _fg .g = color .g ;
31
+ _fg .b = color .b ;
32
+ return _fg ;
33
+ }
34
+
35
+ public inline function set_bg_color (color : Color ): Uint8Array {
36
+ _bg [0 ] = Std .int (color .r * 255 );
37
+ _bg [1 ] = Std .int (color .g * 255 );
38
+ _bg [2 ] = Std .int (color .b * 255 );
39
+ return _bg ;
40
+ }
41
+
42
+ public inline function set_bg (color : Uint8Array ): Uint8Array {
43
+ _bg [0 ] = color [0 ];
44
+ _bg [1 ] = color [1 ];
45
+ _bg [2 ] = color [2 ];
46
+ return _bg ;
47
+ }
48
+
49
+ public inline function get_bg (): Uint8Array {
50
+ return _bg ;
51
+ }
18
52
}
Original file line number Diff line number Diff line change @@ -43,21 +43,14 @@ class TextBuffer {
43
43
if (x < 0 || y < 0 || x >= width || y >= height )
44
44
return ;
45
45
46
- var c : Color = data [y * width + x ].fg ;
47
- c .r = color .r ;
48
- c .g = color .g ;
49
- c .b = color .b ;
46
+ data [y * width + x ].fg = color ;
50
47
}
51
48
52
49
public function set_bg_color (x : Int , y : Int , color : Color ) {
53
50
if (x < 0 || y < 0 || x >= width || y >= height )
54
51
return ;
55
52
56
- var bg = data [y * width + x ].bg ;
57
-
58
- bg [0 ] = Std .int (color .r * 255 );
59
- bg [1 ] = Std .int (color .g * 255 );
60
- bg [2 ] = Std .int (color .b * 255 );
53
+ data [y * width + x ].set_bg_color (color );
61
54
}
62
55
63
56
// Draw a TextBuffer onto this one at (xPos, yPos), taking into account transparency.
@@ -87,9 +80,7 @@ class TextBuffer {
87
80
if (src_data .attr & 0x02 != 0 )
88
81
continue ;
89
82
90
- dst_data .fg .r = src_data .fg .r ;
91
- dst_data .fg .g = src_data .fg .g ;
92
- dst_data .fg .b = src_data .fg .b ;
83
+ dst_data .fg = src_data .fg ;
93
84
94
85
dst_data .char = src_data .char ;
95
86
dst_data .bg [0 ] = src_data .bg [0 ];
You can’t perform that action at this time.
0 commit comments