kopia lustrzana https://github.com/villares/sketch-a-day
				
				
				
			282 283
							rodzic
							
								
									2b457b038d
								
							
						
					
					
						commit
						6b6b9f27a2
					
				| 
						 | 
				
			
			@ -6,6 +6,13 @@ Hi! I'm [Alexandre Villares](https://abav.lugaralgum.com), let's see if I can ma
 | 
			
		|||
 | 
			
		||||
If you enjoy this, be a [patreon](https://patreon.com/arteprog) or make a donation [here](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=HCGAKACDMVNV2) 
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
---
 | 
			
		||||
 | 
			
		||||

 | 
			
		||||
 | 
			
		||||
283: [code](https://github.com/villares/sketch-a-day/tree/master/s283) [[Py.Processing](https://villares.github.io/como-instalar-o-processing-modo-python/index-EN)]
 | 
			
		||||
 | 
			
		||||
---
 | 
			
		||||
 | 
			
		||||

 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,15 +19,15 @@ class Node():
 | 
			
		|||
                   5 : False,
 | 
			
		||||
                  }
 | 
			
		||||
    def plot(self):
 | 
			
		||||
        """ draws box """
 | 
			
		||||
        """ draws node """
 | 
			
		||||
        if self.cor:
 | 
			
		||||
            noFill() #stroke(0)
 | 
			
		||||
            stroke(self.cor)
 | 
			
		||||
            with pushMatrix():
 | 
			
		||||
                translate(self.x, self.y, self.z)
 | 
			
		||||
                self.rect(0, 0, Node.spacing * self.size_, Node.spacing * self.size_)
 | 
			
		||||
                self.lines(0, 0, Node.spacing * self.size_, Node.spacing * self.size_)
 | 
			
		||||
                
 | 
			
		||||
    def rect(self, x, y, w, h):
 | 
			
		||||
    def lines(self, x, y, w, h):
 | 
			
		||||
        rectMode(CENTER)
 | 
			
		||||
        #rect(x, y, w/2, h/2)
 | 
			
		||||
        tlX, tlY = x - w/2, y - h/2
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,7 +1,7 @@
 | 
			
		|||
# Alexandre B A Villares - https://abav.lugaralgum.com/sketch-a-day
 | 
			
		||||
SKETCH_NAME = "s282"  # 20181007
 | 
			
		||||
OUTPUT = ".gif"
 | 
			
		||||
GRID_SIZE = 10
 | 
			
		||||
GRID_SIZE = 8
 | 
			
		||||
 | 
			
		||||
add_library('peasycam')
 | 
			
		||||
from random import seed
 | 
			
		||||
| 
						 | 
				
			
			@ -79,6 +79,7 @@ def settings():
 | 
			
		|||
    println(
 | 
			
		||||
"""
 | 
			
		||||

 | 
			
		||||
 | 
			
		||||
{1}: [code](https://github.com/villares/sketch-a-day/tree/master/{0}) [[Py.Processing](https://villares.github.io/como-instalar-o-processing-modo-python/index-EN)]
 | 
			
		||||
""".format(SKETCH_NAME, SKETCH_NAME[1:], OUTPUT)
 | 
			
		||||
    )
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										20
									
								
								s283/node.py
								
								
								
								
							
							
						
						
									
										20
									
								
								s283/node.py
								
								
								
								
							| 
						 | 
				
			
			@ -19,15 +19,15 @@ class Node():
 | 
			
		|||
                   5 : False,
 | 
			
		||||
                  }
 | 
			
		||||
    def plot(self):
 | 
			
		||||
        """ draws box """
 | 
			
		||||
        """ draws node """
 | 
			
		||||
        if self.cor:
 | 
			
		||||
            noFill() #stroke(0)
 | 
			
		||||
            stroke(self.cor)
 | 
			
		||||
            with pushMatrix():
 | 
			
		||||
                translate(self.x, self.y, self.z)
 | 
			
		||||
                self.rect(0, 0, Node.spacing * self.size_, Node.spacing * self.size_)
 | 
			
		||||
                self.lines(0, 0, Node.spacing * self.size_, Node.spacing * self.size_)
 | 
			
		||||
                
 | 
			
		||||
    def rect(self, x, y, w, h):
 | 
			
		||||
    def lines(self, x, y, w, h):
 | 
			
		||||
        rectMode(CENTER)
 | 
			
		||||
        rect(x, y, w/2, h/2)
 | 
			
		||||
        tlX, tlY = x - w/2, y - h/2
 | 
			
		||||
