PYTHON: dibujar una línea y calcular su valor mediante una función
def setup():
size(800,600)
fill(255)
frameRate(100)
strokeWeight(4)
stroke(255)
textSize(60)
def draw():
background(0)
l=linea(100,100,500,400)
line(100,100,500,400)
text(str(l),400,300)
def linea(cx,cy,cx2,cy2):
h=sqrt((cx2-cx)*(cx2-cx)+(cy2-cy)*(cy2-cy))
return h
Comentarios
Publicar un comentario