graphics¶
classDiagram
CharmyObject <|-- DrawnObject
DrawnObject <|-- DrawnLine
DrawnObject <|-- DrawnShape
DrawnObject <|-- DrawnText
A set of classes represent drawn objects on window. Part of the graphics layer of Charmy.
- class charmy.graphics.DrawnObject(window: _window.WindowEntity)¶
基类:
CharmyObjectBase class of drawn objects in Charmy.
- __init__(window: _window.WindowEntity)¶
To represent a drawn object, inherit this class.
- abstractmethod draw(*args, **kwargs) Self¶
- abstract property boundary: tuple[tuple[int, int], tuple[int, int]]¶
- class charmy.graphics.DrawnLine(window: _window.WindowEntity, line: _styles.shape.LinePath, texture: _styles.texture.Texture | _styles.texture.TextureLike, width: int = 5, offset: _styles.shape.Point | _typing.Literal['auto'] = 'auto', anchor: _styles.shape.Point | _typing.Literal['auto'] = 'auto')¶
基类:
DrawnObjectA class used to represent lines drawn to GUI or canvas.
- __init__(window: _window.WindowEntity, line: _styles.shape.LinePath, texture: _styles.texture.Texture | _styles.texture.TextureLike, width: int = 5, offset: _styles.shape.Point | _typing.Literal['auto'] = 'auto', anchor: _styles.shape.Point | _typing.Literal['auto'] = 'auto')¶
Used to express lines drawn on GUI or canvas.
- 参数:
line -- The line (to be drawn)
texture -- Texture of the drawn line
width -- Line width
offset -- Position offset of the drawn line
anchor -- Point of anchor on the original line
- property boundary: tuple[tuple[int, int], tuple[int, int]]¶
Rect boundary of the drawn line
- class charmy.graphics.DrawnShape(window: _window.WindowEntity, shape: _styles.shape.ShapeType, texture: _styles.texture.Texture | _styles.texture.TextureLike, border_width: int = 0, border_texture: _styles.texture.Texture | _styles.texture.TextureLike = None, offset: _styles.shape.Point | _typing.Literal['auto'] = 'auto', anchor: _styles.shape.Point | _typing.Literal['auto'] = 'auto')¶
基类:
DrawnObjectA Class used to represent shapes drawn to GUI or canvas.
- __init__(window: _window.WindowEntity, shape: _styles.shape.ShapeType, texture: _styles.texture.Texture | _styles.texture.TextureLike, border_width: int = 0, border_texture: _styles.texture.Texture | _styles.texture.TextureLike = None, offset: _styles.shape.Point | _typing.Literal['auto'] = 'auto', anchor: _styles.shape.Point | _typing.Literal['auto'] = 'auto')¶
Used to express shapes drawn on GUI or canvas.
- 参数:
shape -- The shape (to be drawn)
texture -- styles.texture.Texture inside the drawn shape
border_width -- Border width in px, positive for outer and negative for inner
border_texture -- styles.texture.Texture of the drawn border
offset -- Position offset of the drawn shape
anchor -- Point of anchor on the original shape
- property boundary: tuple[tuple[int, int], tuple[int, int]]¶
Rect boundary of the drawn shape.
- copy() DrawnShape¶
- class charmy.graphics.DrawnText(window: _window.WindowEntity, text: str, style: _styles.text_style.TextStyle, texture: _styles.texture.Texture | _styles.texture.TextureLike, offset: _styles.shape.Point | _typing.Literal['auto'] = 'auto', anchor: _styles.shape.Point | _typing.Literal['auto'] = 'auto')¶
基类:
DrawnObjectA class used to represent texts drawn to GUI or canvas.
Notes For Getting Boundary¶
Text relies on backend to render in most cases, so its boundary should be gotten from backend.
- __init__(window: _window.WindowEntity, text: str, style: _styles.text_style.TextStyle, texture: _styles.texture.Texture | _styles.texture.TextureLike, offset: _styles.shape.Point | _typing.Literal['auto'] = 'auto', anchor: _styles.shape.Point | _typing.Literal['auto'] = 'auto')¶
Used to express text drawn on GUI or canvas.
- 参数:
text -- The text content, in Python string
style -- The text style to use
texture -- The texture to use on
offset -- Position of the drawn text
anchor -- Point of anchor on the text
- property boundary: tuple[tuple[int, int], tuple[int, int]]¶
Rect boundary of the drawn text.
- draw() Self¶
Draw the text.
- 参数:
window -- The window to draw text to