Alexandre B A Villares 2019-02-01 11:23:50 -02:00
rodzic 48f0fea1e0
commit 9e46dd41cc
4 zmienionych plików z 41 dodań i 26 usunięć

Plik binarny nie jest wyświetlany.

Przed

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

Po

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

Plik binarny nie jest wyświetlany.

Przed

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

Po

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

Wyświetl plik

@ -10,37 +10,32 @@ def draw():
ri = r1 - r2
p1 = PVector(200, 250)
p2 = PVector(mouseX, mouseY)
# ellipse(p2.x, p2.y, r2 * 2, r2 * 2)
# ellipse(p1.x, p1.y, r1 * 2, r1 * 2)
# ellipse(d, 0, r2 * 2, r2 * 2)
# ellipse(0, 0, r1 * 2, r1 * 2)
strokeWeight(3)
noFill()
new_bar(p1, p2, r1, r2)
def new_bar(p1p, p2p, r1, r2):
d = dist(p1p.x, p1p.y, p2p.x, p2p.y)
p2 = PVector(d, 0)
p1 = PVector(0, 0)
ri = r1 - r2
with pushMatrix():
translate(p1p.x, p1p.y)
angle = atan2(p1p.x - p2p.x, p2p.y - p1p.y)
rotate(angle + HALF_PI)
theta = asin(ri / d)
beta = 3 * HALF_PI - theta
x = cos(beta) * ri
y = sin(beta) * ri
x1 = cos(beta) * r1
y1 = sin(beta) * r1
x2 = cos(beta) * r2
y2 = sin(beta) * r2
line(p1.x - x1, p1.y - y1, p2.x - x2, p2.y - y2)
line(p1.x - x1, p1.y + y1, p2.x - x2, p2.y + y2)
stroke(255, 0, 0)
arc(p1.x, p1.y, r1 * 2, r1 * 2,
-1.5 * PI - theta, -HALF_PI + theta)
arc(p2.x, p2.y, r2 * 2, r2 * 2,
-HALF_PI + theta, HALF_PI - theta)
if d > 0:
with pushMatrix():
translate(p1p.x, p1p.y)
angle = atan2(p1p.x - p2p.x, p2p.y - p1p.y)
rotate(angle + HALF_PI)
ri = r1 - r2
beta = asin(ri / d) + HALF_PI
x1 = cos(beta) * r1
y1 = sin(beta) * r1
x2 = cos(beta) * r2
y2 = sin(beta) * r2
line(-x1, -y1, d - x2, -y2)
line(-x1, +y1, d - x2, +y2)
arc(0, 0, r1 * 2, r1 * 2,
-beta - PI, beta - PI)
arc(d, 0, r2 * 2, r2 * 2,
beta - PI, PI - beta)
def keyPressed():
saveFrame("sketch-190201a.png")

Wyświetl plik

@ -19,6 +19,26 @@ Subscribe to sort-of-weekly newsletter: [[sketch-mail](https://tinyletter.com/v
## 2019
---
![sketch_190201a](2019/sketch_190201a/sketch_190201a.gif)
[sketch_190201a](https://github.com/villares/sketch-a-day/tree/master/2019/sketch_190201a) [[Py.Processing](https://villares.github.io/como-instalar-o-processing-modo-python/index-EN)]
---
![sketch_190131a](2019/sketch_190131a/sketch_190131a.gif)
[sketch_190131a](https://github.com/villares/sketch-a-day/tree/master/2019/sketch_190131a) [[Py.Processing](https://villares.github.io/como-instalar-o-processing-modo-python/index-EN)]
---
![sketch_190130a](2019/sketch_190130a/sketch_190130a.gif)
[sketch_190130a](https://github.com/villares/sketch-a-day/tree/master/2019/sketch_190130a) [[Py.Processing](https://villares.github.io/como-instalar-o-processing-modo-python/index-EN)]
---
![sketch_190129a](2019/sketch_190129a/sketch_190129a.gif)