kopia lustrzana https://github.com/villares/sketch-a-day
319 320
rodzic
1675d46e08
commit
8616801af6
|
|
@ -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)
|
||||
|
|
@ -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)
|
||||
|
||||
|
||||
|
||||
Plik binarny nie jest wyświetlany.
|
Po Szerokość: | Wysokość: | Rozmiar: 3.8 MiB |
Plik binarny nie jest wyświetlany.
|
Po Szerokość: | Wysokość: | Rozmiar: 158 KiB |
|
|
@ -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(
|
||||
"""
|
||||

|
||||
|
||||
{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