Post by bplus on Feb 8, 2023 14:55:51 GMT -5
ChatGPT Draw a Heart in Just Basic code:
What's that? nutt'in!
Some fixes and additions at Just Basic forum and presto!
Something Fun!
OPEN "Heart" FOR GRAPHICS AS #1
PRINT #1, "TRAPCLOSE [QUIT]"
PRINT #1, "home"
PRINT #1, "down"
PRINT #1, "size 1"
PRINT #1, "color red"
PRINT "COMIENZA DIBUJO"
FOR I = 0 TO 180 STEP 2
X = SIN(I) * 400
Y = COS(I) * 400 - (ABS(SIN(I)) * 200)
PRINT #1, "set "; X + 400; ","; Y + 300
NEXT I
FOR I = 180 TO 0 STEP -2
X = SIN(I) * 400
Y = COS(I) * 400 - (ABS(SIN(I)) * 200)
PRINT #1, "set "; X + 400; ","; Y + 300
NEXT I
PRINT "TERMINADO"
PRINT #1, "FLUSH"
WAIT
[QUIT]
CLOSE #1
END
What's that? nutt'in!
Some fixes and additions at Just Basic forum and presto!
global Xmax, Ymax
Xmax = 800
Ymax = 600
WindowWidth = Xmax + 8
WindowHeight = Ymax + 32
UpperLeftX = (DisplayWidth - Xmax) / 2 'or delete if Xmax is 1200 or above
UpperLeftY = (DisplayHeight - Ymax) / 2 'or delete if Ymax is 700 or above
nomainwin
open "Heart" for graphics_nsb_nf as #1 '<======================= title
#1, "Font Arial 64"
PRINT #1, "TRAPCLOSE [QUIT]"
PRINT #1, "home"
PRINT #1, "down"
PRINT #1, "size 40"
#1, "Fill Pink"
#1, "Backcolor Pink"
PRINT #1, "color White"
#1 "place ";350;" ";280;";|";"JB"
for Tpause = 1 to 20
FOR I = 0 TO 180 STEP .1
X = 0.5*SIN(I) * 400
Y = 0.5*COS(I) * 400 - 0.5*(ABS(SIN(I)) * 200)
PRINT #1, "color ";rainbow$(I/180*10)
PRINT #1, "set "; X + 400; " "; Y + 300
call pause 20
NEXT I
next
PRINT #1, "FLUSH"
WAIT
[QUIT]
CLOSE #1
END
sub pause mil
t0=time$("ms")+mil
while time$("ms")<t0
scan
wend
exit sub
[QUIT]
CLOSE #1
END
end sub
' 0..1 into red-green-blue-red continuous colors
function rainbow$(x)
hi = int((x*6) mod 6)+ 5*(x<0) 'fixed to 0..5
f = (x*6) mod 1 + (x<0) 'frac, 0..1
q = (1-f)
select case hi
case 0
r = 1: g = f: b = 0
case 1
r = q: g = 1: b = 0
case 2
r = 0: g = 1: b = f
case 3
r = 0: g = q: b = 1
case 4
r = f: g = 0: b = 1
case 5
r = 1: g = 0: b = q
end select
R = int(r*255)
G = int(g*255)
B = int(b*255)
rainbow$= R;" ";G;" ";B
end function
Something Fun!