@@ -54,19 +54,19 @@ def __init__(self,
54
54
img_format: 默认显示图像时使用的模式:framebuf.MONO_HLSB(单色显示),framebuf.RGB565(彩色显示)
55
55
"""
56
56
self .display = display
57
- self ._reverse = reverse
58
- self ._clear = clear
59
- self ._show = show
57
+ self .any_reverse = reverse
58
+ self .any_clear = clear
59
+ self .any_show = show
60
60
if font_file :
61
61
self ._font = BMFont (font_file ) # 字体显示
62
- self ._font_color = font_color
63
- self ._font_size = font_size
64
- self ._font_half_char = font_half_char
65
- self ._font_auto_wrap = font_auto_wrap
66
- self ._font_alpha_bg = font_alpha_bg
67
- self ._img_alpha = img_alpha
68
- self ._img_color = img_color
69
- self ._img_format = img_format
62
+ self .font_color = font_color
63
+ self .font_size = font_size
64
+ self .font_half_char = font_half_char
65
+ self .font_auto_wrap = font_auto_wrap
66
+ self .font_alpha_bg = font_alpha_bg
67
+ self .img_alpha = img_alpha
68
+ self .img_color = img_color
69
+ self .img_format = img_format
70
70
71
71
@staticmethod
72
72
def rgb (r , g , b ): # 感谢 ChatGPT 对代码的性能优化,性能提升 30%
@@ -104,21 +104,21 @@ def font(self, s: str, x: int, y: int, c: int = None, size: int = None, show: bo
104
104
alpha_bg: 背景透明
105
105
"""
106
106
if c is None :
107
- c = self ._font_color
107
+ c = self .font_color
108
108
if size is None :
109
- size = self ._font_size
109
+ size = self .font_size
110
110
if reverse is None :
111
- reverse = self ._reverse
111
+ reverse = self .any_reverse
112
112
if clear is None :
113
- clear = self ._clear
113
+ clear = self .any_clear
114
114
if show is None :
115
- show = self ._show
115
+ show = self .any_show
116
116
if half_char is None :
117
- half_char = self ._font_half_char
117
+ half_char = self .font_half_char
118
118
if auto_wrap is None :
119
- auto_wrap = self ._font_auto_wrap
119
+ auto_wrap = self .font_auto_wrap
120
120
if alpha_bg is None :
121
- alpha_bg = self ._font_alpha_bg
121
+ alpha_bg = self .font_alpha_bg
122
122
123
123
self ._font .text (
124
124
display = self .display , # 显示对象 必要
@@ -159,17 +159,17 @@ def pbm(self, file: str, x, y, show: bool = None, clear: bool = None, color: int
159
159
format: 显示图像时使用的模式:framebuf.MONO_HLSB(单色显示),framebuf.RGB565(彩色显示)
160
160
"""
161
161
if show is None :
162
- show = self ._show
162
+ show = self .any_show
163
163
if clear is None :
164
- clear = self ._clear
164
+ clear = self .any_clear
165
165
if color is None :
166
- color = self ._img_color
166
+ color = self .img_color
167
167
if alpha is None :
168
- alpha = self ._img_alpha
168
+ alpha = self .img_alpha
169
169
if reverse is None :
170
- reverse = self ._reverse
170
+ reverse = self .any_reverse
171
171
if format is None :
172
- format = self ._img_format
172
+ format = self .img_format
173
173
if clear : # 清屏
174
174
self .clear ()
175
175
with open (file , "rb" ) as f :
@@ -245,17 +245,17 @@ def bmp(self, file: str, x, y, show: bool = None, clear: bool = None, color: int
245
245
format: 显示图像时使用的模式:framebuf.MONO_HLSB(单色显示),framebuf.RGB565(彩色显示)
246
246
"""
247
247
if show is None :
248
- show = self ._show
248
+ show = self .any_show
249
249
if clear is None :
250
- clear = self ._clear
250
+ clear = self .any_clear
251
251
if color is None :
252
- color = self ._img_color
252
+ color = self .img_color
253
253
if alpha is None :
254
- alpha = self ._img_alpha
254
+ alpha = self .img_alpha
255
255
if reverse is None :
256
- reverse = self ._reverse
256
+ reverse = self .any_reverse
257
257
if format is None :
258
- format = self ._img_format
258
+ format = self .img_format
259
259
with open (file , 'rb' ) as f :
260
260
if f .read (2 ) == b'BM' : # 检查文件头来判断是否为支持的文件类型
261
261
dummy = f .read (8 ) # 文件大小占四个字节,文件作者占四个字节,file size(4), creator bytes(4)
0 commit comments