diff --git a/s319/s319.pyde b/s319/s319.pyde new file mode 100644 index 00000000..fae42a58 --- /dev/null +++ b/s319/s319.pyde @@ -0,0 +1,17 @@ + + + +def setup(): + size(500, 500) + noFill() + strokeWeight(10) + stroke(100) + x_mark(300, 200, 30) + x_mark(200, 200, 30) + ellipse(250, 250, 200, 200) + +def x_mark(x, y, s): + with pushMatrix(): + translate(x, y) + line(-s, -s, s, s) + line(s, -s, -s, s) \ No newline at end of file diff --git a/s320/node.py b/s320/node.py new file mode 100644 index 00000000..07ee9ff6 --- /dev/null +++ b/s320/node.py @@ -0,0 +1,45 @@ +from random import choice + +class Node(): + nodes = [] + + def __init__(self, x, y): + self.x = Node.border + Node.spacing / 2 + x * Node.spacing - width / 2 + self.y = Node.border + Node.spacing / 2 + y * Node.spacing - height / 2 + self.size_ = 1 + self.rot0 = choice((0, HALF_PI)) #, PI, PI + HALF_PI)) + self.rot1 = choice((HALF_PI , PI)) #, PI + HALF_PI)) + + def plot(self, ang): + """ draws node """ + with pushMatrix(): + translate(self.x, self.y) + d = abs(self.rot0 + ang - self.rot1) + if d >= 0.30: + rotate(self.rot0 + ang) + else: + self.rot0 = self.rot1 - ang + rotate(self.rot1) + + noFill() #stroke(0) + stroke(0, 0, 200, 50) + siz = Node.spacing * self.size_ + rect(0, 0, siz, siz) + # line(-siz/2, -siz/2, siz/2, siz/2) + stroke(0, 100, 100) + for i in range(-28, 29, 7): + arc(-siz/2, -siz/2, siz+i, siz+i, 0, HALF_PI) + arc(siz/2, siz/2, siz+i, siz+i, PI, PI+HALF_PI) + + @classmethod + def init_grid(cls, grid_size, border): + cls.border = border + cls.spacing = (width - cls.border * 2) / grid_size + cls.nodes = [] + for x in range(grid_size): + for y in range(grid_size): + new_node = cls(x, y) + cls.nodes.append(new_node) + + + \ No newline at end of file diff --git a/s320/s286.gif b/s320/s286.gif new file mode 100644 index 00000000..cc41aef5 Binary files /dev/null and b/s320/s286.gif differ diff --git a/s320/s320.png b/s320/s320.png new file mode 100644 index 00000000..d781e72d Binary files /dev/null and b/s320/s320.png differ diff --git a/s320/s320.pyde b/s320/s320.pyde new file mode 100644 index 00000000..27969052 --- /dev/null +++ b/s320/s320.pyde @@ -0,0 +1,58 @@ +# Alexandre B A Villares - https://abav.lugaralgum.com/sketch-a-day +SKETCH_NAME = "s320" # 20181114 +OUTPUT = ".gif" + +GRID_SIZE = 10 +BORDER = 50 + +from random import seed +from random import choice +from node import Node + +def setup(): + size(500, 500) + strokeWeight(2) + rectMode(CENTER) + frameRate(10) + random_seed(101) + Node.init_grid(GRID_SIZE, BORDER) + +def draw(): + translate(width/2, height/2) + background(200) + ang = 0 #frameCount/31. + + for node in Node.nodes: + node.plot(ang) + + if ang < TWO_PI: + pass + #saveFrame("###.png") + else: + noLoop() + +def keyPressed(): + if key == "n": + Node.init_grid(GRID_SIZE, BORDER) + if key == "s": saveFrame("###.png") + + +def random_seed(s=None): + global rnd_seed + if s: + rnd_seed = s + seed(rnd_seed) + randomSeed(rnd_seed) + else: + seed(rnd_seed) + randomSeed(rnd_seed) + +# print text to add to the project's README.md +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) + ) \ No newline at end of file