kopia lustrzana https://github.com/villares/sketch-a-day
				
				
				
			
			
			
			
				main
			
			
		
		
							rodzic
							
								
									9d666b0a2c
								
							
						
					
					
						commit
						32a809cd37
					
				| 
						 | 
					@ -28,23 +28,34 @@ class Quadrado():
 | 
				
			||||||
        self.cor = CORES[self.tipo]
 | 
					        self.cor = CORES[self.tipo]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def desenha(self):
 | 
					    def desenha(self):
 | 
				
			||||||
        posX, posY = self.coluna * self.tamanho, self.fila * self.tamanho
 | 
					        tam = self.tamanho
 | 
				
			||||||
 | 
					        posX, posY = self.coluna * tam, self.fila * tam
 | 
				
			||||||
        with pushMatrix():
 | 
					        with pushMatrix():
 | 
				
			||||||
            translate(posX, posY)
 | 
					            translate(posX, posY)
 | 
				
			||||||
            noStroke()
 | 
					            noStroke()
 | 
				
			||||||
            fill(self.cor)
 | 
					            fill(self.cor)
 | 
				
			||||||
            pushMatrix()
 | 
					
 | 
				
			||||||
            translate(0, 0, self.altura)
 | 
					            pos = ((-1, -1), (1, -1), (1, 1), (-1, 1))
 | 
				
			||||||
            rect(0, 0, self.tamanho, self.tamanho)
 | 
					            for i, c in enumerate(self.cantos):
 | 
				
			||||||
            popMatrix()
 | 
					                pc = self.cantos[i - 1]
 | 
				
			||||||
            fill(255)       # branco
 | 
					                ipos, ppos = pos[i], pos[i - 1]
 | 
				
			||||||
 | 
					                beginShape()
 | 
				
			||||||
 | 
					                vertex(ipos[0] * tam/2, ipos[1] * tam/2, c)
 | 
				
			||||||
 | 
					                vertex(ppos[0] * tam/2, ppos[1] * tam/2, pc)
 | 
				
			||||||
 | 
					                vertex(0, 0, self.altura)
 | 
				
			||||||
 | 
					                endShape(CLOSE)
 | 
				
			||||||
 | 
					            # translate(0, 0, self.altura)
 | 
				
			||||||
 | 
					            # rect(0, 0, self.tamanho, self.tamanho)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            textSize(20)  # para escrever o tipo se o mouse estiver perto
 | 
					            textSize(20)  # para escrever o tipo se o mouse estiver perto
 | 
				
			||||||
            textAlign(CENTER, CENTER)
 | 
					            textAlign(CENTER, CENTER)
 | 
				
			||||||
            if (dist(posX, posY, mouseX, mouseY) < self.tamanho * 2):
 | 
					            if (dist(posX, posY, mouseX, mouseY) < self.tamanho * 2):
 | 
				
			||||||
                text(self.tipo, self.tamanho / 2,
 | 
					                fill(0)
 | 
				
			||||||
                     self.tamanho / 2, self.altura + 5)
 | 
					                text(self.tipo, self.tamanho / 2, self.tamanho / 2, 35)
 | 
				
			||||||
 | 
					                fill(255)
 | 
				
			||||||
 | 
					                text(self.tipo, self.tamanho / 2 - 2, self.tamanho / 2 - 2, 36)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def media_cantos(self):
 | 
					    def calcula_cantos(self):
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        Devolva uma lista dos cantos nesta ordem:
 | 
					        Devolva uma lista dos cantos nesta ordem:
 | 
				
			||||||
        0 --- 1
 | 
					        0 --- 1
 | 
				
			||||||
