Skip to content

Commit

Permalink
282 283
Browse files Browse the repository at this point in the history
  • Loading branch information
villares committed Oct 10, 2018
1 parent 2b457b0 commit 6b6b9f2
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 20 deletions.
7 changes: 7 additions & 0 deletions README.md
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions s282/node.py
Expand Up @@ -19,15 +19,15 @@ def __init__(self, x, y, z):
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
Expand Down
3 changes: 2 additions & 1 deletion 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
Expand Down Expand Up @@ -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)
)
20 changes: 17 additions & 3 deletions s283/node.py
Expand Up @@ -19,15 +19,15 @@ def __init__(self, x, y, z):
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
Expand All @@ -40,3 +40,17 @@ def rect(self, x, y, w, h):
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
Binary file added s283/s283.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 3 additions & 13 deletions s283/s283.pyde
Expand Up @@ -31,7 +31,7 @@ def draw():
node.plot()

if ang <= TWO_PI:
saveFrame("###.png")
#saveFrame("###.png")
ang += 0.02

def init_grid(grid_size):
Expand All @@ -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():
Expand All @@ -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)
)

0 comments on commit 6b6b9f2

Please sign in to comment.