'Coded By Ashish on 4 March, 2018
_TITLE "Double Pendulum [Press Space for New Settings]"
change_settings:
pendulum(0).r = p5random(250, 350)
pendulum
(0).angInc
= p5random
(0, _PI(2))pendulum
(0).angSize
= p5random
(_PI(.1), _PI(.6))
pendulum
(1).angInc
= p5random
(0, _PI(2))pendulum(1).r = p5random(100, 300)
pendulum
(1).angSize
= p5random
(_PI(.1), _PI(.9))px = 0: py = 0: a = 0: f = 0
tx1
= COS(pendulum
(0).ang
) * pendulum
(0).r
+ pendulum
(0).
pos.x
ty1
= SIN(pendulum
(0).ang
) * pendulum
(0).r
+ pendulum
(0).
pos.y
pendulum
(0).ang
= SIN(pendulum
(0).angInc
) * pendulum
(0).angSize
+ _PI(.5) pendulum
(1).
pos.x
= tx1: pendulum
(1).
pos.y
= ty1
tx2
= COS(pendulum
(1).ang
) * pendulum
(1).r
+ pendulum
(1).
pos.x
ty2
= SIN(pendulum
(1).ang
) * pendulum
(1).r
+ pendulum
(1).
pos.y
pendulum
(1).ang
= SIN(pendulum
(1).angInc
) * pendulum
(0).angSize
+ pendulum
(0).ang
g
= SIN(pendulum
(0).angInc
) * 128 + 128 b
= COS(pendulum
(1).angInc
) * 128 + 128
thickLine px, py, tx2, ty2, 2
LINE (pendulum
(0).
pos.x
, pendulum
(0).
pos.y
)-(tx1
, ty1
) CircleFill tx1
, ty1
, 30, _RGB(50, 50, 50) LINE (pendulum
(1).
pos.x
, pendulum
(1).
pos.y
)-(tx2
, ty2
) CircleFill tx2
, ty2
, 30, _RGB(50, 50, 50)
pendulum(0).angInc = pendulum(0).angInc + .03
pendulum(1).angInc = pendulum(1).angInc + .05
px = tx2: py = ty2
f = f + 1
'By Fellippe
x0
= 0.5 * lineWeight%
* COS(a
) y0
= 0.5 * lineWeight%
* SIN(a
)
'This sub from here: http://www.[abandoned, outdated and now likely malicious qb64 dot net website - don’t go there]/forum/index.php?topic=1848.msg17254#msg17254
RadiusError = -Radius
X = Radius
Y = 0
' Draw the middle span here so we don't draw it twice in the main loop,
' which would be a problem with blending turned on.
LINE (CX
- X
, CY
)-(CX
+ X
, CY
), C
, BF
RadiusError = RadiusError + Y * 2 + 1
LINE (CX
- Y
, CY
- X
)-(CX
+ Y
, CY
- X
), C
, BF
LINE (CX
- Y
, CY
+ X
)-(CX
+ Y
, CY
+ X
), C
, BF
X = X - 1
RadiusError = RadiusError - X * 2
Y = Y + 1
LINE (CX
- X
, CY
- Y
)-(CX
+ X
, CY
- Y
), C
, BF
LINE (CX
- X
, CY
+ Y
)-(CX
+ X
, CY
+ Y
), C
, BF
'taken from p5js.bas
'https://bit.ly/p5jsbas
p5random!
= RND * (mx!
- mn!
) + mn!