| 
						 | 
				
			
			@ -40,3 +40,17 @@ class Node():
 | 
			
		|||
        if not self.nb[3]: line(blX, blY, brX, brY)
 | 
			
		||||
        if self.nb[4]: line(x, y, 0, x, y, -w/2)
 | 
			
		||||
        if self.nb[5]: line(x, y, 0, x, y, w/2)
 | 
			
		||||
        
 | 
			
		||||
    def update_nbs(self):
 | 
			
		||||
        nb0 = Node.grid.get((self.ix-1, self.iy, self.iz))
 | 
			
		||||
        self.nb[0] = True if nb0 and nb0.cor else False
 | 
			
		||||
        nb1 = Node.grid.get((self.ix+1, self.iy, self.iz))
 | 
			
		||||
        self.nb[1] = True if nb1 and nb1.cor else False
 | 
			
		||||
        nb2 = Node.grid.get((self.ix, self.iy-1, self.iz))
 | 
			
		||||
        self.nb[2] = True if nb2 and nb2.cor else False
 | 
			
		||||
        nb3 = Node.grid.get((self.ix, self.iy+1, self.iz))
 | 
			
		||||
        self.nb[3] = True if nb3 and nb3.cor else False
 | 
			
		||||
        nb4 = Node.grid.get((self.ix, self.iy, self.iz-1))
 | 
			
		||||
        self.nb[4] = True if nb4 and nb4.cor else False
 | 
			
		||||
        nb5 = Node.grid.get((self.ix, self.iy, self.iz+1))
 | 
			
		||||
        self.nb[5] = True if nb5 and nb5.cor else False
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
										
											Plik binarny nie jest wyświetlany.
										
									
								
							| 
		 Po Szerokość: | Wysokość: | Rozmiar: 6.7 MiB  | 
| 
						 | 
				
			
			@ -31,7 +31,7 @@ def draw():
 | 
			
		|||
        node.plot()
 | 
			
		||||
        
 | 
			
		||||
    if ang <= TWO_PI:
 | 
			
		||||
        saveFrame("###.png")
 | 
			
		||||
        #saveFrame("###.png")
 | 
			
		||||
        ang += 0.02
 | 
			
		||||
                                                
 | 
			
		||||
def init_grid(grid_size):
 | 
			
		||||
| 
						 | 
				
			
			@ -50,18 +50,7 @@ def init_grid(grid_size):
 | 
			
		|||
                    new_node.cor = None
 | 
			
		||||
 | 
			
		||||
    for node in Node.nodes:
 | 
			
		||||
        nb0 = Node.grid.get((node.ix-1, node.iy, node.iz))
 | 
			
		||||
        node.nb[0] = True if nb0 and nb0.cor else False
 | 
			
		||||
        nb1 = Node.grid.get((node.ix+1, node.iy, node.iz))
 | 
			
		||||
        node.nb[1] = True if nb1 and nb1.cor else False
 | 
			
		||||
        nb2 = Node.grid.get((node.ix, node.iy-1, node.iz))
 | 
			
		||||
        node.nb[2] = True if nb2 and nb2.cor else False
 | 
			
		||||
        nb3 = Node.grid.get((node.ix, node.iy+1, node.iz))
 | 
			
		||||
        node.nb[3] = True if nb3 and nb3.cor else False
 | 
			
		||||
        nb4 = Node.grid.get((node.ix, node.iy, node.iz-1))
 | 
			
		||||
        node.nb[4] = True if nb4 and nb4.cor else False
 | 
			
		||||
        nb5 = Node.grid.get((node.ix, node.iy, node.iz+1))
 | 
			
		||||
        node.nb[5] = True if nb5 and nb5.cor else False
 | 
			
		||||
        node.update_nbs()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def keyPressed():
 | 
			
		||||
| 
						 | 
				
			
			@ -85,6 +74,7 @@ def settings():
 | 
			
		|||
    println(
 | 
			
		||||
"""
 | 
			
		||||

 | 
			
		||||
 | 
			
		||||
{1}: [code](https://github.com/villares/sketch-a-day/tree/master/{0}) [[Py.Processing](https://villares.github.io/como-instalar-o-processing-modo-python/index-EN)]
 | 
			
		||||
""".format(SKETCH_NAME, SKETCH_NAME[1:], OUTPUT)
 | 
			
		||||
    )
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Ładowanie…
	
		Reference in New Issue