def forward(self, l): angle = radians(90 - self.angle) nx, ny = self.x+l*cos(angle), self.y-l*sin(angle) nx, ny = max(0, nx), max(0, ny) nx, ny = min(nx, risar.maxX), min(ny, risar.maxY) if self.penActive: risar.crta(self.x, self.y, nx, ny, self.color, self.width) ## SPREMENJENO ## self.x, self.y = nx, ny self.update()
def gore(x0, y0, x2, y2, globina): if globina == 0: risar.crta(x0, y0, x2, y2) else: odmik = (x2 - x0) // 4 x1 = (x0 + x2) / 2 y1 = (y0 + y2) / 2 + random.randint(-odmik, odmik) gore(x0, y0, x1, y1, globina - 1) gore(x1, y1, x2, y2, globina - 1)
def forward(self, a): phi = radians(90 - self.angle) nx = self.x + a * cos(phi) ny = self.y + a * sin(phi) if self.pen_active: risar.crta(self.x, self.y, nx, ny) self.x, self.y = nx, ny self.update() risar.cakaj(self.pause)
def forward(self, a): phi = radians(90 - self.angle) nx = self.x + a * cos(phi) ny = self.y - a * sin(phi) if self.pen_active: risar.crta(self.x, self.y, nx, ny) self.x = nx self.y = ny self.update()
def forward(self, l): angle = radians(90 - self.angle) nx, ny = self.x + l * cos(angle), self.y - l * sin(angle) nx, ny = max(0, nx), max(0, ny) nx, ny = min(nx, risar.maxX), min(ny, risar.maxY) if self.penActive: risar.crta(self.x, self.y, nx, ny) self.x, self.y = nx, ny self.update()
def forward(self, l): angle = radians(90 - self.angle) nx, ny = self.x + l * cos(angle), self.y - l * sin(angle) nx, ny = max(0, nx), max(0, ny) nx, ny = min(nx, risar.maxX), min(ny, risar.maxY) if self.penActive: risar.crta(self.x, self.y, nx, ny, self.color, self.width) self.x, self.y = nx, ny self.update() self.trace.append((self.forward, (l, ))) ## DODANO ##
def forward(self, l): angle = radians(90 - self.angle) nx, ny = self.x + l * cos(angle), self.y - l * sin(angle) nx, ny = max(0, nx), max(0, ny) nx, ny = min(nx, risar.maxX), min(ny, risar.maxY) if self.penActive: risar.crta(self.x, self.y, nx, ny, sirina = self.width, barva = self.color) self.x, self.y = nx, ny self.update() self.macro.append([self.forward, [l]])
def porocaj(self): self.dan += 1 risar.crta(self.prejsnidan, risar.maxY - self.prejsni_dan_okuzenih, self.dan, risar.maxY - self.okuženih, risar.rdeca) self.prejsnidan = self.dan self.prejsni_dan_okuzenih = self.okuženih risar.crta(self.prejsnidan, risar.maxY - self.prejsni_dan_ozdravelih, self.dan, risar.maxY - self.ozdravelih, risar.zelena) self.prejsni_dan_ozdravelih = self.ozdravelih
def forward(self, a): phi = radians(90 - self.angle) nx = self.x + a * cos(phi) ny = self.y + a * sin(phi) if self.pen_active: risar.crta(self.x, self.y, nx, ny) self.length += abs(a) self.x = nx self.y = ny self.update()
def narisi_povezave(kraji, enosmerne=False): koord = koordict(kraji) pov = povezave(5, kraji) if not enosmerne: pov = dvosmerno(pov) for kraj, sosedi in pov.items(): for sosed in sosedi: x1, y1 = koord[kraj] x2, y2 = koord[sosed] if enosmerne: x2 = .6 * x1 + .4 * x2 y2 = .6 * y1 + .4 * y2 risar.crta(tx(x1), ty(y1), tx(x2), ty(y2), barva=risar.barva(48, 48, 48), sirina=4) risar.crta(tx(x1), ty(y1), tx(x2), ty(y2), barva=risar.barva(96, 96, 96), sirina=1)
def ogrodje(self): rightX = self.maxX - 25 rightY = self.maxY - 145 risar.crta(25, 25, rightX, 25, risar.bela, 3) risar.crta(rightX, 25, rightX, rightY, risar.bela, 3) risar.crta(24, 26, 25, rightY, risar.bela, 3) risar.crta(24, rightY, rightX, rightY, risar.bela, 3)
def naloga10_pot(): kraji = TestBase.kraji pov = dvosmerno(povezave(5, kraji)) koord = koordict(kraji) pot = najkrajsa_pot("Škofije", "Lenart", pov) risar.obnavljaj = False narisi_povezave(kraji) for kraj1, kraj2 in zip(pot, pot[1:]): x1, y1 = koord[kraj1] x2, y2 = koord[kraj2] risar.crta(tx(x1), ty(y1), tx(x2), ty(y2), barva=risar.zelena, sirina=3) narisi_kraje(TestBase.kraji) risar.obnavljaj = True risar.obnovi() risar.stoj()
def __init__(self): self.x, self.y = risar.maxX // 2, risar.maxY // 2 self.angle = 0 self.penActive = True self.pause = 0 self.body = risar.krog(0, 0, 5, risar.zelena, 3) self.head = risar.crta(0, 0, 5, risar.rdeca, 3) self.update()
def forward(self, a): phi = radians(90 - self.angle) nx = self.x + a * cos(phi) ny = self.y + a * sin(phi) if self.pen_active: crta = risar.crta(self.x, self.y, nx, ny) self.seznam.append([crta,self.x,self.y,self.angle]) self.x = nx self.y = ny self.update()
def forward(self, a): phi = radians(90 - self.angle) nx = self.x + a * cos(phi) ny = self.y + a * sin(phi) if self.pen_active: zadnja_crta = risar.crta(self.x, self.y, nx, ny) x = self.x y = self.y kot = self.angle self.seznam.append([zadnja_crta, x, y, kot]) self.x = nx self.y = ny self.update()
import math import risar n = 20 # Število manjših krogov R = 200 # Radij velikega kroga x0, y0 = risar.maxX / 2, risar.maxY / 2 # Središče velikega kroga krogi = [] for i in range(n): phi = 2 * math.pi / n x = x0 + R * math.cos(phi * i) y = y0 + R * math.sin(phi * i) barva = risar.nakljucna_barva() r = math.sin(phi / 2) * R risar.krog(x, y, r, barva) for xx, yy in krogi: risar.crta(x, y, xx, yy, barva) krogi.append((x, y)) risar.stoj()
import random import risar sez = [] for i in range(50): x, y, r = random.randint(20, risar.maxX - 20), random.randint(20, risar.maxY - 20), random.randint(5, 20) risar.krog(x, y, r, barva=risar.nakljucna_barva()) sez.append((x, y)) for x, y in sez: for x1, y1 in sez: risar.crta(x, y, x1, y1, barva = risar.nakljucna_barva()) risar.stoj()
def trikotnik(Ax, Ay, Bx, By, Cx, Cy): risar.crta(Ax, Ay, Bx, By) risar.crta(Cx, Cy, Bx, By) risar.crta(Ax, Ay, Cx, Cy)
import random from PyQt4 import QtGui import risar for i in range(100): x0, y0 = risar.nakljucne_koordinate() x1, y1 = risar.nakljucne_koordinate() barva = risar.nakljucna_barva() sirina = random.randint(2, 20) risar.crta(x0, y0, x1, y1, barva, sirina) risar.stoj()
import risar from random import randint for i in range(100): x0, y0 = randint(0, risar.maxX), randint(0, risar.maxY) x1, y1 = randint(0, risar.maxX), randint(0, risar.maxY) barva = risar.barva(randint(0, 255), randint(0, 255), randint(0, 255)) sirina = randint(2, 20) risar.crta(x0, y0, x1, y1, barva, sirina) risar.stoj()