ein Dreieck zeichnen und wollte mir das einfach machen:
Code: Alles auswählen
x0 = random.randint(4,12)
y0 = random.randint(1,12)
breite = random.randint(1,6)
hoehe = random.randint(1,6)
schieb = random.randint(0,breite)
x_koo = [x0, x0+breite, x0+schieb, x0]
y_koo = [y0, y0, y0+hoehe, y0]
text = ["A", "B", "C"]
text_y_schieb = [20, 20, -20]
lsg = ["({0};{1})".format(x0, y0)]
h_hoehe = 300
h_breite = 320
y_null = 260
x_null = 30
grafik = {
'einteilung' :20,
'view_hoehe' : 400,
'view_breite' : 400,
'h_hoehe' : h_hoehe,
'h_breite' : h_breite,
'y_null': y_null,
'x_null': x_null,
...
'xvalues': [
(x_null + n*40, 2*n) for n in range(0, 7)
],
'yvalues': [
(y_null - n*40, 2*n) for n in range(0, 7)
],
'koo': [
(x_null + x_koo[n]*20, y_null - y_koo[n]*20, x_null + x_koo[n+1]*20, y_null - y_koo[n+1]*20) for n in range(0, 3)
],
'x_koo': x_null + x0*20,
'y_koo': y_null - y0*20,
}
print(grafik)
Code: Alles auswählen
<text x="{{grafik.x_koo}}" y="{{grafik.y_koo}}" style="stroke:blue;stroke-width:1;">A</text>
{%for xa, ya, xe, ye in grafik.koo %}
<line x1="{{grafik.xa}}" y1="{{grafik.ya}}" x2="{{grafik.xe}}" y2="{{grafik.ye}}" style="stroke:black;stroke-width:1" />
<text x="{{grafik.xa}}" y="{{grafik.ya}}" style="stroke:black;stroke-width:1;">X</text>
{%endfor%}
'koo': [(190, 100, 270, 100), (270, 100, 270, 0), (270, 0, 190, 100)]
Das Dreieck will aber nicht so wie ich - was mache ich denn jetzt wieder falsch?