Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draw function makes my canvas just completely black #337

Open
MoosyLager opened this issue Mar 18, 2022 · 1 comment
Open

Draw function makes my canvas just completely black #337

MoosyLager opened this issue Mar 18, 2022 · 1 comment

Comments

@MoosyLager
Copy link

MoosyLager commented Mar 18, 2022

So i've been trying to recreate The Coding Train's Double Pendulum project in p5py. So I've drawn a single frame of the pendulum but when I just dumbly update the angle between of the pendulum, the screen is black when run it. Am i just being dumb or something?

here's my code:
from p5 import *

r1 = 100
r2 = 100
m1 = 10
m2 = 10
angle1 = PI/2
angle2 = 0

def setup():
size(800, 800)
title('Double Pendulum - Coding Train')

def draw():
stroke(0)
background(255)
stroke_weight(2)

translate(400, 50)

x1 = r1 * sin(angle1)
y1 = r2 * cos(angle2)

x2 = r2 * sin(angle2) + x1
y2 = r2 * cos(angle2) + y1

line((0, 0), (x1, y1))
fill(0)
circle((x1,y1),m1)
line((x1,y1),(x2,y2))
circle((x2,y2),m2)

angle1 += 0.01

if name == "main":
run()

@github-actions
Copy link
Contributor

Thank you for submitting your first issue to p5py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant