对不起我的语言表达有些破碎。
我是Python的初学者,但我别无选择,我需要它来完成一个项目,在这个项目中我必须通过编程创建ascii等距立方体。我不知道该如何做,所以我先从想法开始,找到“角落”的坐标(不是正确的词)来绘制瓷砖。
#what I expect really :
- for a 2 wide
.-⁻``⁻-.
.-⁻` `⁻-.
| |
| |
`⁻-. .-⁻`
`⁻-..-⁻`
- for 3 wide
.-⁻``⁻-.
.-⁻` `⁻-.
.-⁻` `⁻-.
| |
| |
`⁻-. .-⁻`
`⁻-. .-⁻`
`⁻-..-⁻`
# what I except for the beginning
- 2 wide
.-⁻``⁻-.
.-⁻` `⁻-.
`⁻-. .-⁻`
`⁻-..-⁻`
- 3 wide (,etc.)
.-⁻``⁻-.
.-⁻` `⁻-.
.-⁻` `⁻-.
`⁻-. .-⁻`
`⁻-. .-⁻`
`⁻-..-⁻`
我开始做的事情
。#! /usr/bin/env python
import numpy as np
x = 2 // number of tiles
y = 2 // idem
z = 2 // elevation, not used yet.
w = 4 // wideness of a tile (.-⁻` ---> 4 characters)
s = range ( x * y ) // just to apply a number to a corner
c = 0 // counter
def makeMatrix ( x, y ):
matrix = np.full ( y*2*h+z, x*2*w), '.', dtype=str )
return matrix
def getOut ():
global x, y, w, h, c
for i in range ( int(x) ):
for j in range ( int(y) ):
cx = ( j - i ) * w
cy = ( j + i )
dec = w
cx += dec
matrix[cy][cx] = str ( s[c] )
c += 1
return matrix
matrix = makeMatrix ( x, y )
print ( getOut () )
我找到了一些坐标,但从某种意义上说它们是错误的。我有点困惑。 我已经使用瓦片进行过操作,但这次我不太清楚该怎么做... 你有什么想法吗?