From d68bd1988ac9f9313847f83325a4d2484906c6d9 Mon Sep 17 00:00:00 2001 From: Xevion Date: Mon, 21 Oct 2019 13:41:39 -0500 Subject: [PATCH] update README for visuals (fix) and add CircleIntersection project --- .../CircleIntersection.pyde | 43 +++++++++++++++++++ visuals/CircleIntersection/sketch.properties | 2 + visuals/README.md | 8 +++- 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 visuals/CircleIntersection/CircleIntersection.pyde create mode 100644 visuals/CircleIntersection/sketch.properties diff --git a/visuals/CircleIntersection/CircleIntersection.pyde b/visuals/CircleIntersection/CircleIntersection.pyde new file mode 100644 index 0000000..3f5d867 --- /dev/null +++ b/visuals/CircleIntersection/CircleIntersection.pyde @@ -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() diff --git a/visuals/CircleIntersection/sketch.properties b/visuals/CircleIntersection/sketch.properties new file mode 100644 index 0000000..2456b0a --- /dev/null +++ b/visuals/CircleIntersection/sketch.properties @@ -0,0 +1,2 @@ +mode=Python +mode.id=jycessing.mode.PythonMode diff --git a/visuals/README.md b/visuals/README.md index 8b60a79..f72a294 100644 --- a/visuals/README.md +++ b/visuals/README.md @@ -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. \ No newline at end of file +## 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). \ No newline at end of file