(sorry für mein gebrochenes Sprache)isometrischer ascii Würfel mit Python
Ich bin ein Anfänger in Python, aber ich habe keine andere Wahl, ich es für ein Projekt benötigen, und für diese ein Ich habe ascii isometrisch schaffen Würfel durch Programmierung. Ich weiß nicht wirklich, wie es zu tun, so begann ich mit der Idee Koordinaten von „Ecken“ zu finden (nicht das richtige Wort, aber ...) eine Fliese
#what I expect really :
- for a 2 wide
.-⁻``⁻-.
.-⁻` `⁻-.
| |
| |
`⁻-. .-⁻`
`⁻-..-⁻`
- for 3 wide
.-⁻``⁻-.
.-⁻` `⁻-.
.-⁻` `⁻-.
| |
| |
`⁻-. .-⁻`
`⁻-. .-⁻`
`⁻-..-⁻`
# what I except for the beginning
- 2 wide
.-⁻``⁻-.
.-⁻` `⁻-.
`⁻-. .-⁻`
`⁻-..-⁻`
- 3 wide (,etc.)
.-⁻``⁻-.
.-⁻` `⁻-.
.-⁻` `⁻-.
`⁻-. .-⁻`
`⁻-. .-⁻`
`⁻-..-⁻`
Was ich begann zu zeichnen zu do
#! /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())
Ich finde einige Koordonate, aber sie sind in gewissem Sinne falsch. Ich bin ein bisschen verwirrt. Ich arbeite bereits mit Fliesen, aber ich weiß nicht wirklich, wie es diesmal geht ... Irgendeine Idee?
konnte man das Ding in Standard-Bild machen und dann in ASCII-Kunst sehen mein [Bild in ASCII-Kunst Umwandlung] konvertieren (http: // Stackoverflow. com/a/32987834/2521214) – Spektre