|
Post by cundo on Feb 5, 2023 21:43:36 GMT
I told CHAT gpt to write a code that draws a red heart, but got this, I don't know what it is hahaha 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
|
|
|
Post by plus on Feb 6, 2023 2:21:59 GMT
A little fix here and there:
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
open "Heart" for graphics_nsb_nf as #1 '<======================= title 'OPEN "Heart" FOR GRAPHICS AS #1 #1 "TRAPCLOSE [QUIT]" #1 "down" #1 "size 20" #1 "color red"
PRINT "COMIENZA DIBUJO" FOR I = 0 TO 180 STEP .01 X = .5*SIN(I) * 400 Y = .45*COS(I) * 400 - .7*(ABS(SIN(I)) * 200) #1 "set "; X + 400;" "; Y + 330 NEXT I
FOR I = 180 TO 0 STEP -.01 X = .5*SIN(I) * 400 Y = .45*COS(I) * 400 - .7*(ABS(SIN(I)) * 200) #1 "set "; X + 400;" "; Y + 330 NEXT I #1 "place ";390;" ";280;";|";"b+" PRINT "TERMINADO" #1 "FLUSH" WAIT
[QUIT] CLOSE #1 END
|
|
|
Post by plus on Feb 6, 2023 2:30:16 GMT
Oh don't need the second block, I was wondering why it took b+ so long? LOL
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
open "Heart" for graphics_nsb_nf as #1 '<======================= title 'OPEN "Heart" FOR GRAPHICS AS #1 #1 "TRAPCLOSE [QUIT]" #1 "down" #1 "size 20" #1 "color red"
PRINT "COMIENZA DIBUJO" FOR I = 0 TO 180 STEP .01 X = .5*SIN(I) * 400 Y = .45*COS(I) * 400 - .7*(ABS(SIN(I)) * 200) #1 "set "; X + 400;" "; Y + 330 NEXT I
#1 "place ";390;" ";280;";|";"b+" PRINT "TERMINADO" #1 "FLUSH" WAIT
[QUIT] CLOSE #1 END
|
|
|
Post by plus on Feb 6, 2023 2:32:15 GMT
It's fun when you get it working.
|
|
|
Post by tsh73 on Feb 6, 2023 6:26:20 GMT
Ha! interesting indeed They often said ChatGPT gave out programs that looks OK... but do not work :)
So this is little comma (,) which prevents source program from drawing ANYTHING
PRINT #1, "set "; X + 400; ","; Y + 300 should be
PRINT #1, "set "; X + 400; " "; Y + 300
Then it happened it draws for bigger screen so one needs to scale it down
Also,
FOR I = 0 TO 180 STEP 2 hints what angle is in degrees. While SIN/COS work in radians!
If you adapt code to work in radians you'll get half of a heart Hence two loops
But if you leave it 0..180, it will end with scattered points along the heart shape I added pause to see the order and color change to see several loops of small step;)
(and with small step it will just do consequitive points - but several loops around the shape!, 180/2pi, some 30 loops (long with pause/color change))
nomainwin
OPEN "Heart" FOR GRAPHICS_fs AS #1 PRINT #1, "TRAPCLOSE [QUIT]" PRINT #1, "home" PRINT #1, "down" PRINT #1, "size 10" PRINT #1, "color red"
Tpause=1' - big step 'or 'Tpause=100 '- small step
PRINT "COMIENZA DIBUJO" pi = acs(-1) FOR I = 0 TO 180 STEP 2/Tpause a=I'*pi/180 X = 0.5*SIN(a) * 400 Y = 0.5*COS(a) * 400 - 0.5*(ABS(SIN(a)) * 200) PRINT #1, "color ";rainbow$(I/180*10) PRINT #1, "set "; X + 400; " "; Y + 300 'PRINT #1, "set "; X + 400; ","; Y + 300 'print I, X, Y call pause 100/Tpause 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
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
|
|
|
Post by plus on Feb 6, 2023 16:26:51 GMT
Gotta animate it for Valentine's Day! 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 'OPEN "Heart" FOR GRAPHICS_fs AS #1 PRINT #1, "TRAPCLOSE [QUIT]" PRINT #1, "home" PRINT #1, "down" PRINT #1, "size 10" #1, "Fill Pink" #1, "Backcolor Pink" PRINT #1, "color White"
Tpause=5' - big step 'or 'Tpause=100 '- small step #1 "place ";390;" ";280;";|";"JB" for Tpause = 1 to 20 PRINT "COMIENZA DIBUJO" pi = acs(-1) FOR I = 0 TO 180 STEP 2/Tpause a=I'*pi/180 X = 0.5*SIN(a) * 400 Y = 0.5*COS(a) * 400 - 0.5*(ABS(SIN(a)) * 200) PRINT #1, "color ";rainbow$(I/180*10) PRINT #1, "set "; X + 400; " "; Y + 300 'PRINT #1, "set "; X + 400; ","; Y + 300 'print I, X, Y call pause 60 NEXT I next '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
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
Hope not too adolescent or girly to still have heart throbs and get mushy
|
|
|
Post by cundo on Feb 6, 2023 19:41:19 GMT
Beautiful ! Now we are having fun. The valentine's day was just a coincidence
|
|
|
Post by plus on Feb 8, 2023 20:12:44 GMT
Just posted another mod update at Friends of Basic 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
I think I removed most of excess variables and comments not in use?
|
|
|
Post by tsh73 on Feb 9, 2023 17:43:01 GMT
Today I was shown result of asking chatGPT "draw me a house in a Python". It produced page-long python program using Turtle module It even had comments like "door" "window" etc It compiled without error (so it was sintaxically correct) But all it produced was number of garbled lines, no slightest similarity to a house.
Nice phrase on one forum: "I do not afraid of first computer which 'll pass Turing test. But I am afraid first one who decide to conceal it".
|
|
|
Post by cundo on Feb 10, 2023 21:42:32 GMT
It is somewhat scary haha.
|
|
|
Post by marshawn on Feb 11, 2023 2:45:24 GMT
beautiful mods, B+, it's throbbing alright
|
|