mirror of
https://github.com/Xevion/processing-projects.git
synced 2025-12-06 01:15:57 -06:00
update README for visuals (fix) and add CircleIntersection project
This commit is contained in:
43
visuals/CircleIntersection/CircleIntersection.pyde
Normal file
43
visuals/CircleIntersection/CircleIntersection.pyde
Normal 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()
|
||||
2
visuals/CircleIntersection/sketch.properties
Normal file
2
visuals/CircleIntersection/sketch.properties
Normal file
@@ -0,0 +1,2 @@
|
||||
mode=Python
|
||||
mode.id=jycessing.mode.PythonMode
|
||||
@@ -1,3 +1,9 @@
|
||||
# visuals
|
||||
|
||||
## 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).
|
||||
Reference in New Issue
Block a user