Programación

“Primero resuelve el problema. Entonces, escribe el código.” — John Johnson

miércoles, 20 de noviembre de 2019

Apoyos

https://stackoverflow.com/questions/25088087/how-to-move-a-turtle-stamp-in-python


https://runestone.academy/runestone/books/published/StudentCSP/CSPRe

peatTurtles/stamp.html


from turtle import *
t=Turtle()
screen=t.getscreen()


setup(250, 250, 0, 0)
screensize(120, 120)
hideturtle()

penup()
color("Red")
goto(-100, 0)
pendown()
goto(-50, 50)
goto(50, -50)
goto(100, 0)
goto(50, 50)
goto(-50, -50)
goto(-100, 0)

penup()

goto(0, 50)
dot(50, 0, 0, 0)
goto(0, -50)
dot(50, 0, 0, 0)
screen.exitonclick()

*******Camina y estampa**************
from turtle import *
#tortugota caminando
t=Turtle()
screen=t.getscreen()
setup(1500,600)
#screensize(400,200)
#speed(10)
t.shapesize(4,4,5)
t.shape("turtle")
t.fd(200)
t.fd(100)
t.stamp()
#tilt() Rota la forma del shape determinado
#en angulos, desde el actual angulo de inclinacion
#pero no cambia la direcciona de desplazamiento
t.tilt(30)
t.fd(50)
t.tilt(30)
t.fd(150)


****Vegetacion ****
from turtle import *
t=Turtle()
screen=t.getscreen()

setup(420, 420, 0, 0)

setup(450, 200, 0, 0)
screensize(300, 150)
title("www.mclibre.org")
hideturtle()
color("Green")
lado = int(numinput("Módulo turtle", "Tamaño del cuadros (10-100): ", 50, 10, 100))
nx = int(numinput("Módulo turtle", "Número de cuadros en horizontal (1-20)", 5, 1, 20))
ny = int(numinput("Módulo turtle", "Número de cuadros en vertical (1-20)", 5, 1, 20))

screensize(lado * nx * 2, lado * ny * 2)

for i in range(ny):
    for j in range(nx):
        origenX = lado * j
        origenY = lado * i
        goto(origenX, origenY)
        pendown()
        begin_fill()
        goto(origenX, origenY + lado//2)
        goto(origenX + lado, origenY + lado//2)
        goto(origenX + lado, origenY + lado)
        goto(origenX, origenY)
        end_fill()
        penup()
        goto(origenX, origenY + lado)
        pendown()
        begin_fill()
        goto(origenX + lado//2, origenY + lado)
        goto(origenX + lado // 2, origenY)
        goto(origenX + lado, origenY)
        goto(origenX, origenY + lado)
        end_fill()
        penup()
screen.exitonclick()

****puntos****

from turtle import *
t=Turtle()
screen=t.getscreen()




#3
setup(250, 250, 0, 0)
screensize(120, 120)
colormode(255)
hideturtle()

penup()
goto(-100, 100)
dot(10, 255, 0, 0)
goto(-33, 33)
dot(10, 0, 0, 0)
goto(33, -33)
dot(10, 0, 0, 255)
goto(100, -100)
dot(10, 0, 255, 0)
#4
setup(250, 250, 0, 0)
screensize(120, 120)
colormode(255)
hideturtle()

penup()
goto(-100, 0)
dot(10, 0, 0, 0)
goto(-50, 0)
dot(10, 51, 51, 51)
goto(0, 0)
dot(10, 102, 102, 102)
goto(50, 0)
dot(10, 153, 153, 153)
goto(100, 0)
dot(10, 204, 204, 204)

#5
setup(250, 250, 0, 0)
screensize(120, 120)
colormode(255)
hideturtle()

penup()
goto(0, 80)
dot(40, 0, 0, 255)
goto(0, 40)
dot(40, 255, 0, 0)
goto(0, 0)
dot(40, 0, 0, 0)
goto(0, -40)
dot(40, 0, 255, 0)
goto(0, -80)
dot(40, 255, 0, 255)
screen.exitonclick()


****Coordenadas***
from turtle import *
t=Turtle()
a=Turtle()
screen=t.getscreen()
setup(800, 600, 0, 0)
shape('turtle')
penup()
goto(100,100)
write("Estas en 100, 100")
t.penup()
t.color("red")
t.goto(120,120)
t.write("Estas en 120, 120")
a.penup()
a.shape("turtle")
a.color("magenta")
a.goto(140,140)
a.write("Estas en 140, 140")


screen.exitonclick()


No hay comentarios:

Publicar un comentario