tkintertools-3d


Nametkintertools-3d JSON
Version 1.0.3 PyPI version JSON
download
home_pageNone
SummaryExtension package for tkintertools to simple 3D drawings
upload_time2025-01-13 14:42:18
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseMIT License
keywords tkinter tkintertools 3d cross-platform
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <h1 align="center">tkintertools-3d</h1>

<p align="center"><a title="Official Website" href="https://xiaokang2022.github.io/tkintertools/">https://xiaokang2022.github.io/tkintertools/</a></p>

<p align="center">Extension package of <code>tkintertools</code> for simple 3D drawings</p>

<p align="center">
<a href="https://github.com/Xiaokang2022/tkintertools-3d/releases"><img alt="Version" src="https://img.shields.io/github/v/release/Xiaokang2022/tkintertools-3d?include_prereleases&logo=github&label=Version" title="Latest Version" /></a>
<a href="https://pypistats.org/packages/tkintertools-3d"><img alt="Downloads" src="https://img.shields.io/pypi/dm/tkintertools-3d?label=Downloads&logo=pypi&logoColor=skyblue" title="Downloads" /></a>
<a href="https://pepy.tech/project/tkintertools-3d"><img alt="Total Downloads" src="https://img.shields.io/pepy/dt/tkintertools-3d?logo=pypi&logoColor=gold&label=Total%20Downloads" title="Total Downloads" /></a>
<a href="https://github.com/Xiaokang2022/tkintertools-3d"><img alt="Size" src="https://img.shields.io/github/languages/code-size/Xiaokang2022/tkintertools-3d?label=Size&logo=github" title="Code Size"/></a>
<br/>
<a href="https://github.com/Xiaokang2022/tkintertools-3d/watchers"><img alt="Watchers" src="https://img.shields.io/github/watchers/Xiaokang2022/tkintertools-3d?label=Watchers&logo=github&style=flat" title="Watchers" /></a>
<a href="https://github.com/Xiaokang2022/tkintertools-3d/forks"><img alt="Forks" src="https://img.shields.io/github/forks/Xiaokang2022/tkintertools-3d?label=Forks&logo=github&style=flat" title="Forks" /></a>
<a href="https://github.com/Xiaokang2022/tkintertools-3d/stargazers"><img alt="Stars" src="https://img.shields.io/github/stars/Xiaokang2022/tkintertools-3d?label=Stars&color=gold&logo=github&style=flat" title="Stars" /></a>
<a href="https://github.com/Xiaokang2022/tkintertools-3d/issues"><img alt="Issues" src="https://img.shields.io/github/issues/Xiaokang2022/tkintertools-3d?label=Issues&logo=github" title="Issues" /></a>
<a href="https://github.com/Xiaokang2022/tkintertools-3d/pulls"><img alt="Pull Requests" src="https://img.shields.io/github/issues-pr/Xiaokang2022/tkintertools-3d?label=Pull%20Requests&logo=github" title="Pull Requests" /></a>
<a href="https://github.com/Xiaokang2022/tkintertools-3d/discussions"><img alt="Discussions" src="https://img.shields.io/github/discussions/Xiaokang2022/tkintertools-3d?label=Discussions&logo=github" title="Discussions" /></a>
</p>

<p align="center">
<a href="https://github.com/Xiaokang2022/tkintertools-3d/pulse"><img alt="Insights" src="https://repobeats.axiom.co/api/embed/bdabcdebf74f33dcec27065e08f54c8e2d58a4d0.svg" /></a>
</p>

<p align="center">
    <a href="https://star-history.com/#Xiaokang2022/tkintertools-3d&Date">
        <picture>
            <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=Xiaokang2022/tkintertools-3d&type=Date&theme=dark" />
            <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=Xiaokang2022/tkintertools-3d&type=Date" />
            <img alt="Star History Chart" src="https://api.star-history.com/svg?repos=Xiaokang2022/tkintertools-3d&type=Date" />
        </picture>
    </a>
</p>

📦 Installation
----------------

