Post by B+ on Feb 17, 2019 1:27:48 GMT
A little late or really early
So there is another way to fill a figure that this demos.
'Beating Cardioid.bas for JB v2, 2019-02-16 B+ translation from QB64
global H$, XMAX, YMAX, PI
H$ = "gr"
XMAX = 600 '<======================================== actual drawing space needed
YMAX = 600 '<======================================== actual drawing space needed
PI = acs(-1)
nomainwin
WindowWidth = XMAX + 8
WindowHeight = YMAX + 32
UpperLeftX = (1200 - XMAX) / 2 'or delete if XMAX is 1200 or above
UpperLeftY = (720 - YMAX) / 2 'or delete if YMAX is 700 or above
open "Beating Cardioid" for graphics_nsb_nf as #gr '<======================= title
#gr "setfocus"
#gr "trapclose quit"
#gr "down"
#gr "size 4"
#gr "color red"
'center of screen
CX = XMAX / 2
CY = YMAX / 2
WHILE 1
scan
#gr "fill white"
loopCount = (loopCount + 1) MOD 2
IF loopCount THEN magnify = 10 ELSE magnify = 15
FOR a = -1*PI TO PI STEP PI*(1 / 360)
scan
x = CX + magnify * xCard(a)
y = CY - magnify * yCard(a)
#gr "line ";CX;" ";CY;" ";x;" ";y 'add 1 to end point
NEXT
IF loopCount THEN call pause 500 ELSE call pause 550
WEND
wait
sub quit H$
close #H$
end
end sub
sub pause mil 'tsh version has scan built-in
t0 = time$("ms")
while time$("ms") < t0 + mil : scan : wend
end sub
'Reference and thanks to:
' http://mathworld.wolfram.com/HeartCurve.html
' find the 6th heart curve equations #7, 8
FUNCTION xCard (t)
xCard = 16 * SIN(t) ^ 3
END FUNCTION
FUNCTION yCard (t)
yCard = 13 * COS(t) - 5 * COS(2 * t) - 2 * COS(3 * t) - COS(4 * t)
END FUNCTION
So there is another way to fill a figure that this demos.