maliang.three¶
字数 11 个 阅读时间不到 1 分钟 访问量
Extension package of maliang for simple 3D drawings
Provides:
- Pure 3D implementation with no third-party packages
- Simple 3D drawing and manipulation
- Themed 3D drawings
模块:
-
engine
–Core codes of 3D
-
geometries
–Standard Geometries
类:
-
Canvas
–Base class of 3D Canvas
-
Space
–A canvas where you can view 3D objects
-
Component
–3D 对象基类
-
Point
–点
-
Line
–线
-
Plane
–面
-
Text3D
–三维文本
-
Geometry
–几何体
-
Cuboid
–Cuboid
-
Tetrahedron
–Tetrahedron
函数:
-
translate
–将一个三维空间中的点进行平移
-
rotate
–将一个三维空间中的点以一个点或线为参照进行旋转(实现方式为欧拉角)
-
scale
–将一个三维空间中的点以另一个点为缩放中心进行缩放
-
project
–将一个三维空间中的点投影到指定距离的正向平面上,并返回在该平面上的坐标
Canvas ¶
Canvas(
master: containers.Tk | containers.Toplevel | containers.Canvas | None = None,
*,
expand: typing.Literal["", "x", "y", "xy"] = "xy",
auto_zoom: bool = False,
keep_ratio: typing.Literal["min", "max"] | None = None,
free_anchor: bool = False,
**kwargs
)
Bases: containers.Canvas
Base class of 3D Canvas
方法:
-
space_sort
–Sort the contextual relationship between the spatial positions of the components
属性:
-
components
(tuple[Component, ...]
) –Return all
Component
of this Canvas -
geometries
(tuple[Geometry, ...]
) –Return all
Geometry
of this Canvas
Space ¶
Space(
master: containers.Tk | containers.Toplevel | containers.Canvas | None = None,
*,
expand: typing.Literal["", "x", "y", "xy"] = "xy",
auto_zoom: bool = False,
keep_ratio: typing.Literal["min", "max"] | None = None,
free_anchor: bool = False,
**kwargs
)
Component ¶
Point ¶
Line ¶
Plane ¶
Text3D ¶
Geometry ¶
几何体
canvas
: 父画布sides
: 组成几何体的面
方法:
Cuboid ¶
Cuboid(
canvas: engine.Canvas | engine.Space,
x: float,
y: float,
z: float,
length: float,
width: float,
height: float,
*,
boardwidth: int = 1,
color_fill_up: str = "",
color_fill_down: str = "",
color_fill_left: str = "",
color_fill_right: str = "",
color_fill_front: str = "",
color_fill_back: str = "",
color_outline_up: str = "#000000",
color_outline_down: str = "#000000",
color_outline_left: str = "#000000",
color_outline_right: str = "#000000",
color_outline_front: str = "#000000",
color_outline_back: str = "#000000"
)
Tetrahedron ¶
Tetrahedron(
canvas: engine.Canvas | engine.Space,
point_1: tuple[float, float, float],
point_2: tuple[float, float, float],
point_3: tuple[float, float, float],
point_4: tuple[float, float, float],
*,
boardwidth: int = 1,
color_fill: tuple[str, str, str, str] = ("", "", "", ""),
color_outline: tuple[str, str, str, str] = ("#000000", "#000000", "#000000", "#000000")
)
translate ¶
translate(
coordinate: tuple[float, float, float], dx: float = 0, dy: float = 0, dz: float = 0
) -> None
将一个三维空间中的点进行平移
coordinate
: 点的空间坐标dx
: x 方向位移长度dy
: y 方向位移长度dz
: z 方向位移长度
rotate ¶
将一个三维空间中的点以一个点或线为参照进行旋转(实现方式为欧拉角)
coordinate
: 点的空间坐标dx
: x 方向逆时针旋转弧度,或者绕旋转轴线的旋转弧度dy
: y 方向逆时针旋转弧度dz
: z 方向逆时针旋转弧度center
: 旋转中心的空间坐标axis
: 旋转轴线的空间坐标
scale ¶
将一个三维空间中的点以另一个点为缩放中心进行缩放
coordinate
: 点的空间坐标kx
: x 方向缩放比例ky
: y 方向缩放比例kz
: z 方向缩放比例center
: 缩放中心的空间坐标
project ¶
将一个三维空间中的点投影到指定距离的正向平面上,并返回在该平面上的坐标
coordinate
: 点的空间坐标distance
: 正向平面的距离(平面正对着我们)