update README for visuals (fix) and add CircleIntersection project

This commit is contained in:
Xevion
2019-10-21 13:41:39 -05:00
parent 2e423f8f23
commit d68bd1988a
3 changed files with 52 additions and 1 deletions

View File

@@ -0,0 +1,43 @@
import random
class Circle:
def __init__(self, x, y, radius):
self.x, self.y, self.radius = x, y, radius
def render(self):
ellipse(self.x, self.y, self.radius, self.radius)
def dist(x1, y1, x2, y2):
return sqrt(((x2-x1) ** 2) + ((y2 - y1) ** 2))
def circleIntersectCircle(c1, c2):
d = dist(c1.x, c1.y, c2.x, c2.y)
return c1.radius > d or c2.radius > d
def setup():
size(1000, 1000)
global circles, upperRadius, s
s = 0
upperRadius = 500
circles = []
def draw():
# background(204)
global circles
print(len(circles))
for _ in range(5):
skip = False
x = random.randint(0, width)
y = random.randint(0, height)
r = random.randint(0, 100)
circle = Circle(x, y, r)
for c in circles:
if circleIntersectCircle(c, circle):
skip = True
break
if not skip:
circles.append(circle)
circle.render()
# for circle in circles:
# circle.render()

View File

@@ -0,0 +1,2 @@
mode=Python
mode.id=jycessing.mode.PythonMode

View File

@@ -1,3 +1,9 @@
# visuals
All my projects attempting to create vivid or interesting visuals using the Processing.py library. Some are algorithms, most are just for loops with tweaked constants to create interesting animation.
## About
All my projects attempting to create vivid or interesting visuals using the Processing.py library. Some are algorithms, most are just for loops with tweaked constants to create interesting animation.
## Sketches
- **CircleIntersection** Plots circles in places where others aren't, expoonentially becoming slower and slower with each successfully located spot. Somewhat buggy and needs tuning to become much faster using a better algorithm, and probably better methods for deciding where spots are (less random, more organized manner).