diff --git a/README.md b/README.md index 71015b56..962f78b5 100644 --- a/README.md +++ b/README.md @@ -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) + +--- + +![s283](s283/s283.gif) + +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)] + --- ![s282](s282/s282.gif) diff --git a/s282/node.py b/s282/node.py index 53da30a0..2cc93714 100644 --- a/s282/node.py +++ b/s282/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 diff --git a/s282/s282.pyde b/s282/s282.pyde index fe82c19d..f146c254 100644 --- a/s282/s282.pyde +++ b/s282/s282.pyde @@ -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( """ ![{0}]({0}/{0}{2}) + {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) ) diff --git a/s283/node.py b/s283/node.py index 396ce2a2..5c95cc89 100644 --- a/s283/node.py +++ b/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 diff --git a/s283/s283.gif b/s283/s283.gif new file mode 100644 index 00000000..149cc52e Binary files /dev/null and b/s283/s283.gif differ diff --git a/s283/s283.pyde b/s283/s283.pyde index 88070c2d..3e66a854 100644 --- a/s283/s283.pyde +++ b/s283/s283.pyde @@ -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( """ ![{0}]({0}/{0}{2}) + {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) )