plotille:rotating_cube
차이
문서의 선택한 두 판 사이의 차이를 보여줍니다.
| 양쪽 이전 판이전 판다음 판 | 이전 판 | ||
| plotille:rotating_cube [2020/06/17 13:15] – rex8312 | plotille:rotating_cube [2024/03/23 02:42] (현재) – 바깥 편집 127.0.0.1 | ||
|---|---|---|---|
| 줄 9: | 줄 9: | ||
| # drawille의 rotating cube를 plotille를 사용하도록 포팅 | # drawille의 rotating cube를 plotille를 사용하도록 포팅 | ||
| - | import sys | ||
| import math | import math | ||
| - | import time | ||
| - | from IPython import embed | ||
| import random | import random | ||
| - | import | + | import |
| + | import threading | ||
| + | import time | ||
| + | from queue import Queue | ||
| + | import numpy as np | ||
| import plotille | import plotille | ||
| + | from IPython import embed | ||
| from plotille import Canvas | from plotille import Canvas | ||
| + | |||
| + | def keyboard(queue): | ||
| + | import platform | ||
| + | |||
| + | if platform.system() == ' | ||
| + | import msvcrt | ||
| + | from msvcrt import kbhit | ||
| + | from msvcrt import getch | ||
| + | | ||
| + | while True: | ||
| + | if msvcrt.kbhit(): | ||
| + | queue.put(msvcrt.getch()) | ||
| + | | ||
| + | elif platform.system() == ' | ||
| + | import curses | ||
| + | import time | ||
| + | |||
| + | stdscr = curses.initscr() | ||
| + | stdscr.refresh() | ||
| + | |||
| + | while True: | ||
| + | queue.put(stdscr.getch()) | ||
| + | | ||
| class Screen: | class Screen: | ||
| 줄 137: | 줄 162: | ||
| # 변환 행렬 | # 변환 행렬 | ||
| TR = R(2, 3, 5) @ T(0, 0, 0) | TR = R(2, 3, 5) @ T(0, 0, 0) | ||
| + | |||
| + | key = Queue() | ||
| + | threading.Thread(target=keyboard, | ||
| + | |||
| + | colors = [' | ||
| while True: | while True: | ||
| + | if not key.empty() and key.get() == b' ': | ||
| + | colors = colors[1:] + colors[:1] | ||
| + | | ||
| canvas = Canvas(height=screen.height, | canvas = Canvas(height=screen.height, | ||
| 줄 155: | 줄 188: | ||
| for f in faces: | for f in faces: | ||
| - | canvas.line(t[f[0]].x, | + | canvas.line(t[f[0]].x, |
| - | canvas.line(t[f[1]].x, | + | canvas.line(t[f[1]].x, |
| - | canvas.line(t[f[2]].x, | + | canvas.line(t[f[2]].x, |
| - | canvas.line(t[f[3]].x, | + | canvas.line(t[f[3]].x, |
| screen.write(canvas.plot()) | screen.write(canvas.plot()) | ||
| + | |||
| </ | </ | ||
plotille/rotating_cube.1592399736.txt.gz · 마지막으로 수정됨: (바깥 편집)