Skip to content

Instantly share code, notes, and snippets.

@tado
Last active February 13, 2025 00:03
Show Gist options
  • Save tado/eaebd702baccb899f0216aaffdf3c2d7 to your computer and use it in GitHub Desktop.
Save tado/eaebd702baccb899f0216aaffdf3c2d7 to your computer and use it in GitHub Desktop.

Revisions

  1. tado revised this gist Feb 13, 2025. 1 changed file with 1 addition and 3 deletions.
    4 changes: 1 addition & 3 deletions hello.py
    Original file line number Diff line number Diff line change
    @@ -13,9 +13,7 @@ def setup():
    pos = Vector(random.uniform(0, width), random.uniform(0, height))
    vel = Vector(random.uniform(-2.0, 2.0), random.uniform(-2.0, 2.0))
    diameter = random.uniform(2, 40)
    color = Color(random.uniform(0, 255),
    random.uniform(0, 255),
    random.uniform(0, 255), 190)
    color = Color(random.uniform(0, 255), random.uniform(0, 255), random.uniform(0, 255), 190)
    circles.append({'pos': pos, 'vel': vel, 'diameter': diameter, 'color': color})

    def draw():
  2. tado revised this gist Feb 13, 2025. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions hello.py
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,6 @@
    circles = []

    def setup():
    global width, height, circles, circle_count
    size(width, height)
    no_stroke()
    for _ in range(circle_count):
    @@ -20,7 +19,6 @@ def setup():
    circles.append({'pos': pos, 'vel': vel, 'diameter': diameter, 'color': color})

    def draw():
    global width, height, circles, circle_count
    background(0)
    for c in circles:
    fill(c["color"])
  3. tado revised this gist Feb 13, 2025. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions hello.py
    Original file line number Diff line number Diff line change
    @@ -13,10 +13,10 @@ def setup():
    for _ in range(circle_count):
    pos = Vector(random.uniform(0, width), random.uniform(0, height))
    vel = Vector(random.uniform(-2.0, 2.0), random.uniform(-2.0, 2.0))
    diameter = random.randrange(2, 40)
    color = Color(random.randrange(0, 255),
    random.randrange(0, 255),
    random.randrange(0, 255), 190)
    diameter = random.uniform(2, 40)
    color = Color(random.uniform(0, 255),
    random.uniform(0, 255),
    random.uniform(0, 255), 190)
    circles.append({'pos': pos, 'vel': vel, 'diameter': diameter, 'color': color})

    def draw():
    @@ -26,9 +26,9 @@ def draw():
    fill(c["color"])
    c["pos"] += c["vel"]
    if c["pos"].x > width or c["pos"].x < 0:
    c["vel"].x = -c["vel"].x
    c["vel"].x *= -1
    if c["pos"].y > height or c["pos"].y < 0:
    c["vel"].y = -c["vel"].y
    c["vel"].y *= -1
    circle((c["pos"].x, c["pos"].y), c["diameter"])
    fill(255, 190)
    text_size(200)
  4. tado created this gist Feb 12, 2025.
    38 changes: 38 additions & 0 deletions hello.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    from p5 import *
    import random

    width = 1280
    height = 720
    circle_count = 500
    circles = []

    def setup():
    global width, height, circles, circle_count
    size(width, height)
    no_stroke()
    for _ in range(circle_count):
    pos = Vector(random.uniform(0, width), random.uniform(0, height))
    vel = Vector(random.uniform(-2.0, 2.0), random.uniform(-2.0, 2.0))
    diameter = random.randrange(2, 40)
    color = Color(random.randrange(0, 255),
    random.randrange(0, 255),
    random.randrange(0, 255), 190)
    circles.append({'pos': pos, 'vel': vel, 'diameter': diameter, 'color': color})

    def draw():
    global width, height, circles, circle_count
    background(0)
    for c in circles:
    fill(c["color"])
    c["pos"] += c["vel"]
    if c["pos"].x > width or c["pos"].x < 0:
    c["vel"].x = -c["vel"].x
    if c["pos"].y > height or c["pos"].y < 0:
    c["vel"].y = -c["vel"].y
    circle((c["pos"].x, c["pos"].y), c["diameter"])
    fill(255, 190)
    text_size(200)
    text_align('CENTER')
    text("Hello p5!", (640, 400))

    run(renderer='skia')