|
Spinner
Jun 23, 2021 15:54:00 GMT -5
Post by bplus on Jun 23, 2021 15:54:00 GMT -5
A fun little graphics proggie! Maybe aurel can do this on his interpreter: _Title "Spinner" 'b+ 2021-06-18 Screen _NewImage(500, 500, 32) Const rad = _Pi / 180 While 1 Cls b = b + 5 For r = 20 To 200 Step 20 ' tsh73 suggested fix for inner most a = b * r / 20 For i = r - 15 To r arc 250, 250, i, a, 180 Next Next _Display _Limit 15 Wend Sub arc (xCenter, yCenter, arcRadius, dAStart, dAMeasure) 'notes: 'you may want to adjust size and color for line drawing 'using angle measures in degrees to match Just Basic ways with pie and piefilled 'this sub assumes drawing in a CW direction if dAMeasure positive 'for Just Basic angle 0 degrees is due East and angle increases clockwise towards South 'dAStart is degrees to start Angle, due East is 0 degrees 'dAMeasure is degrees added (Clockwise) to dAstart for end of arc rAngleStart = rad * dAStart rAngleEnd = rad * dAMeasure + rAngleStart Stepper = rad / (.1 * arcRadius) 'fixed lastX = xCenter + arcRadius * Cos(rAngleStart) lastY = yCenter + arcRadius * Sin(rAngleStart) PSet (lastX, lastY) For rAngle = rAngleStart + Stepper To rAngleEnd Step Stepper nextX = xCenter + arcRadius * Cos(rAngle) nextY = yCenter + arcRadius * Sin(rAngle) Line -(nextX, nextY) 'int speeds things up Next End Sub
|
|
|
Spinner
Jun 23, 2021 15:58:46 GMT -5
Post by bplus on Jun 23, 2021 15:58:46 GMT -5
Oh! for slow Interpreter maybe the Just Basic version would be best to port:
global H$, XMAX, YMAX, PI, DEG, RAD, goON H$ = "gr" XMAX = 500 '<======================================== actual drawing space needed YMAX = 500 '<======================================== actual drawing space needed PI = acs(-1) DEG = 180 / PI RAD = PI / 180
nomainwin
WindowWidth = XMAX + 8 WindowHeight = YMAX + 32 UpperLeftX = (1200 - XMAX) / 2 'or delete if XMAX is 1200 or above UpperLeftY = (700 - YMAX) / 2 'or delete if YMAX is 700 or above
open "Spinner" for graphics_nsb_nf as #gr '<======================= title #gr "setfocus" #gr "trapclose quit" #gr "down" #gr "fill black" #gr "size 15" While 1 For r = 20 To 200 Step 20 scan a = b * r / 40 #gr "color blue" call arc 250, 250, r - 10, a, 165 #gr "color red" call arc 250, 250, r - 10, a+ 180, 165 Next b = b + 2 call pause 20 Wend wait
sub arc xCenter, yCenter, arcRadius, dAStart, dAMeasure 'notes: 'you may want to adjust size and color for line drawing 'using angle measures in degrees to match Just Basic ways with pie and piefilled 'this sub assumes drawing in a CW direction if dAMeasure positive
'for Just Basic angle 0 degrees is due East and angle increases clockwise towards South
'dAStart is degrees to start Angle, due East is 0 degrees
'dAMeasure is degrees added (Clockwise) to dAstart for end of arc
rAngleStart = RAD * dAStart rAngleEnd = RAD * dAMeasure + rAngleStart Stepper = RAD* 180/ arcRadius 'fixed lastX = xCenter + arcRadius * cos(rAngleStart) lastY = yCenter + arcRadius * sin(rAngleStart) #gr "set ";int(lastX);" ";int(lastY) for rAngle = rAngleStart+Stepper to rAngleEnd step Stepper nextX = xCenter + arcRadius * cos(rAngle) nextY = yCenter + arcRadius * sin(rAngle) #gr "goto ";int(nextX);" ";int(nextY) 'int speeds things up next end sub
sub pause mil 'tsh version has scan built-in t0 = time$("ms") while time$("ms") < t0 + mil : scan : wend end sub
sub quit H$ close #H$ '<=== this needs Global H$ = "gr" end 'Thanks Facundo, close graphic wo error end sub
You'll have to ignore or work around Just Basic idiosyncratic way of Screen or Window setup and handling.
|
|
johnno56
Junior Member
Logic is the beginning of wisdom.
Posts: 85
|
Spinner
Jun 23, 2021 17:10:29 GMT -5
Post by johnno56 on Jun 23, 2021 17:10:29 GMT -5
This is pretty cool... Even looks good in blue... *wink*
J
|
|
|
Spinner
Jun 23, 2021 19:12:24 GMT -5
Post by bplus on Jun 23, 2021 19:12:24 GMT -5
This is pretty cool... Even looks good in blue... *wink* J Oh blue, yes we can ;-)) _Title "Spinner" 'b+ 2021-06-18 Screen _NewImage(500, 500, 32) Const rad = _Pi / 180 Color , &HFF000088 While 1 Cls b = b + 5 For r = 20 To 200 Step 20 ' tsh73 suggested fix for inner most a = b * r / 20 For i = r - 15 To r Color _RGB32(255 - r, 255 - .5 * r, 255) arc 250, 250, i, a, 180 Next Next _Display _Limit 15 Wend
Sub arc (xCenter, yCenter, arcRadius, dAStart, dAMeasure) 'notes: 'you may want to adjust size and color for line drawing 'using angle measures in degrees to match Just Basic ways with pie and piefilled 'this sub assumes drawing in a CW direction if dAMeasure positive
'for Just Basic angle 0 degrees is due East and angle increases clockwise towards South
'dAStart is degrees to start Angle, due East is 0 degrees
'dAMeasure is degrees added (Clockwise) to dAstart for end of arc
rAngleStart = rad * dAStart rAngleEnd = rad * dAMeasure + rAngleStart Stepper = rad / (.1 * arcRadius) 'fixed lastX = xCenter + arcRadius * Cos(rAngleStart) lastY = yCenter + arcRadius * Sin(rAngleStart) PSet (lastX, lastY) For rAngle = rAngleStart + Stepper To rAngleEnd Step Stepper nextX = xCenter + arcRadius * Cos(rAngle) nextY = yCenter + arcRadius * Sin(rAngle) Line -(nextX, nextY) 'int speeds things up Next End Sub
Guess I blew it?
|
|
johnno56
Junior Member
Logic is the beginning of wisdom.
Posts: 85
|
Spinner
Jun 24, 2021 3:10:30 GMT -5
Post by johnno56 on Jun 24, 2021 3:10:30 GMT -5
That was a nicer blue than I had... I had just given it _RGB32(0, 0, 191). I like yours better...
|
|
|
Spinner
Sept 27, 2023 20:48:18 GMT -5
Post by bplus on Sept 27, 2023 20:48:18 GMT -5
Spinner Update: 'Option _Explicit _Title "Spinner 2" 'b+ 2021-06-18
' 2023-09-25 convert to QBJS ' 2023-09-27 use FArc for Fat Arcs!
$If WEB Then import G2D From "lib/graphics/2d.bas" $End If
Dim As Long b, r Dim a Dim K As _Unsigned Long Screen _NewImage(500, 500, 32)
While 1 Cls b = b + 1 For r = 10 To 200 Step 10 ' tsh73 suggested fix for inner most a = _D2R(b * r / 20) If Int(r / 10) Mod 2 Then K = &HFF009900 Else K = &HFF0000FF FArc 250, 250, r, 3, a, a + _Pi, K Next _Display _Limit 20 ' slowed down for QBJS Wend
'2023-02-04 Fill Arc draw an arc with thickness, tested in Profile Pong 3-0 ' this sub needs sub FCirc(CX As Long, CY As Long, R As Long, C As _Unsigned Long) for dots Sub FArc (x, y, r, thickness, RadianStart, RadianStop, c As _Unsigned Long) Dim al, a 'x, y origin of arc, r = radius, thickness is radius of dots, c = color 'RadianStart is first angle clockwise from due East = 0 in Radians ' arc will start drawing there and clockwise until RadianStop angle reached
If RadianStop < RadianStart Then FArc x, y, r, thickness, RadianStart, _Pi(2), c FArc x, y, r, 0, thickness, RadianStop, c Else al = _Pi * r * r * (RadianStop - RadianStart) / _Pi(2) For a = RadianStart To RadianStop Step 1 / r FCirc x + r * Cos(a), y + r * Sin(a), thickness, c Next End If End Sub
' modified for QBJS AND QB64 Sub FCirc (CX As Long, CY As Long, R As Long, C As _Unsigned Long)
' put this at top of QB64 to QBJS code '$If WEB Then ' import G2D From "lib/graphics/2d.bas" '$End If
$If WEB Then G2D.FillCircle CX, CY, R, C $Else Dim Radius As Long, RadiusError As Long Dim X As Long, Y As Long Radius = Abs(R): RadiusError = -Radius: X = Radius: Y = 0 If Radius = 0 Then PSet (CX, CY), C: Exit Sub Line (CX - X, CY)-(CX + X, CY), C, BF While X > Y RadiusError = RadiusError + Y * 2 + 1 If RadiusError >= 0 Then If X <> Y + 1 Then Line (CX - Y, CY - X)-(CX + Y, CY - X), C, BF Line (CX - Y, CY + X)-(CX + Y, CY + X), C, BF End If X = X - 1 RadiusError = RadiusError - X * 2 End If 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 Wend $End If End Sub
Works in QBJS too, copy / paste to qbjs.org and press Play button,
|
|
|
Spinner
Sept 28, 2023 4:26:14 GMT -5
Post by zxdunny on Sept 28, 2023 4:26:14 GMT -5
For those of you not in the realtime chat, I made this in SpecBAS where due to the unique handling of DRAW in the venerable Sinclair BASIC, it's a much shorter snippet of code: 10 def proc arc(xc,yc,r,st,a,t): ea=st+a,fr=r+t/2,fa=st+a/2,t+=r, cst=cos st,sst=sin st,cea=cos ea,sea=sin ea: x1=xc+r*cst,y1=yc+r*sst,x2=xc+r*cea,y2=yc+r*sea, x3=xc+t*cst,y3=yc+t*sst,x4=xc+t*cea,y4=yc+t*sea: draw x1,y1 to x2,y2,a: draw x3,y3 to x4,y4,a: draw x1,y1 to x3,y3,pi: draw x2,y2 to x4,y4,-pi: fill xc+fr*cos fa,yc+fr*sin fa: end proc 20 s=200/15,g=5 30 cls 0: i=0: For r=5 To 200 Step s: a=msecs*(r+s)/5e4: ink i+=iif(i<15,1,-14): proc arc(400,240,r,a,pi,s-g): Next r: wait screen: GO To 30 Which produces this display: And I'm actually quite chuffed with how that turned out
|
|
|
Spinner
Sept 28, 2023 20:10:10 GMT -5
Post by bplus on Sept 28, 2023 20:10:10 GMT -5
"chuffed" had to look that one up
|
|
|
Spinner
Sept 28, 2023 21:04:20 GMT -5
Post by charliejv on Sept 28, 2023 21:04:20 GMT -5
This is pretty cool... Even looks good in blue... *wink* J Oh blue, yes we can ;-)) _Title "Spinner" 'b+ 2021-06-18 Screen _NewImage(500, 500, 32) Const rad = _Pi / 180 Color , &HFF000088 While 1 Cls b = b + 5 For r = 20 To 200 Step 20 ' tsh73 suggested fix for inner most a = b * r / 20 For i = r - 15 To r Color _RGB32(255 - r, 255 - .5 * r, 255) arc 250, 250, i, a, 180 Next Next _Display _Limit 15 Wend
Sub arc (xCenter, yCenter, arcRadius, dAStart, dAMeasure) 'notes: 'you may want to adjust size and color for line drawing 'using angle measures in degrees to match Just Basic ways with pie and piefilled 'this sub assumes drawing in a CW direction if dAMeasure positive
'for Just Basic angle 0 degrees is due East and angle increases clockwise towards South
'dAStart is degrees to start Angle, due East is 0 degrees
'dAMeasure is degrees added (Clockwise) to dAstart for end of arc
rAngleStart = rad * dAStart rAngleEnd = rad * dAMeasure + rAngleStart Stepper = rad / (.1 * arcRadius) 'fixed lastX = xCenter + arcRadius * Cos(rAngleStart) lastY = yCenter + arcRadius * Sin(rAngleStart) PSet (lastX, lastY) For rAngle = rAngleStart + Stepper To rAngleEnd Step Stepper nextX = xCenter + arcRadius * Cos(rAngle) nextY = yCenter + arcRadius * Sin(rAngle) Line -(nextX, nextY) 'int speeds things up Next End Sub
Guess I blew it? That was rather painless:
|
|
aurel
Full Member
Posts: 233
|
Spinner
Sept 29, 2023 7:44:56 GMT -5
Post by aurel on Sept 29, 2023 7:44:56 GMT -5
maybe ..but is kind of boring to me ..i mean i already have to much graphic examples and this one need local variables ..arghhhh
|
|
aurel
Full Member
Posts: 233
|
Spinner
Sept 29, 2023 7:56:47 GMT -5
Post by aurel on Sept 29, 2023 7:56:47 GMT -5
Anyway why this program need any local varibles it have 10 stages or orbits around center of circle ploting ..similar to solar system i made in micro(A)
so i think it can be made in much easier way then this complex jumping around.
'mini solar system - micro(A) var x,y,x1,y1,pi,t,w,h ,r, w2, h2,fPi,fRad,r2 var x2,y2, x3,y3, x4,y4, x5,y5, x6,y6, x7,y7, x8,y8, x9,y9 var r2,r3,r4,r5,r6,r7,r8,r9 w = 800 : h = 600 : w2 = w / 2 : h2 = (h / 2)-20 fPi = Cos(0.98) : fRad = fPi / 180 wcolor 0,0,0 t = 0 r = 30 r2 = 50 r3 = 90 r4 = 130 r5 = 150 r6 = 190 r7 = 220 r8 = 240 r9 = 270 fcolor 0,100,200
'---------------------------------- label start
fcolor 160,160,160 : rect 0,0,800,600 fcolor 160,160,160 : circle w2,h2,r9 fcolor 160,160,160 : circle w2,h2,r8 fcolor 160,160,160 : circle w2,h2,r7 fcolor 160,160,160 : circle w2,h2,r6 fcolor 160,160,160 : circle w2,h2,r5 fcolor 160,160,160 : circle w2,h2,r4 fcolor 160,160,160 : circle w2,h2,r3 fcolor 160,160,160 : circle w2,h2,r2 fcolor 160,160,160 : circle w2,h2,r
'sun fcolor 240,200,100 : circle w2,h2,10 : print 4,4,"MINI SOLAR SYSTEM" x = w2 + r * Cos(t + 0.5 + fRad * 90) : y = h2 + r * Sin(t+0.5 + fRad * 90) fcolor 150,100,20 : circle x,y,5 :print x,y,"mercury" x2 = w2 + r2 * Cos(t-0.5 + fRad * 90) : y2 = h2 + r2 * Sin(t-0.5 + fRad * 90) fcolor 200,180,0 : circle x2,y2,8 : print x2,y2," venus"
x3 = w2 + r3 * Cos(t + fRad * 90) : y3 = h2 + r3 * Sin(t + fRad * 90) fcolor 0,150,200 : circle x3,y3,8 : print x3,y3," earth"
x4 = w2 + r4 * Cos(t+0.9 + fRad * 90) : y4 = h2 + r4 * Sin(t+0.9 + fRad * 90) fcolor 240,160,100 : circle x4,y4,7 : print x4,y4," mars"
x5 = w2 + r5 * Cos(t- 0.9 + fRad * 90) : y5 = h2 + r5 * Sin(t- 0.9 + fRad * 90) fcolor 180,190,210 : circle x5,y5,12 : print x5,y5," jupiter"
x6 = w2 + r6 * Cos(t- 2.5 + fRad * 90) : y6 = h2 + r6 * Sin(t- 2.5 + fRad * 90) fcolor 230,190,110 : circle x6,y6,10 : print x6,y6," saturn"
x7 = w2 + r7 * Cos(t- 3.2 + fRad * 90) : y7 = h2 + r7 * Sin(t- 3.2 + fRad * 90) fcolor 130,190,240 : circle x7,y7,6 : print x7,y7," uranus"
x8 = w2 + r8 * Cos(t- 4.2 + fRad * 90) : y8 = h2 + r8 * Sin(t- 4.2 + fRad * 90) fcolor 130,190,160 : circle x8,y8,6 : print x8,y8," neptune"
x9 = w2 + r9 * Cos(t- 5.5 + fRad * 90) : y9 = h2 + r9 * Sin(t- 5.5 + fRad * 90) fcolor 160,160,160 : circle x9,y9,5 : print x9,y9," pluto"
t = t + 0.001666 swap goto start
|
|
|
Spinner
Sept 29, 2023 7:59:29 GMT -5
Post by zxdunny on Sept 29, 2023 7:59:29 GMT -5
Anyway why this program need any local varibles it have 10 stages or orbits around center of circle ploting ..similar to solar system i made in micro(A) so i think it can be made in much easier way then this complex jumping around. Yeah this doesn't even need a sub, it could all be inlined without issues.
|
|
|
Spinner
Sept 29, 2023 8:53:15 GMT -5
Post by bplus on Sept 29, 2023 8:53:15 GMT -5
Anyway why this program need any local varibles it have 10 stages or orbits around center of circle ploting ..similar to solar system i made in micro(A) so i think it can be made in much easier way then this complex jumping around. 'mini solar system - micro(A) var x,y,x1,y1,pi,t,w,h ,r, w2, h2,fPi,fRad,r2 var x2,y2, x3,y3, x4,y4, x5,y5, x6,y6, x7,y7, x8,y8, x9,y9 var r2,r3,r4,r5,r6,r7,r8,r9 w = 800 : h = 600 : w2 = w / 2 : h2 = (h / 2)-20 fPi = Cos(0.98) : fRad = fPi / 180 wcolor 0,0,0 t = 0 r = 30 r2 = 50 r3 = 90 r4 = 130 r5 = 150 r6 = 190 r7 = 220 r8 = 240 r9 = 270 fcolor 0,100,200
'---------------------------------- label start
fcolor 160,160,160 : rect 0,0,800,600 fcolor 160,160,160 : circle w2,h2,r9 fcolor 160,160,160 : circle w2,h2,r8 fcolor 160,160,160 : circle w2,h2,r7 fcolor 160,160,160 : circle w2,h2,r6 fcolor 160,160,160 : circle w2,h2,r5 fcolor 160,160,160 : circle w2,h2,r4 fcolor 160,160,160 : circle w2,h2,r3 fcolor 160,160,160 : circle w2,h2,r2 fcolor 160,160,160 : circle w2,h2,r
'sun fcolor 240,200,100 : circle w2,h2,10 : print 4,4,"MINI SOLAR SYSTEM" x = w2 + r * Cos(t + 0.5 + fRad * 90) : y = h2 + r * Sin(t+0.5 + fRad * 90) fcolor 150,100,20 : circle x,y,5 :print x,y,"mercury" x2 = w2 + r2 * Cos(t-0.5 + fRad * 90) : y2 = h2 + r2 * Sin(t-0.5 + fRad * 90) fcolor 200,180,0 : circle x2,y2,8 : print x2,y2," venus"
x3 = w2 + r3 * Cos(t + fRad * 90) : y3 = h2 + r3 * Sin(t + fRad * 90) fcolor 0,150,200 : circle x3,y3,8 : print x3,y3," earth"
x4 = w2 + r4 * Cos(t+0.9 + fRad * 90) : y4 = h2 + r4 * Sin(t+0.9 + fRad * 90) fcolor 240,160,100 : circle x4,y4,7 : print x4,y4," mars"
x5 = w2 + r5 * Cos(t- 0.9 + fRad * 90) : y5 = h2 + r5 * Sin(t- 0.9 + fRad * 90) fcolor 180,190,210 : circle x5,y5,12 : print x5,y5," jupiter"
x6 = w2 + r6 * Cos(t- 2.5 + fRad * 90) : y6 = h2 + r6 * Sin(t- 2.5 + fRad * 90) fcolor 230,190,110 : circle x6,y6,10 : print x6,y6," saturn"
x7 = w2 + r7 * Cos(t- 3.2 + fRad * 90) : y7 = h2 + r7 * Sin(t- 3.2 + fRad * 90) fcolor 130,190,240 : circle x7,y7,6 : print x7,y7," uranus"
x8 = w2 + r8 * Cos(t- 4.2 + fRad * 90) : y8 = h2 + r8 * Sin(t- 4.2 + fRad * 90) fcolor 130,190,160 : circle x8,y8,6 : print x8,y8," neptune"
x9 = w2 + r9 * Cos(t- 5.5 + fRad * 90) : y9 = h2 + r9 * Sin(t- 5.5 + fRad * 90) fcolor 160,160,160 : circle x9,y9,5 : print x9,y9," pluto"
t = t + 0.001666 swap goto start Why does this code need umpteen x#, y#, r# variables?: var x2,y2, x3,y3, x4,y4, x5,y5, x6,y6, x7,y7, x8,y8, x9,y9 r = 30 r2 = 50 r3 = 90 r4 = 130 r5 = 150 r6 = 190 r7 = 220 r8 = 240 r9 = 270 When arrays will do, cut your code in less than half with FOR loop! Don't need to reply, I know why! hee, hee thinks his MicroA is BIG Sh..
|
|
aurel
Full Member
Posts: 233
|
Spinner
Sept 29, 2023 15:39:54 GMT -5
Post by aurel on Sept 29, 2023 15:39:54 GMT -5
if something is big shit ..it is your way of programming using usr functions for every piece of crap and don't acting like smart_ass_tomaaz
|
|
|
Spinner
Sept 30, 2023 10:06:53 GMT -5
Post by bplus on Sept 30, 2023 10:06:53 GMT -5
if something is big shit ..it is your way of programming using usr functions for every piece of crap and don't acting like smart_ass_tomaaz Well I was thinking shot, "Big Shot" but confess maybe leave it open to people's imagination, see what they do with it Very predictable Aurel! Ha! I guess it gets lonely on the MicroA Board, so you come into the QB64 board dump your junk and then bit** a fit when someone says, "Hey!" Well again I confess, at least it gets the blood stirred up in us old geezers Sorry to be making fun of MicroA, no Basic is perfect except our own of course
|
|
|
Spinner
Sept 30, 2023 10:15:54 GMT -5
Post by bplus on Sept 30, 2023 10:15:54 GMT -5
Oh dang it! I see Charlie invited him in with this:
Sh Charlie what the smeg you do'n mess'in with the devil!
(I hope we all are friends enough I can say that without piss'n off people even more!)
|
|
|
Spinner
Sept 30, 2023 10:16:55 GMT -5
Post by bplus on Sept 30, 2023 10:16:55 GMT -5
smeg = Mid$("hello", 1, 4)
Love this AI censor s*
|
|
|
Spinner
Sept 30, 2023 10:25:59 GMT -5
Post by bplus on Sept 30, 2023 10:25:59 GMT -5
Oh double dang!!! dang dang I started this S* with my first post.
Well hey! how was I to know back then that this big a* battle would brew up between a couple of my friends, who I like, so real sucky for me in the middle.
But hey, in my defense I wrote that invitation to Aurel June 23, 2021 over 2 frick'n years ago!
And for some reason maybe ZXDunny post maybe or maybe Charlie's he finally gets around to posting something. Most curious!
This is very interesting thread!
|
|
|
Spinner
Sept 30, 2023 11:25:09 GMT -5
Post by charliejv on Sept 30, 2023 11:25:09 GMT -5
Oh dang it! I see Charlie invited him in with this: Sh Charlie what the smeg you do'n mess'in with the devil! (I hope we all are friends enough I can say that without piss'n off people even more!) Hey, "Maybe aurel can do this on his interpreter". You wrote that in the second line of your original post.
|
|
|
Spinner
Sept 30, 2023 11:27:56 GMT -5
Post by charliejv on Sept 30, 2023 11:27:56 GMT -5
Oh double dang!!! dang dang I started this S* with my first post. Well hey! how was I to know back then that this big a* battle would brew up between a couple of my friends, who I like, so real sucky for me in the middle. But hey, in my defense I wrote that invitation to Aurel June 23, 2021 over 2 frick'n years ago! And for some reason maybe ZXDunny post maybe or maybe Charlie's he finally gets around to posting something. Most curious! This is very interesting thread! Ah, I thought I had reached the last post. I kind of thought you were on the wacky tobacky for a bit.
|
|