text
stringlengths
0
828
if isinstance(newBuffer, dict):
self._buffer = Image.new( newBuffer[""color_mode""] , newBuffer[""size""] )
self.Canvas = ImageDraw.Draw( self._buffer )
return True
pass"
4831,"def write(self, text="""", xy=(0,0), align=""left"", font=None, fontName=None, fontSize = 10, fill = 1, spacing = 0, screenCenter = False):
""""""!
\~english
Print one line text or multi-line text on the screen
@param text: Text to be drawn. eg. ""Hello World!"" or ""Hello/nWorld!""
@param xy: Top left corner of the text. defaule: (0,0)
@param align: ""left"", ""center"" or ""right"". defaule: ""left""
@param fontName: Name of font or font instance. defaule: None (use default font)
@param fontSize: Font size. default: 10
@param fill: Color to use for the text. default: 1 (white)
@param spacing: The number of pixels between lines. default: 0
@param screenCenter: Keep the text center of screen. default: False
@note
How to use screenCenter?
1. align=""left""; screenCenter=False
<pre>
+---------------------------------+
| Simple text line1 |
| Simple line2 |
| Simple |
| |
+---------------------------------+
</pre>
2. align=""left""; screenCenter=True
<pre>
+---------------------------------+
| Simple text line1 |
| Simple line2 |
| Simple |
| |
+---------------------------------+
</pre>
\~chinese
在屏幕上打印一行文字或多行文字
@param text: 要输出的文字,可以单行也可以多行。例如: ""Hello World!"" 或 ""Hello/nWorld!""
@param xy: 文字输出的坐标点。默认: (0,0)
@param align: 多行文字对齐方式,可选: ""left"", ""center"" 或 ""right"". 默认: ""left""
@param fontName: 字体名或字体对象实例。默认:None(使用系统默认的字体)
@param fontSize: 字体大小。默认:10
@param fill: 文字颜色。默认: 1 (白色)
@param spacing: 行间距。默认:0
@param screenCenter: 让文本居中屏幕。
@note
screenCenter 效果示例:
1. align=""left""; screenCenter=False
<pre>
+---------------------------------+
| Simple text line1 |
| Simple line2 |
| Simple |
| |
+---------------------------------+
</pre>
2. align=""left""; screenCenter=True
<pre>
+---------------------------------+
| Simple text line1 |
| Simple line2 |
| Simple |
| |
+---------------------------------+
</pre>
""""""
tx = xy[0]
try:
dwFont = font if font != None else DEF_SCR_FRONT if fontName==None else ImageFont.truetype(fontName, fontSize)
except:
dwFont = DEF_SCR_FRONT
try:
if screenCenter == True:
(fw, fh) = self.Canvas.multiline_textsize( text, font )
tx = xy[0] + (self._display_size[0]-fw)/2
self.Canvas.multiline_text( (tx, xy[1]) , text, font = dwFont, align=align, fill=fill, spacing=spacing)
except:
print(""ERROR: canvas write error"")"
4832,"def resize(self, newWidth = 0, newHeight = 0):
""""""!
\~english
Resize width and height of rectangles
@param newWidth: new width value
@param newHeight: new height value
\~chinese
重新设定矩形高宽
@param newWidth: 新宽度
@param newHeight: 新高度
""""""
self.height = newHeight
self.width = newWidth"