I would like to know how to fill a matrix in such a way that it would appear that I "draw" a figure, it is supposed that I should create the figure and then "paint" it (that would be done for example by adding another number to the "drawing"), I know to paint I should use (or so they told me) backctraking and I have been reading that I could use Bresenham to "draw" in the matrix but I do not understand much how to use both methods, if they could guide me I would appreciate it very much.
Update: The figures that can be requested would be "square", "triangle", "circle" and "rectangle", you must draw its outline and then show that figure filled with the "color" "who chose, the user should only choose if he wants a large or small figure What I've been doing recently is this:
# -*- coding: utf-8 -*-
def Rombo(n):
l = [[' ' for x in range(n)] for z in range(n/2+1)]
for e in range(n):
for i in range(e,n-e):
l[e][i] = '*'
l = l[:0:-1]+l
for i in l:
print ' '.join(i)
def Cuadrado(largo,ancho):
for i in range(largo):
if i in[0]:
print("* "*(ancho))
elif i in[(largo-1)]:
print("* "*(ancho))
else:
print("*"+" "*(ancho)+" *")
def Opciones():
op=0
while op!=1 and op!=2 and op!=9:
print
print " Menu de opciones"
print"-----------------------"
print "[1] Rombo"
print "[2] Cuadrado"
print "[9] terminar la ejecucion"
op = int(raw_input("ingrese opcion: "))
return op
#programa
opcion=Opciones()
while opcion!=9:
if opcion==1:
Rombo(21)
elif opcion==2:
Cuadrado(6,6)
else:
print"Debe ingresar una opcion valida"
print 'Adios, nos vemos :3'
Note: Something like that would be the menu, I managed to implement the square and diamond but I do not know how to stop the infinite loop so they do not print anymore, I also do not know how to fill the square with the color that want the user and in the case of the diamond I did not think of how to do it that only shows the edges, but I get everything full.