# the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # from libreria.vplot import ROBOT robot = ROBOT() # este es el "nombre" de nuestro robot. robot.iniciar() # iniciamos la conexion robot.bajar_lapiz() # bajo el lapiz para que apoye sobre el papel lados = 20 largo = 50 for a in range(360 / ((360 / lados) / 2)): for b in range(lados): robot.adelante(largo) robot.derecha(360 / lados) robot.derecha((360 / lados) / 2) # Una ves terminado el dibujo, levanta el lapiz y cierra el programa robot.levantar_lapiz() robot.cerrar()
# but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # from libreria.vplot import ROBOT robot = ROBOT() # este es el "nombre" de nuestro robot. robot.iniciar() # iniciamos la conexion robot.bajar_lapiz() # bajo el lapiz para que apoye sobre el papel # Las varaibles son "cajas" donde se puede almacenar un valor y cambiarlo a # medida que nuestro programa se va ejecutando, permiten almacenar cualquier # valor, numeros, cadenas de caracteres y muchas cosas mas. # en este ejemplo, la variable "Lados" determina la cantidad de lados que va a # tener el poligono que vamos a dibujar con nuestro robot. lados = 5 for a in range(lados): robot.adelante(100) robot.derecha(360 / lados) # la suma de los angulos de un poligono regular # es igual a 360, por lo tanto si tenemos 5 angulos # cada uno de ellos tiene que ser de 360/5= 72° # Cambiando el valor de "lados" podemos dibujar cualquier poligono regular # Una ves terminado el dibujo, levanta el lapiz y cierra el programa robot.levantar_lapiz() robot.cerrar()
# This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # from libreria.vplot import ROBOT robot = ROBOT() # este es el "nombre" de nuestro robot. robot.iniciar() # iniciamos la conexion robot.bajar_lapiz() # bajo el lapiz para que apoye sobre el papel angulo = 3 for m in range(12): robot.bajar_lapiz() for a in range(1, 36, 3): robot.adelante(9 + a) robot.derecha(360 / angulo) robot.levantar_lapiz() robot.poner_a_cero() robot.derecha(30) robot.atras(a)
# #########################5###################################################### # # En el ejercicio anterior dibujamos un cuadrado con los comandos para mover # el cabezal del robot. # Sin embargo, repetimos 4 veces la mismas lineas - adelante(100), derecha(90)- # En este ejercicio vamos a usar un bucle de repeticion "for" que nos permite # repetir muchas veces la misma porcion de codigo fuente. # los bucles o repeticiones, son una de las partes mas importante de programar. from libreria.vplot import ROBOT robot = ROBOT() # este es el "nombre" de nuestro robot. #robot.PUERTO="/dev/ttyACM1" robot.iniciar() # iniciamos la conexion #~ robot.subir_lapiz() robot.bajar_lapiz() # bajo el lapiz para que apoye sobre el papel b = 15 lados = 5 for a in range(100): robot.adelante(b) robot.derecha((360 / lados) - 1) b = b + 5 # Una ves terminado el dibujo, levanta el lapiz y cierra el programa robot.levantar_lapiz() robot.cerrar()
# This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # from libreria.vplot import ROBOT robot = ROBOT() # este es el "nombre" de nuestro robot. robot.iniciar() # iniciamos la conexion robot.bajar_lapiz() # bajo el lapiz para que apoye sobre el papel # En este ejercicio, usamos 2 bucles, uno adentro del otro, lo que se denomina # un "bucle anidado", en cada interación del bucle A, se haran 3 repeticiones # del codigo fuente del bucle B (dibujando un triangulo). for a in range(4): # bucle A for b in range(3): # bucle B robot.adelante(200) robot.derecha(120) robot.derecha(90) # gira para que el robot no dibuje el mismo triangulo # sobre la misma superficie # Una ves terminado el dibujo, levanta el lapiz y cierra el programa robot.levantar_lapiz() robot.cerrar()
linea = linea + "_" if lapiz == 0: drawbot.levantar_lapiz() lapiz = 1 punto(caracter) #blanco() else: linea = linea + "#" if lapiz == 1: drawbot.bajar_lapiz() lapiz = 0 punto(caracter) #negro() pa = pa + 1 print linea band = 1 else: drawbot.derecha(90) drawbot.adelante(caracter) drawbot.derecha(90) for x in list(reversed(range(xx))): pixel = pix[x, y] if pixel[0] == 255 and pixel[1] == 255 and pixel[2] == 255: linea = linea + "_" if lapiz == 0: drawbot.levantar_lapiz() lapiz = 1 punto(caracter) #blanco() else: linea = linea + "#" if lapiz == 1: drawbot.bajar_lapiz()
# You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################### # # En el ejercicio anterior dibujamos un cuadrado con los comandos para mover # el cabezal del robot. # Sin embargo, repetimos 4 veces la mismas lineas - adelante(100), derecha(90)- # En este ejercicio vamos a usar un bucle de repeticion "for" que nos permite # repetir muchas veces la misma porcion de codigo fuente. # los bucles o repeticiones, son una de las partes mas importante de programar. from libreria.vplot import ROBOT robot=ROBOT() # este es el "nombre" de nuestro robot. robot.iniciar() # iniciamos la conexion robot.bajar_lapiz() # bajo el lapiz para que apoye sobre el papel for a in range(4): robot.adelante(100) robot.derecha(90) # Una ves terminado el dibujo, levanta el lapiz y cierra el programa robot.levantar_lapiz() robot.cerrar()