Skip to content

Commit

Permalink
Primer comit desde el museo
Browse files Browse the repository at this point in the history
  • Loading branch information
crisconru committed Oct 13, 2016
1 parent 440a6ba commit ce08449
Show file tree
Hide file tree
Showing 79 changed files with 3,032 additions and 0 deletions.
Binary file added 0000000000000000000000000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 0000000000000000000000001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 0000000000000000000100000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 0000000000000000001000000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 0111111111111111111111111.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

187 changes: 187 additions & 0 deletions PiMondrian.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
#!/usr/bin/python
#coding: utf-8

# CopyRight 2013 Allan Psicobyte ([email protected])
#
# 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/>.


import hashlib, ImageDraw
import Image, ImageFont

Iterations= 4
Gallery= 20

WIDTH= 800
HEIGHT= 800

LINE= 2

TableauName= "PiMondrian"



ArrayCuadros= []



class SubRectangle:
"""crea un rectángulo con coordenadas y color como subdivisión de un rectágulo padre"""
def __init__(self, orden, division, color, parent= None):

self.Parent= parent
self.Color= color

if parent is None:
self.ZeroX= 0
self.ZeroY= 0
self.EndX= WIDTH
self.EndY= HEIGHT
self.VorH= "V"
self.Generation= 0

else:

self.Generation= parent.Generation + 1

if parent.VorH == "V":
self.VorH= "H"

if orden == 1:
self.ZeroX= parent.ZeroX
self.ZeroY= parent.ZeroY
self.EndX= Division(parent.ZeroX, parent.EndX, division)
self.EndY= parent.EndY

elif orden == 2:
self.ZeroX= Division(parent.ZeroX, parent.EndX, division)
self.ZeroY= parent.ZeroY
self.EndX= parent.EndX
self.EndY= parent.EndY

elif parent.VorH == "H":
self.VorH= "V"

if orden == 1:
self.ZeroX= parent.ZeroX
self.ZeroY= parent.ZeroY
self.EndX= parent.EndX
self.EndY= Division(parent.ZeroY, parent.EndY, division)

elif orden == 2:
self.ZeroX= parent.ZeroX
self.ZeroY= Division(parent.ZeroY, parent.EndY, division)
self.EndX= parent.EndX
self.EndY= parent.EndY



def DivideRectangle(parent):
"""Toma los siguientes tres dígitos de Pi, y divide el cuadro en dos usando como proporción el primero de esos tres dígitos. Los otros dos digitos asignan el color de los cuadros """
global PI, ArrayCuadros

division= int(PI.pop(0))
color1= int(PI.pop(0))
color2= int(PI.pop(0))

ArrayCuadros.append(SubRectangle(1,division,color1,parent))

if division > 0:
ArrayCuadros.append(SubRectangle(2,division,color2,parent))


def Division(corta,larga,division):
"""Calcula el punto que coresponde a 'división' décimas partes entre 'corta' y 'larga' """

if division == 0:
division = 10
#resultado= larga

#else:
resultado= corta + ((larga - corta) * division / 10)
resultado= round(resultado,0)

return resultado


def PintaCuadro(generation,name):

global WIDTH, HEIGHT, LINE, ArrayCuadros

img = Image.new("RGB", (WIDTH, HEIGHT), "#000000")

draw = ImageDraw.Draw(img)

for elemento in ArrayCuadros:

if elemento.Color == 0:
FillColor= "#FFFFFF"
if elemento.Color == 1:
FillColor= "#FFFFFF"
if elemento.Color == 2:
FillColor= "#FFFFFF"
if elemento.Color == 3:
FillColor= "#AA0000"
if elemento.Color == 4:
FillColor= "#AA0000"
if elemento.Color == 5:
FillColor= "#0000AA"
if elemento.Color == 6:
FillColor= "#0000AA"
if elemento.Color == 7:
FillColor= "#000000"
if elemento.Color == 8:
FillColor= "#000000"
if elemento.Color == 9:
FillColor= "#AAAA00"

linea= round(LINE / 2,0)

if elemento.Generation == generation:
draw.rectangle([(elemento.ZeroX + linea, elemento.ZeroY + linea), (elemento.EndX - linea, elemento.EndY - linea)], outline="#000000", fill= FillColor)
# name = name + ".png"
return img


def Inspiration(Iterations):

global ArrayCuadros

ArrayCuadros= []
# Creamos el rectángulo raiz
ArrayCuadros.append(SubRectangle(1,0,0))

# Creamos el resto de rectángulos
i = 0
while i < Iterations:
for elemento in ArrayCuadros:
if elemento.Generation == i:
DivideRectangle(elemento)
i = i + 1


def numerical_hash(key):

hash = hashlib.sha256(key)
return str(int(hash.hexdigest(),base=16))


def mondrian(entrada):
global PI
Cadena = numerical_hash(entrada)

PI = list(Cadena)
Inspiration(Iterations)
salida = PintaCuadro(Iterations,TableauName)
return salida
Binary file added PiMondrian.pyc
Binary file not shown.
11 changes: 11 additions & 0 deletions Pymiento.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=Pymiento
Comment=
Exec=sudo python /home/pi/Pymiento/detectorTarjeta.py
SartupNotify=false
Terminal=true
Hidden=false
X-KeepTerminal=true
StartupNotify=true
47 changes: 47 additions & 0 deletions configuracion.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Configuracion red wifi:

* Abrir el terminal y poner la sentencia "wpa_gui"

# Descarga de sonidos .wav

* Visitar la pagina http://www.freespecialeffects.co.uk
* Escoger el sonido que nos guste
* Descargarlo a la carpeta del pymiento con una sentencia como esta de ejemplo
" sudo wget http://www.freespecialeffects.co.uk/soundfx/scifi/electronicping.wav"

* Iniciar el programa automáticamente cuando se arranca la Raspberry

El siguiente es un método sencillo, testeado y depurable para hacer arranques
de programas en el inicio.

Crea en el escritorio un archivo .desktop con el nombre por ejemplo “pymiento.desktop”

Escribe lo siguiente en el archivo :

[Desktop Entry]
Encoding=UTF-8
Type=Application
Name= Pymiento
Comment=
Exec= sudo python /home/pi/Pymiento/detectorTarjeta.py
StartupNotify=false
Terminal=true
Hidden=false


Dos cosas importantes respecto a nuestro programa,
ha de estar marcado como ejecutable y si hace uso de rutas de archivos en su código,
dichas rutas han de estar en forma absoluta y no relativa.

Ahora , al pinchar dos veces sobre archivo .desktop del escritorio nos debe lanzar la aplicación,
esto es útil ya que nos permite ver si hay algún problema con el lanzamiento antes de hacerlo
automático en el arrranque .

Para que dicha aplicación se lance al inicio hay que copiar el archivo en el directorio
“ /home/pi/.config/autostart/” (creándolo si no existe), y ya está.

Para que dicha aplicación no se lance al principio basta con quitar el lanzador
de la carpeta autostart



Loading

0 comments on commit ce08449

Please sign in to comment.