Пример #1
0
#
# 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

# 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()
Пример #2
0
for y in range(yy):
    linea = ""
    pa = 0
    if band == 0:
        for x in 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()
                    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()