Názory ke článku Python - 7. lekce
[btaze ked niekto vie ta nech mi rychlo pomoze, ako ja mam ten ukol uz dokonceny ale chcem vediet ako by som mohol spravit to aby mi nakreslil moj program 3 hlavy na [suradniciach napr (100,500), 2hlava(150,500), a 3 hlava (300,500)] rôznych suradniciach. skuste nekdo dopomoct.
from livewires import*
def postavicka(x,y,):
begin_graphics(800,600)
circle(x+70,y+15,15,colour=Colour.red,filled=1) #prave ucho
circle(x-70,y+15,15,colour=Colour.red,filled=1) #lave ucho
circle(x,y,70,colour=Colour.dark_red,filled=1) #tvar
circle(x+20,y+20,10,colour=Colour.green,filled=1) #prave oko
circle(x-20,y+20,10,colour=Colour.green,filled=1) #lave oko
circle(x+20,y+20,2,colour=Colour.brown,filled=1) #prava zrenicka
circle(x-20,y+20,2,colour=Colour.brown,filled=1) #lava zrenicka
circle(x,y-25,20,endpoints=((-179),(0))) #usta
move(x,y) #nos
draw(x-15,y-15)
move(x-15,y-15)
draw(x+5,y-15)
move(x,y+70) #vlasy
draw(x,y+75)
move(x-15,y+65)
draw(x-15,y+75)
move(x+15,y+65)
draw(x+15,y+75)
move(x,y-70) #telo
draw(x,y-270)
move(x,y-100) #prava ruka
draw(x+70,y-85)
move(x,y-100) #lava ruka
draw(x-70,y-85)
move(x,y-270) #lava noha
draw(x-90,y-390)
move(x,y-270) #prava noha
draw(x+90,y-390)
postavicka(100,500)
vopred dakujem, ked sa k tomu ovsem niekto ozve :-)
yorik NOVÝ
30. 4. 2008
30. 4. 2008
tu mas tvojho trojhlaveho draka :-)
from livewires import*
begin_graphics(800,600)
def hlava(x,y):
circle(x+70,y+15,15,colour=Colour.red,filled=1) #prave ucho
circle(x-70,y+15,15,colour=Colour.red,filled=1) #lave ucho
circle(x,y,70,colour=Colour.dark_red,filled=1) #tvar
circle(x+20,y+20,10,colour=Colour.green,filled=1) #prave oko
circle(x-20,y+20,10,colour=Colour.green,filled=1) #lave oko
circle(x+20,y+20,2,colour=Colour.brown,filled=1) #prava zrenicka
circle(x-20,y+20,2,colour=Colour.brown,filled=1) #lava zrenicka
circle(x,y-25,20,endpoints=((-179),(0))) #usta
move(x,y) #nos
draw(x-15,y-15)
move(x-15,y-15)
draw(x+5,y-15)
move(x,y+70) #vlasy
draw(x,y+75)
move(x-15,y+65)
draw(x-15,y+75)
move(x+15,y+65)
draw(x+15,y+75)
def telo(x,y,):
move(x,y-70) #telo
draw(x,y-270)
move(x,y-100) #prava ruka
draw(x+70,y-85)
move(x,y-100) #lava ruka
draw(x-70,y-85)
move(x,y-270) #lava noha
draw(x-90,y-390)
move(x,y-270) #prava noha
draw(x+90,y-390)
def postavicka(x,y):
hlava(x,y)
hlava(x-50,y-50)
hlava(x+50,y-50)
telo(x,y)
postavicka(550,500)
sleep(2)
end_graphics()
tttt NOVÝ
11. 8. 2012
11. 8. 2012
from livewires import *
import math
def ksicht(x,y, uhol, velkost):
begin_graphics()
#uvedenie pouzitych premennych, len kvoli priehladnosti
lxpy=0 #lave oko,suradnica x, prave oko, suradnica y
lypx=0 #lave oko, suradnica y, prave oko, suradnica x
zacx=0.0 #x a y suradnice zaciatku a konca roznych ciar, budu teda...
zacy=0.0 #...viac krat pouzite, skusim okomentovat co kedy znamenaju
konx=0.0
kony=0.0
r=0.15 * velkost #r = polomer oka
pomx=0.0 #pomocna premenna, mozem pouzit aj inu, ale bol by v tom bordel...
pomy=0.0 #...pouzijem ju len, ked uz sa to inac nebude dat bez straty priehladnosti
uhol=math.radians(uhol) * (-1) #upravi na radiany, aby sa to dalo hodit do goniometrickych funkcii a...
#...a prenasobi -1, aby sa uhol ratal po smere hodinovych ruciciek,...
#...nie proti, ako sa to pouziva v matematike na jednotkovej kruznici
uhol+= math.radians(90) #Pripocita k uhlu 90 stupnov, aby sa zacinalo od hora, nie od prava dole
#vypocet posunu kurzora pred tym, ako zacne kreslit oci
lxpy = velkost * 0.6 * math.sin(uhol + math.radians(135)) #lave oko, suradnica x, prave oko, suradnica y
lypx = velkost * 0.6 * math.sin(uhol + math.radians(45)) #lave oko, suradnica y, prave oko, suradnica x
#velkost * 0.6 - aby bol posun stredu oka od stredu hlavy vzdy relativny k...
#...velkosti hlavy, cislo 0.6 mi len pripadalo vhodne
circle(x,y,velkost) #hlavny kruh - hlava
circle(x + lxpy, y + lypx, r) #lave oko
circle(x + lypx, y - lxpy, r, colour = Colour.red) #prave oko, pozor na minus za y
#minus je tam preto, lebo x suradnica laveho oka je zapor y suradnice praveho - da sa to aj cez cosinusy riesit
zacx = (2*x + lxpy + lypx)/2 #ide sa kreslit nos, vrch nosa je medzi ocami
zacy = (2*y - lxpy + lypx)/2 #zase pozor na minus
uhol-=math.radians(90) #pre nos uz mozem uhly ratat normalne
uhol*=-1
konx= x + 0.424264 * velkost * math.sin(uhol-math.radians(90)) # bulharska konstanta 0.424264 suvisi s cislom 0.6...
kony= y + 0.424264 * velkost * math.sin(uhol) #...spomenutym vyssie, je to vzdialenost od stredu...
#...hlavy, kde je spicka nosa
line(zacx,zacy,konx,kony )
line(konx,kony,x,y, colour=Colour.red)
zacx = x + 0.25 * velkost * math.sin(uhol)
zacy = y + 0.25 * velkost * math.cos(uhol)
pomy = y - 0.45 * velkost * math.sin(uhol + math.radians(56.31))/math.sin(math.radians(56.31)) #delim to, pretoze pri normalne otocenej...
pomx = x + 0.30 * velkost * math.cos(uhol + math.radians(56.31))/math.cos(math.radians(56.31)) #hlave je x- a y-priemet vzdialenosti od ...
konx = x - 0.30 * velkost * math.sin(uhol + math.radians(33.69))/math.sin(math.radians(33.69)) #okraja kruznice 1 * zadana velkost, pri inom...
kony = y - 0.45 * velkost * math.cos(uhol + math.radians(33.69))/math.cos(math.radians(33.69)) #to bude viac, alebo menej, nie len menej
circle(zacx,zacy,endpoints= ((konx,kony),(pomx,pomy)) )
#lave obocie
zacx = x + velkost * 0.885669946 * math.sin(uhol + math.radians(40.42070956)) #pri polomeri (velkosti) hlavy 100 to...
zacy = y + velkost * 0.885669946 * math.sin(-uhol + math.radians(49.579290441))#...ma byt x na urovni vonkajsej strany...
#...oka a y o 10 bodov nad hornou stranou oka
konx = x + velkost * 0.636396103 * math.sin(uhol + math.radians(25.52877937)) #Tie bulharske konstanty uhlov a dlzok stran...
kony = y + velkost * 0.636396103 * math.sin(-uhol + math.radians(64.47122063)) #vychadzaju na zaklade kosinusovej vety
line(zacx,zacy,konx,kony)
#prave obocie
zacx = x + velkost * 0.885669946 * math.sin(uhol - math.radians(40.42070956)) #pri polomeri (velkosti) hlavy 100 to...
zacy = y + velkost * 0.885669946 * math.sin(uhol + math.radians(49.579290441))#...ma byt x na urovni vonkajsej strany...
#...oka a y o 10 bodov nad hornou stranou oka
konx = x + velkost * 0.636396103 * math.sin(uhol - math.radians(25.52877937))
kony = y + velkost * 0.636396103 * math.sin(uhol + math.radians(64.47122063))
line(zacx,zacy,konx,kony)
#circle(zacx,zacy,5,colour=Colour.blue,filled=1)
sleep(5)
end_graphics()