-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
79 changed files
with
3,032 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
|
||
|
Oops, something went wrong.