| 
						 | 
					@ -57,14 +68,14 @@ class Quadrado():
 | 
				
			||||||
        BL = ((-1, +1), (0, +1), (-1, 0), (0, 0))
 | 
					        BL = ((-1, +1), (0, +1), (-1, 0), (0, 0))
 | 
				
			||||||
        BR = ((+1, +1), (0, +1), (+1, 0), (0, 0))
 | 
					        BR = ((+1, +1), (0, +1), (+1, 0), (0, 0))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        result = []
 | 
					        self.cantos = []
 | 
				
			||||||
        for corner in (TL, TR, BR, BL):
 | 
					        for canto in (TL, TR, BR, BL):
 | 
				
			||||||
            alturas = [self.mapa[(self.coluna + i, self.fila + j)].altura
 | 
					            alturas = [self.mapa[(self.coluna + i, self.fila + j)].altura
 | 
				
			||||||
                       for i, j in corner
 | 
					                       for i, j in canto
 | 
				
			||||||
                       if self.mapa.get((self.coluna + i, self.fila + j))]
 | 
					                       if self.mapa.get((self.coluna + i, self.fila + j))]
 | 
				
			||||||
            print(alturas)
 | 
					            print(alturas)
 | 
				
			||||||
            media = sum(alturas) / len(alturas)
 | 
					            media = sum(alturas) / len(alturas)
 | 
				
			||||||
            result.append(media)
 | 
					            self.cantos.append(media)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @staticmethod
 | 
					    @staticmethod
 | 
				
			||||||
    def sorteiaAltura(tipo):
 | 
					    def sorteiaAltura(tipo):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
										
											Plik binarny nie jest wyświetlany.
										
									
								
							| 
		 Przed Szerokość: | Wysokość: | Rozmiar: 1.8 MiB  | 
										
											Plik binarny nie jest wyświetlany.
										
									
								
							| 
		 Po Szerokość: | Wysokość: | Rozmiar: 2.4 MiB  | 
| 
						 | 
					@ -22,11 +22,12 @@ def setup():
 | 
				
			||||||
            mapa[(coluna, fila)] = Quadrado(coluna, fila)
 | 
					            mapa[(coluna, fila)] = Quadrado(coluna, fila)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for quadrado in mapa.values():
 | 
					    for quadrado in mapa.values():
 | 
				
			||||||
            print(quadrado.media_cantos())
 | 
					            quadrado.calcula_cantos()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def draw():
 | 
					def draw():
 | 
				
			||||||
    background(0)
 | 
					    background(0)
 | 
				
			||||||
    camera(width / 2, height / 2, 500.0,  # eyeX, eyeY, eyeZ
 | 
					    # camera(width / 2, height / 2, 500.0,  # eyeX, eyeY, eyeZ
 | 
				
			||||||
 | 
					    camera(width / 2, mouseY*2, 500.0,  # eyeX, eyeY, eyeZ
 | 
				
			||||||
           width / 2, height / 2, 0.0,        # centerX, centerY, centerZ
 | 
					           width / 2, height / 2, 0.0,        # centerX, centerY, centerZ
 | 
				
			||||||
           0.0, 1.0, 0.0)        # upX, upY, upZ
 | 
					           0.0, 1.0, 0.0)        # upX, upY, upZ
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -21,6 +21,12 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
---
 | 
					---
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[sketch_2020_07_23c](https://github.com/villares/sketch-a-day/tree/master/2020/sketch_2020_07_23c) [[Py.Processing](https://villares.github.io/como-instalar-o-processing-modo-python/index-EN)]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					---
 | 
				
			||||||
 | 
					
 | 
				
			||||||

 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[sketch_2020_07_22c](https://github.com/villares/sketch-a-day/tree/master/2020/sketch_2020_07_22c) [[Py.Processing](https://villares.github.io/como-instalar-o-processing-modo-python/index-EN)]
 | 
					[sketch_2020_07_22c](https://github.com/villares/sketch-a-day/tree/master/2020/sketch_2020_07_22c) [[Py.Processing](https://villares.github.io/como-instalar-o-processing-modo-python/index-EN)]
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Ładowanie…
	
		Reference in New Issue