```bash
pip install tkintertools-3d
```

### 👀 Preview

![preview](preview.png)

```python
import itertools
import math
import statistics

import tkintertools as tkt
from tkintertools import theme, three

tk = tkt.Tk(title="tkintertools-3d")
space = three.Space(auto_zoom=True, free_anchor=True, keep_ratio="min")
space.light.update(bg="white")
space.dark.update(bg="black")
space.configure(bg="black" if theme.get_color_mode() == "dark" else "light")
space.place(width=1280, height=720, x=640, y=360, anchor="center")
space.update()  # NOTE: This line is very important!

### Inside ###

m = 150 * math.sqrt(50 - 10*math.sqrt(5)) / 10
n = 150 * math.sqrt(50 + 10*math.sqrt(5)) / 10
points = []
dis_side = (
    150
    * (3 * math.sqrt(3) + math.sqrt(15))
    / 12
    / ((math.sqrt(10 + 2 * math.sqrt(5))) / 4)
)
count, color_lst = 0, ["00", "77", "FF"]
colors = [f"#{r}{g}{b}" for r in color_lst for g in color_lst for b in color_lst]

for i in m, -m:
    for j in n, -n:
        points.append([0, j, i])
        points.append([i, 0, j])
        points.append([j, i, 0])

for p in itertools.combinations(points, 3):
    dis = math.hypot(*[statistics.mean(c[i] for c in p) for i in range(3)])
    if math.isclose(dis, dis_side):
        three.Plane(space, *p, fill=colors[count], outline="grey")
        count += 1

### Outside ###

r = 250

O = three.Point(space, (0, 0, 0), fill='white', size=3)
X = three.Line(space, (0, 0, 0), (1, 0, 0), fill='')
Y = three.Line(space, (0, 0, 0), (0, 1, 0), fill='')
Z = three.Line(space, (0, 0, 0), (0, 0, 1), fill='')

ring: dict[str, list[three.Text3D]] = {'x': [], 'y': [], 'z': []}
line: dict[str, list[three.Text3D]] = {'x': [], 'y': [], 'z': []}

for i in range(26):
    t = chr(65+i)
    φ = i/26 * math.tau
    c1 = r * math.sin(φ)
    c2 = r * math.cos(φ)
    ring['x'].append(three.Text3D(space, (0, c1, c2), text=t, fill='#FF0000'))
    ring['y'].append(three.Text3D(space, (c1, 0, c2), text=t, fill='#00FF00'))
    ring['z'].append(three.Text3D(space, (c1, c2, 0), text=t, fill='#0000FF'))

for i in range(10):
    t = str(i)
    c = (i+1) * 500/11 - r
    line['x'].append(three.Text3D(space, (c, 0, 0), text=t, fill='#00FFFF'))
    line['y'].append(three.Text3D(space, (0, c, 0), text=t, fill='#FF00FF'))
    line['z'].append(three.Text3D(space, (0, 0, c), text=t, fill='#FFFF00'))


def text_animation() -> None:
    """Make the Text spin."""
    for obj3D in ring['x']:
        obj3D.rotate(0.05, axis=X.coordinates)
    for obj3D in ring['y']:
        obj3D.rotate(0.05, axis=Y.coordinates)
    for obj3D in ring['z']:
        obj3D.rotate(0.05, axis=Z.coordinates)
    for obj3D in line['x']:
        obj3D.rotate(-0.05, axis=Y.coordinates)
    for obj3D in line['y']:
        obj3D.rotate(-0.05, axis=Z.coordinates)
    for obj3D in line['z']:
        obj3D.rotate(-0.05, axis=X.coordinates)
    for obj3D in space.components:
        obj3D.rotate(0, -0.01, 0.01, center=O.center())
        obj3D.update()
    space.space_sort()
    tk.after(10, text_animation)


text_animation()
tk.mainloop()
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "tkintertools-3d",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "Xiaokang2022 <2951256653@qq.com>",
    "keywords": "tkinter, tkintertools, 3d, cross-platform",
    "author": null,
    "author_email": "Xiaokang2022 <2951256653@qq.com>",
    "download_url": "https://files.pythonhosted.org/packages/b7/3d/68cd0ea02fca73fb8de04b52514ea3b41e2abecd8f100483a29aaa0f2f2a/tkintertools_3d-1.0.3.tar.gz",
    "platform": null,
    "description": "<h1 align=\"center\">tkintertools-3d</h1>\r\n\r\n<p align=\"center\"><a title=\"Official Website\" href=\"https://xiaokang2022.github.io/tkintertools/\">https://xiaokang2022.github.io/tkintertools/</a></p>\r\n\r\n<p align=\"center\">Extension package of <code>tkintertools</code> for simple 3D drawings</p>\r\n\r\n<p align=\"center\">\r\n<a href=\"https://github.com/Xiaokang2022/tkintertools-3d/releases\"><img alt=\"Version\" src=\"https://img.shields.io/github/v/release/Xiaokang2022/tkintertools-3d?include_prereleases&logo=github&label=Version\" title=\"Latest Version\" /></a>\r\n<a href=\"https://pypistats.org/packages/tkintertools-3d\"><img alt=\"Downloads\" src=\"https://img.shields.io/pypi/dm/tkintertools-3d?label=Downloads&logo=pypi&logoColor=skyblue\" title=\"Downloads\" /></a>\r\n<a href=\"https://pepy.tech/project/tkintertools-3d\"><img alt=\"Total Downloads\" src=\"https://img.shields.io/pepy/dt/tkintertools-3d?logo=pypi&logoColor=gold&label=Total%20Downloads\" title=\"Total Downloads\" /></a>\r\n<a href=\"https://github.com/Xiaokang2022/tkintertools-3d\"><img alt=\"Size\" src=\"https://img.shields.io/github/languages/code-size/Xiaokang2022/tkintertools-3d?label=Size&logo=github\" title=\"Code Size\"/></a>\r\n<br/>\r\n<a href=\"https://github.com/Xiaokang2022/tkintertools-3d/watchers\"><img alt=\"Watchers\" src=\"https://img.shields.io/github/watchers/Xiaokang2022/tkintertools-3d?label=Watchers&logo=github&style=flat\" title=\"Watchers\" /></a>\r\n<a href=\"https://github.com/Xiaokang2022/tkintertools-3d/forks\"><img alt=\"Forks\" src=\"https://img.shields.io/github/forks/Xiaokang2022/tkintertools-3d?label=Forks&logo=github&style=flat\" title=\"Forks\" /></a>\r\n<a href=\"https://github.com/Xiaokang2022/tkintertools-3d/stargazers\"><img alt=\"Stars\" src=\"https://img.shields.io/github/stars/Xiaokang2022/tkintertools-3d?label=Stars&color=gold&logo=github&style=flat\" title=\"Stars\" /></a>\r\n<a href=\"https://github.com/Xiaokang2022/tkintertools-3d/issues\"><img alt=\"Issues\" src=\"https://img.shields.io/github/issues/Xiaokang2022/tkintertools-3d?label=Issues&logo=github\" title=\"Issues\" /></a>\r\n<a href=\"https://github.com/Xiaokang2022/tkintertools-3d/pulls\"><img alt=\"Pull Requests\" src=\"https://img.shields.io/github/issues-pr/Xiaokang2022/tkintertools-3d?label=Pull%20Requests&logo=github\" title=\"Pull Requests\" /></a>\r\n<a href=\"https://github.com/Xiaokang2022/tkintertools-3d/discussions\"><img alt=\"Discussions\" src=\"https://img.shields.io/github/discussions/Xiaokang2022/tkintertools-3d?label=Discussions&logo=github\" title=\"Discussions\" /></a>\r\n</p>\r\n\r\n<p align=\"center\">\r\n<a href=\"https://github.com/Xiaokang2022/tkintertools-3d/pulse\"><img alt=\"Insights\" src=\"https://repobeats.axiom.co/api/embed/bdabcdebf74f33dcec27065e08f54c8e2d58a4d0.svg\" /></a>\r\n</p>\r\n\r\n<p align=\"center\">\r\n    <a href=\"https://star-history.com/#Xiaokang2022/tkintertools-3d&Date\">\r\n        <picture>\r\n            <source media=\"(prefers-color-scheme: dark)\" srcset=\"https://api.star-history.com/svg?repos=Xiaokang2022/tkintertools-3d&type=Date&theme=dark\" />\r\n            <source media=\"(prefers-color-scheme: light)\" srcset=\"https://api.star-history.com/svg?repos=Xiaokang2022/tkintertools-3d&type=Date\" />\r\n            <img alt=\"Star History Chart\" src=\"https://api.star-history.com/svg?repos=Xiaokang2022/tkintertools-3d&type=Date\" />\r\n        </picture>\r\n    </a>\r\n</p>\r\n\r\n\ud83d\udce6 Installation\r\n----------------\r\n\r\n```bash\r\npip install tkintertools-3d\r\n```\r\n\r\n### \ud83d\udc40 Preview\r\n\r\n![preview](preview.png)\r\n\r\n```python\r\nimport itertools\r\nimport math\r\nimport statistics\r\n\r\nimport tkintertools as tkt\r\nfrom tkintertools import theme, three\r\n\r\ntk = tkt.Tk(title=\"tkintertools-3d\")\r\nspace = three.Space(auto_zoom=True, free_anchor=True, keep_ratio=\"min\")\r\nspace.light.update(bg=\"white\")\r\nspace.dark.update(bg=\"black\")\r\nspace.configure(bg=\"black\" if theme.get_color_mode() == \"dark\" else \"light\")\r\nspace.place(width=1280, height=720, x=640, y=360, anchor=\"center\")\r\nspace.update()  # NOTE: This line is very important!\r\n\r\n### Inside ###\r\n\r\nm = 150 * math.sqrt(50 - 10*math.sqrt(5)) / 10\r\nn = 150 * math.sqrt(50 + 10*math.sqrt(5)) / 10\r\npoints = []\r\ndis_side = (\r\n    150\r\n    * (3 * math.sqrt(3) + math.sqrt(15))\r\n    / 12\r\n    / ((math.sqrt(10 + 2 * math.sqrt(5))) / 4)\r\n)\r\ncount, color_lst = 0, [\"00\", \"77\", \"FF\"]\r\ncolors = [f\"#{r}{g}{b}\" for r in color_lst for g in color_lst for b in color_lst]\r\n\r\nfor i in m, -m:\r\n    for j in n, -n:\r\n        points.append([0, j, i])\r\n        points.append([i, 0, j])\r\n        points.append([j, i, 0])\r\n\r\nfor p in itertools.combinations(points, 3):\r\n    dis = math.hypot(*[statistics.mean(c[i] for c in p) for i in range(3)])\r\n    if math.isclose(dis, dis_side):\r\n        three.Plane(space, *p, fill=colors[count], outline=\"grey\")\r\n        count += 1\r\n\r\n### Outside ###\r\n\r\nr = 250\r\n\r\nO = three.Point(space, (0, 0, 0), fill='white', size=3)\r\nX = three.Line(space, (0, 0, 0), (1, 0, 0), fill='')\r\nY = three.Line(space, (0, 0, 0), (0, 1, 0), fill='')\r\nZ = three.Line(space, (0, 0, 0), (0, 0, 1), fill='')\r\n\r\nring: dict[str, list[three.Text3D]] = {'x': [], 'y': [], 'z': []}\r\nline: dict[str, list[three.Text3D]] = {'x': [], 'y': [], 'z': []}\r\n\r\nfor i in range(26):\r\n    t = chr(65+i)\r\n    \u03c6 = i/26 * math.tau\r\n    c1 = r * math.sin(\u03c6)\r\n    c2 = r * math.cos(\u03c6)\r\n    ring['x'].append(three.Text3D(space, (0, c1, c2), text=t, fill='#FF0000'))\r\n    ring['y'].append(three.Text3D(space, (c1, 0, c2), text=t, fill='#00FF00'))\r\n    ring['z'].append(three.Text3D(space, (c1, c2, 0), text=t, fill='#0000FF'))\r\n\r\nfor i in range(10):\r\n    t = str(i)\r\n    c = (i+1) * 500/11 - r\r\n    line['x'].append(three.Text3D(space, (c, 0, 0), text=t, fill='#00FFFF'))\r\n    line['y'].append(three.Text3D(space, (0, c, 0), text=t, fill='#FF00FF'))\r\n    line['z'].append(three.Text3D(space, (0, 0, c), text=t, fill='#FFFF00'))\r\n\r\n\r\ndef text_animation() -> None:\r\n    \"\"\"Make the Text spin.\"\"\"\r\n    for obj3D in ring['x']:\r\n        obj3D.rotate(0.05, axis=X.coordinates)\r\n    for obj3D in ring['y']:\r\n        obj3D.rotate(0.05, axis=Y.coordinates)\r\n    for obj3D in ring['z']:\r\n        obj3D.rotate(0.05, axis=Z.coordinates)\r\n    for obj3D in line['x']:\r\n        obj3D.rotate(-0.05, axis=Y.coordinates)\r\n    for obj3D in line['y']:\r\n        obj3D.rotate(-0.05, axis=Z.coordinates)\r\n    for obj3D in line['z']:\r\n        obj3D.rotate(-0.05, axis=X.coordinates)\r\n    for obj3D in space.components:\r\n        obj3D.rotate(0, -0.01, 0.01, center=O.center())\r\n        obj3D.update()\r\n    space.space_sort()\r\n    tk.after(10, text_animation)\r\n\r\n\r\ntext_animation()\r\ntk.mainloop()\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "Extension package for tkintertools to simple 3D drawings",
    "version": "1.0.3",
    "project_urls": {
        "Bug tracker": "https://github.com/Xiaokang2022/tkintertools-3d/issues",
        "Source code": "https://github.com/Xiaokang2022/tkintertools-3d"
    },
    "split_keywords": [
        "tkinter",
        " tkintertools",
        " 3d",
        " cross-platform"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cc577b6b321a5ded8637d787ef814f5a6ce11d04dae7bc05d47586ebea724033",
                "md5": "a3c95fdb877ad3e4a0bdbe9565d9e973",
                "sha256": "bb153108c0fc055ea785113be73a75364e0073e2b7cc197c80f436bd5775a493"
            },
            "downloads": -1,
            "filename": "tkintertools_3d-1.0.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a3c95fdb877ad3e4a0bdbe9565d9e973",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 10871,
            "upload_time": "2025-01-13T14:42:17",
            "upload_time_iso_8601": "2025-01-13T14:42:17.012353Z",
            "url": "https://files.pythonhosted.org/packages/cc/57/7b6b321a5ded8637d787ef814f5a6ce11d04dae7bc05d47586ebea724033/tkintertools_3d-1.0.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b73d68cd0ea02fca73fb8de04b52514ea3b41e2abecd8f100483a29aaa0f2f2a",
                "md5": "cba03356df861021a92841e4f29c5906",
                "sha256": "30532c4a3bdce0c8b5bf71174c356e4ecb2c3debf85def523b3c00ca1775bc94"
            },
            "downloads": -1,
            "filename": "tkintertools_3d-1.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "cba03356df861021a92841e4f29c5906",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 12177,
            "upload_time": "2025-01-13T14:42:18",
            "upload_time_iso_8601": "2025-01-13T14:42:18.595130Z",
            "url": "https://files.pythonhosted.org/packages/b7/3d/68cd0ea02fca73fb8de04b52514ea3b41e2abecd8f100483a29aaa0f2f2a/tkintertools_3d-1.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-13 14:42:18",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Xiaokang2022",
    "github_project": "tkintertools-3d",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "tkintertools-3d"
}
        
Elapsed time: 4.16509s