main
Alexandre B A Villares 2022-01-12 18:16:50 -03:00
rodzic 156c6afafe
commit 782f9fabc5
8 zmienionych plików z 171 dodań i 0 usunięć

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 18 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 163 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 388 KiB

Wyświetl plik

@ -0,0 +1,32 @@
from random import choice
modulor = [1, 2, 3, 5, 8, 13, 21]
strip_height = 8
strips = 10
def setup():
size(1400, 800)
colorMode(HSB)
noLoop()
def draw():
rects = []
s = height / strips / strip_height
for y in range(0, 800, strip_height * s):
x = 0
while x < width:
h = strip_height * s
w = choice(modulor) * s
if x + w > width:
continue
rects.append((x, y, w, h))
x += w
for x, y, w, h in rects:
fill((w / s * h / s) % 256, 200, 200)
rect(x, y, w, h)
def keyPressed():
redraw()

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 156 KiB

Wyświetl plik

@ -0,0 +1,112 @@
boxes = []
def setup():
size(500, 500, P3D)
colorMode(HSB)
create_boxes()
def create_boxes():
boxes[:] = []
while len(boxes) < 4000:
w = int(random(1, 20)) * 12
hw = w / 2
x = int(random(hw, width - hw) - width / 2)
y = int(random(hw, height - hw) - height / 2)
z = int(random(hw, height - hw) - height / 2)
b = Box(x, y, z, w)
if not box_boxes_intersection(b):
boxes.append(b)
def draw():
background(0)
translate(width / 2, height / 2, - height)
rotateY(frameCount / 100.0)
for b in boxes:
b.plot()
# if keyPressed:
# b.plot_points()
def keyPressed():
create_boxes()
def box_boxes_intersection(b):
for other in boxes:
if box_box_intersection(b, other):
return True
return False
def box_box_intersection(a, b):
a_max_x, a_max_y, a_max_z = a.max
a_min_x, a_min_y, a_min_z = a.min
b_max_x, b_max_y, b_max_z = b.max
b_min_x, b_min_y, b_min_z = b.min
if a_max_x < b_min_x or b_max_x < a_min_x:
return False
if a_max_y < b_min_y or b_max_y < a_min_y:
return False
if a_max_z < b_min_z or b_max_z < a_min_z:
return False
return True
class Box():
def __init__(self, x, y, z, w, h=None, d=None):
if not h: h = w
if not d: d = h
self.x = x
self.y = y
self.z = z
self.w = w
self.h = h
self.d = d
self.points = self.calc_points()
self.min = self.points[0]
self.max = self.points[-1]
@property
def color(self):
return color(
self.w ** 2 / 2 % 255,
200,
200
)
def calc_points(self):
hw, hh, hd = self.w / 2.0, self.h / 2.0, self.d / 2.0
return (
(self.x - hw, self.y - hh, self.z - hd),
(self.x - hw, self.y + hh, self.z - hd),
(self.x + hw, self.y - hh, self.z - hd),
(self.x + hw, self.y + hh, self.z - hd),
(self.x - hw, self.y - hh, self.z + hd),
(self.x - hw, self.y + hh, self.z + hd),
(self.x + hw, self.y - hh, self.z + hd),
(self.x + hw, self.y + hh, self.z + hd),
)
def plot(self):
push()
translate(self.x, self.y, self.z)
fill(self.color)
box(self.w, self.h, self.d)
pop()
def plot_points(self):
for x, y, z in (self.min, self.max): #self.points:
push()
translate(x, y, z)
fill(255)
box(5)
pop()
def __repr__(self):
return "Box({}, {}, {}, {}, {}, {}).color={}".format(
self.x,
self.y,
self.z,
self.w,
self.h,
self.d,
self.color
)

Wyświetl plik

@ -27,6 +27,30 @@ Here are listed some of the tools I have been using:
---
![sketch_2022_01_12a](2022/sketch_2022_01_12a/sketch_2022_01_12a.jpeg)
[sketch_2022_01_12a](https://github.com/villares/sketch-a-day/tree/master/2022/sketch_2022_01_12a) [[Py.Processing](https://villares.github.io/como-instalar-o-processing-modo-python/index-EN)]
---
![sketch_2022_01_11a](2022/sketch_2022_01_11a/sketch_2022_01_11a.gif)
[sketch_2022_01_11a](https://github.com/villares/sketch-a-day/tree/master/2022/sketch_2022_01_11a) [[Py.Processing](https://villares.github.io/como-instalar-o-processing-modo-python/index-EN)]
---
![sketch_2022_01_10a_reticula](2022/sketch_2022_01_10a_reticula/sketch_2022_01_10a_reticula.png)
[sketch_2022_01_10a_reticula](https://github.com/villares/sketch-a-day/tree/master/2022/sketch_2022_01_10a_reticula) [[Py.Processing](https://villares.github.io/como-instalar-o-processing-modo-python/index-EN)]
---
![sketch_2022_01_09a](2022/sketch_2022_01_09a/sketch_2022_01_09a.png)
[sketch_2022_01_09a](https://github.com/villares/sketch-a-day/tree/master/2022/sketch_2022_01_09a) [[Py.Processing](https://villares.github.io/como-instalar-o-processing-modo-python/index-EN)]
---
![sketch_2022_01_08b](2022/sketch_2022_01_08b/sketch_2022_01_08b.gif)
[sketch_2022_01_08b](https://github.com/villares/sketch-a-day/tree/master/2022/sketch_2022_01_08b) [[Py.Processing](https://villares.github.io/como-instalar-o-processing-modo-python/index-EN)]

Wyświetl plik

@ -0,0 +1,3 @@
with open("/usr/share/dict/words") as w:
print(w)