From 641b4648a832870cda1907f9c967aa4c3e1f5e07 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 24 May 2010 07:27:36 +0000 Subject: Updated names of variables --- diff --git a/MANIFEST b/MANIFEST index fed861b..fed861b 100644..100755 --- a/MANIFEST +++ b/MANIFEST diff --git a/PaintingFractionsActivity.py b/PaintingFractionsActivity.py index f231709..f231709 100644..100755 --- a/PaintingFractionsActivity.py +++ b/PaintingFractionsActivity.py diff --git a/activity/activity.info b/activity/activity.info index 4e15b70..4e15b70 100644..100755 --- a/activity/activity.info +++ b/activity/activity.info diff --git a/color.py b/color.py index b685e78..472b44e 100755 --- a/color.py +++ b/color.py @@ -2,65 +2,67 @@ import os, pygame,math import pygame.font, pygame.event, pygame.draw, string -from matriz import * +from matrix import * from pygame.locals import * from math import sin, cos, pi, sqrt + +IMAGES_PATH = 'images/' class pyGrafic: - def __init__(self, matriz): - self.matriz=matriz - self.filas=matriz.Filas - self.columnas=matriz.Columnas + def __init__(self, matrix): + self.matrix=matrix + self.rows=matrix.Rows + self.columns=matrix.Columns def init(self): #pygame.init() self.screen = pygame.display.set_mode((600, 600),1) pygame.display.set_caption('Pintando Fracciones') self.cargaImgs() - self.dibujar() + self.draw() self.gridRect = pygame.Rect(0,0,50,45) self.palet() self.color=self.back self.colorName='white' def cargaImgs(self): - self.purple= pygame.image.load("./purple.png").convert() + self.purple= pygame.image.load(IMAGES_PATH + "purple.png").convert() self.purple.set_colorkey((0x80, 0x00, 0x80), RLEACCEL) - self.brown= pygame.image.load("./brown.png").convert() + self.brown= pygame.image.load(IMAGES_PATH + "brown.png").convert() self.brown.set_colorkey((0x80, 0x00, 0x80), RLEACCEL) - self.pink= pygame.image.load("./pink.png").convert() + self.pink= pygame.image.load(IMAGES_PATH + "pink.png").convert() self.pink.set_colorkey((0x80, 0x00, 0x80), RLEACCEL) - self.orange= pygame.image.load("./orange.png").convert() + self.orange= pygame.image.load(IMAGES_PATH + "orange.png").convert() self.orange.set_colorkey((0x80, 0x00, 0x80), RLEACCEL) - self.gray= pygame.image.load("./gray.png").convert() + self.gray= pygame.image.load(IMAGES_PATH + "gray.png").convert() self.gray.set_colorkey((0x80, 0x00, 0x80), RLEACCEL) - self.yellow= pygame.image.load("./yellow.png").convert() + self.yellow= pygame.image.load(IMAGES_PATH + "yellow.png").convert() self.yellow.set_colorkey((0x80, 0x00, 0x80), RLEACCEL) - self.blue = pygame.image.load("./blue.png").convert() + self.blue = pygame.image.load(IMAGES_PATH + "blue.png").convert() self.blue.set_colorkey((0x80, 0x00, 0x80), RLEACCEL) - self.green = pygame.image.load("./green.png").convert() + self.green = pygame.image.load(IMAGES_PATH + "green.png").convert() self.green.set_colorkey((0x80, 0x00, 0x80), RLEACCEL) - self.red = pygame.image.load("./red.png").convert() + self.red = pygame.image.load(IMAGES_PATH + "red.png").convert() self.red.set_colorkey((0x80, 0x00, 0x80), RLEACCEL) - self.back = pygame.image.load("./back.png").convert() + self.back = pygame.image.load(IMAGES_PATH + "back.png").convert() self.back.set_colorkey((0x80, 0x00, 0x80), RLEACCEL) - def dibujar(self): + def draw(self): self.mapimg = pygame.Surface((600,600),1) self.mapimg= self.mapimg.convert() self.mapimg.fill((0,0,0)) - for y in range(self.columnas): - for x in range(self.filas): + for y in range(self.columns): + for x in range(self.rows): pixelX,pixelY=x*38,y*41 self.mapimg.blit(self.back,(pixelX,pixelY)) @@ -96,21 +98,21 @@ class pyGrafic: c=-1 f=-1 - for fila in range(self.filas+1): - if (x<=(fila*38)): - f=fila-1 - print "columna:" + str(f) + for row in range(self.rows+1): + if (x<=(row*38)): + f=row-1 + print "column:" + str(f) break - for columna in range(self.columnas+1): - if (y<=(columna*41)): - c=columna-1 - print "fila:" + str(c) + for column in range(self.columns+1): + if (y<=(column*41)): + c=column-1 + print "row:" + str(c) break - if c-1 and f>-1: - self.matriz.Tabla[c][f].PintarCelda(self.colorName) - print "Color:" + self.matriz.Tabla[c][f].ObtenerColor() + if c-1 and f>-1: + self.matrix.Values[c][f].PaintCell(self.colorName) + print "Color:" + self.matrix.Values[c][f].GetColor() c=c*41 f=f*38 @@ -149,10 +151,10 @@ class pyGrafic: def main(): pygame.init() - matriz=CrearMatriz(60) + matrix=CreateMatrix(60) #se inicia el controlador de pygame - objeto=pyGrafic(matriz) + objeto=pyGrafic(matrix) objeto.loop() #se llama a la funcion main cuando se ejecute el scrip diff --git a/matrix.py b/matrix.py index 2506229..4b31d22 100755 --- a/matrix.py +++ b/matrix.py @@ -1,6 +1,5 @@ from math import sqrt -#Cell: represents a single cell of the matrix class Cell: def __init__(self): self.Color = 'white' @@ -11,7 +10,6 @@ class Cell: def PaintCell(self, color): self.Color = color -#Matrix: represent the cell's matrix. Defines constructor class Matrix: def __init__(self, rows, columns): self.Rows = rows @@ -29,7 +27,7 @@ def CreateMatrix(Cells): #Generate the number of rows and columns #so matrix can be similar as possible to a square matrix - + root = int(sqrt(Cells)) l = list(range(1,root+1)) l.reverse() @@ -39,27 +37,21 @@ def CreateMatrix(Cells): break columns = Cells / rows - #Got the matrix's dimension - matrix = Matrix(rows,columns) return matrix; #Parameters: matrix, list of colors, and how many cells has to be painted in each color -#Returns: True if the painting is correct, False if is not def CheckMatrix(matrix, colors, number_color): painted = number_color - #Each color got no cells painted initially for item in painted: item = 0 rows = matriz.rows columns = matriz.columns - #Walk over the matrix for i in range(rows): for j in range(columns): - #Walk over the list of colors cont=0 for color in colors: if matriz.Cells[i][j].GetColor() == color: @@ -80,6 +72,4 @@ def CheckMatrix(matrix, colors, number_color): cont=cont+1 return success - -#probar que funcione -#CrearMatriz(24) + diff --git a/setup.py b/setup.py index b36fc91..b36fc91 100644..100755 --- a/setup.py +++ b/setup.py -- cgit v0.9.1