|
Post by bplus on Oct 19, 2023 14:37:05 GMT
Instead of starting a whole new thread for another little Proggie from bplus, how about all in one thread? To kick this thread off, I present to you my latest creation: Plasma PLUS Vonoroi !!! Warning: Extremely bright and moving colors may cause epileptic seizures, run at your own risk. !!! 'Option _Explicit _Title "Real Plasma and Voronoi, press key for new scheme" '2023-10-19 b+ overhaul of 'fake-voronoi-plasma.bas Dav, OCT/2023
Screen _NewImage(600, 600, 32) '_ScreenMove 290, 40 Randomize Timer $If WEB Then Import G2D From "lib/graphics/2d.bas" $End If
' cap all shared variables Dim Shared As Long CX, CY, Radius ' modified by Setup Dim Shared As Single Rd, Gn, Bl ' plasma colorsfor RGB Dim Shared As Long NP ' voronoi pt count mod in setup Dim Shared As Single Angle ' mod in setup Dim Shared As Long Direction ' mod random turning clockwise or counter
' local Dim As Long x, y ' from screen ReDim As Single px(1 To NP), py(1 To NP) ' voronoi points hopefully a spinning polygon Dim As Single px, py, d, dist ' Voronoi calcs point and distance Dim As Single da ' is polygon animating index Dim As Long i, t ' indexes i a regular one and t for plasma color Dim k$ ' polling keypresses Dim c As _Unsigned Long ' plasma color line is soooooo long! save it in c container
'once and for all time CX = _Width / 2: CY = _Height / 2: Radius = _Height / 3
Setup Do For y = 0 To _Height - 1 Step 4 For x = 0 To _Width - 1 Step 4 d = 100000 ' too big! For i = 1 To NP px = CX + Radius * Cos(i * Angle + da) py = CY + Radius * Sin(i * Angle + da) dist = Sqr(((x - px) ^ 2) + ((y - py) ^ 2)) If dist < d Then d = dist Next d = d + t c = _RGB32(127 + 127 * Sin(Rd * d), 127 + 127 * Sin(Gn * d), 127 + 127 * Sin(Bl * d)) FCirc x, y, 3, c Next Next
'animate! t = t + 2: da = da + _Pi(2 / 90) * Direction k$ = InKey$ If Len(k$) Then If Asc(k$) = 27 Then End Else 'reset plasma Setup: t = 0 End If End If _Display _Limit 30 'ha! Loop Until InKey$ = Chr$(27)
Sub Setup ' reset shared 'setup plasma for RGB color Rd = Rnd * Rnd: Gn = Rnd * Rnd: Bl = Rnd * Rnd
'setup voronoi variables for calcs NP = Int(Rnd * 10) + 3 ' 9 + 3 max number of poly points Angle = _Pi(2 / NP) ' angle between Direction = 2 * Int(Rnd * 2) - 1 ' turn clockwise or the other wise End Sub
' this sub for circle fill so can use code in QBJS wo mod Sub FCirc (CX As Long, CY As Long, R As Long, C As _Unsigned Long) $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
![](//storage.proboards.com/7292714/thumbnailer/PIwGPUkEeYIPDaiVtXsn.png) Hope to have decent QBJS working later on.
|
|
|
Post by bplus on Oct 19, 2023 21:43:17 GMT
Another Plasma Plus Vonoroi! '$If WEB Then ' Import G2D From "lib/graphics/2d.bas" '$End If Screen _NewImage(800, 600, 32) Dim Shared As Single Rd, Gn, Bl Dim Shared As Long NP ReDim Shared As Long Px(1 To NP), Py(1 To NP) Dim As Long x, y Dim As Single d, dist Dim As Long i Dim As Single t Dim k$ Dim c As _Unsigned Long Setup Do For y = 0 To _Height - 1 Step 2 For x = 0 To _Width - 1 Step 2 d = 10000 For i = 1 To NP dist = _Hypot(x - Px(i), y - Py(i)) If dist < d Then d = dist Next d = d + t c = _RGB32(127 + 127 * Sin(Rd * d), 127 + 127 * Sin(Gn * d), 127 + 127 * Sin(Bl * d)) Line (x, y)-Step(2, 2), c, BF Next Next t = t + 1 k$ = InKey$ If Len(k$) Then Setup: t = 0 End If _Display _Limit 30 'ha! Loop Until _KeyDown(27)
Sub Setup Dim As Long i Rd = Rnd * Rnd: Gn = Rnd * Rnd: Bl = Rnd * Rnd NP = Int(Rnd * 50) + 3 ReDim As Long Px(1 To NP), Py(1 To NP) For i = 1 To NP Px(i) = Int(Rnd * _Width) Py(i) = Int(Rnd * _Height) Next End Sub
![](//storage.proboards.com/7292714/thumbnailer/lXHV0cQdmLoMNTuSpNuA.png)
|
|
|
Post by bplus on Oct 21, 2023 0:11:20 GMT
Carbonated Circle Fractal Option _Explicit _Title "Carbonated Circle Fractal by bplus 2017-10-15" ' working from Ashish simple Circle Fractal
ReDim Shared As Long cx(0), cy(0), cr(0) Dim Shared xmax, ymax Dim Shared As Long ci, r1, basey, nb, i, r Dim antiGravity
nb = 60 Dim bx(nb), by(nb), br(nb), bdy(nb) Dim bc~&(nb)
xmax = 700 ymax = 700
Screen _NewImage(xmax, ymax, 32) _ScreenMove 290, 40 Randomize Timer
r1 = 150 basey = ymax - r1 - 10 drawCircle xmax / 2, basey, r1 antiGravity = -.6
For i = 1 To nb r = rand&(1, ci) bx(i) = cx(r): by(i) = rand(0, basey): br(i) = cr(r): bdy(i) = rand(-4, -2) bc~&(i) = _RGB32(Rnd * 155 + 100, Rnd * 155 + 100, Rnd * 155 + 100) Next Cls Do While 1 Cls For i = 1 To ci Color &HFF88DDDD Circle (cx(i), cy(i)), cr(i) Next For i = 1 To nb Color bc~&(i) Circle (bx(i), by(i)), br(i) If by(i) - 4 + br(i) < 0 Then r = rand&(1, ci) bx(i) = cx(r) by(i) = cy(r) br(i) = cr(r) bdy(i) = rand&(-4, -2) bc~&(i) = _RGB32(rand&(100, 255), rand&(100, 255), rand&(100, 255)) Else bdy(i) = bdy(i) + antiGravity by(i) = by(i) + bdy(i) End If Next _Display _Limit 10 Wend Loop
Sub drawCircle (x, y, r) ' draws fractal Circle (x, y), r ci = ci + 1 ReDim _Preserve cx(ci): cx(ci) = x ReDim _Preserve cy(ci): cy(ci) = y ReDim _Preserve cr(ci): cr(ci) = r If r > 2 Then drawCircle x + r, y, r / 2 drawCircle x - r, y, r / 2 End If End Sub
Function rand& (lo&, hi&) rand& = Int(Rnd * (hi& - lo& + 1)) + lo& End Function
![](//storage.proboards.com/7292714/thumbnailer/BjUMQtTtxQrrmwbHPtbq.png)
|
|
|
Post by bplus on Oct 27, 2023 8:20:31 GMT
Plasma Plus Vonoroi #3 _Title "Plasma Plus Vonoroi 3" ' b+ 2023-10 ' move points that are either holes or humps!
'$If WEB Then ' Import G2D From "lib/graphics/2d.bas" '$End If Screen _NewImage(800, 600, 32) Type Pt_Type X As Single ' location Y As Single DX As Single ' moving points DY As Single HoleTF As Long ' TF hole of not (= bump/ hill) here is the new twist! End Type
Dim Shared As Single Rd, Gn, Bl Dim Shared As Long NP ReDim Shared Pt(1 To 1) As Pt_Type Dim As Long x, y Dim As Single d, dist, f Dim As Long i, savei Dim As Single t Dim k$ Dim c As _Unsigned Long Setup Do For y = 0 To _Height - 1 Step 2 For x = 0 To _Width - 1 Step 2 d = 10000 For i = 1 To NP dist = _Hypot(x - Pt(i).X, y - Pt(i).Y) If dist < d Then d = dist: savei = i Next If Pt(savei).HoleTF Then d = t - d Else d = d + t End If c = _RGB32(127 + 127 * Sin(Rd * d), 127 + 127 * Sin(Gn * d), 127 + 127 * Sin(Bl * d)) Line (x, y)-Step(2, 2), c, BF Next Next For i = 1 To NP ' move along If Pt(i).X + Pt(i).DX < 0 Or Pt(i).X + Pt(i).DX > _Width - 1 Then Pt(i).DX = -Pt(i).DX If Pt(i).Y + Pt(i).DY < 0 Or Pt(i).Y + Pt(i).DY > _Height - 1 Then Pt(i).DY = -Pt(i).DY Pt(i).X = Pt(i).X + Pt(i).DX: Pt(i).Y = Pt(i).Y + Pt(i).DY Next t = t + 1 k$ = InKey$ If Len(k$) Then Setup: t = 0 End If _Display _Limit 30 'ha! Loop Until _KeyDown(27)
Sub Setup Dim As Long i Rd = Rnd * Rnd: Gn = Rnd * Rnd: Bl = Rnd * Rnd NP = Int(Rnd * 50) + 3 ReDim Pt(1 To NP) As Pt_Type For i = 1 To NP Pt(i).X = Int(Rnd * _Width) Pt(i).Y = Int(Rnd * _Height) Pt(i).DX = (2 * Int(Rnd * 2) - 1) * (Rnd * 5 + .5) Pt(i).DY = (2 * Int(Rnd * 2) - 1) * (Rnd * 5 + .5) Pt(i).HoleTF = Int(Rnd * 2) Next End Sub
![](//storage.proboards.com/7292714/thumbnailer/KsUmNbhQJFwmIul0ldiz.png)
|
|
|
Post by bplus on Oct 29, 2023 13:01:45 GMT
Sin Wave on circle _Title "Sin wave on circle" ' b+ fixed up 2023-10-29 Option _Explicit Const xmax = 1200, ymax = 700 Screen _NewImage(xmax, ymax, 32) _FullScreen Randomize Timer Dim Shared cn, pr, pg, pb Dim xc, yc, r, r1, a, xb, yb, xd, yd xc = _Width / 2: yc = _Height / 2: r = 100: r1 = 10 Do resetPlasma For r = 0 To 300 Step 1 r1 = 10 + .1 * r For a = 0 To _Pi(2) Step .0005 xb = xc + r * Cos(a) yb = yc + r * Sin(a) xd = xb + r1 * Cos(-21 * a) yd = yb + r1 * Sin(-21 * a) cn = r PSet (xd, yd), Plasma~& Next _Limit 60 _Display Next Loop Until _KeyDown(27)
Function Plasma~& () 'cN = cN + .2 Plasma~& = _RGB32(127 + 127 * Sin(pr * cn), 127 + 127 * Sin(pg * cn), 127 + 127 * Sin(pb * cn)) End Function
Sub resetPlasma () pr = Rnd ^ 2: pg = Rnd ^ 2: pb = Rnd ^ 2 End Sub
![](//storage.proboards.com/7292714/thumbnailer/DiAeKMJiTyQEDmQuRRRA.png)
|
|
|
Post by bplus on Nov 2, 2023 2:02:23 GMT
Decorated Skull Modified to work in QBJS as well: 'Option _Explicit _Title "Skull - ZXDunny to Ron to b+" ' bplus 2023-11-01 'Randomize Timer
' prep for QBJS Dim Shared CN, PR, PG, PB Dim As Long Xmax, Ymax, Cx, K, I, D, N, A, U, V, J, B1, B2, B3, B4 Dim t, z, x, y, e, r, f, g, l, h
Xmax = 480: Ymax = 480 Cx = Xmax / 2 Dim c As _Unsigned Long Screen _NewImage(Xmax, Ymax, 32) ' 320x 200 no graphics ??
K = 360 Dim Sine(K): Dim Cosi(K)
For I = 0 To K t = I * 2 * _Pi(1 / K) Sine(I) = Sin(t) Cosi(I) = Cos(t) Next I
Do Cls resetPlasma U = 120 ' orig V = -60: D = 2: N = 7: A = 70 c = _RGB32(255, 0, 0) ' eye coloring For J = 1 To 40 For t = 0 To K * 2 Step .25 z = A * Cosi(((t * N) \ D) Mod K) x = U + z * Cosi(t Mod K) y = V + z * Sine(t Mod K) e = x * x r = Sqr(e + y * y) f = y + K g = Sqr(e + f * f) l = y + 60 I = x - 120 h = Sqr(I * I + l * l) B1 = (g <= 220 Or r <= K) B2 = (r <= 380 Or r >= 480 Or Abs(x) >= 160 Or Abs(x Mod 32) <= 4 Or r Mod 48 <= 4) B3 = (J <= 1 Or h >= 90) B4 = (y < -300 Or y >= -160 Or -x * 2 - y <= 180) If B1 And B2 And B3 And B4 Then ' apply scaling and translation x = x / 2 y = Ymax - ((y / 2.2) + 130 * 2.2) PSet (Int(x + Cx), y), c PSet (Int(Cx - x), y), c End If Next t D = Rand&(3): N = Rand&(5) + 2: A = Rand&(80) + 50: U = Rand&(K): V = Rand&(940) - 520 c = _RGB32(0, 0, J * 5 + 55) c = Plasma~& Next J _Display _Limit .5 Loop Until InKey$ = "q"
Function Rand& (n) Rand& = Int(Rnd * n) + 1 End Function
Function Plasma~& () CN = CN + .2 'dim shared cN as _Integer64, pR as long, pG as long, pB as long Plasma~& = _RGB32(127 + 127 * Sin(PR * CN), 127 + 127 * Sin(PG * CN), 127 + 127 * Sin(PB * CN)) End Function
Sub resetPlasma () PR = Rnd ^ 2: PG = Rnd ^ 2: PB = Rnd ^ 2 End Sub
![](//storage.proboards.com/7292714/thumbnailer/yCPYpHJDjRWtcvmQxSgh.png) ![](//storage.proboards.com/7292714/thumbnailer/dmMyUGgUifCwLvDmAmvT.png)
|
|
|
Post by bplus on Nov 4, 2023 0:38:07 GMT
Circle Packing #4 NonCircles I just found this in my files: _Title "Circle Packing 4 nonCircles" 'B+ started 2019-04-08 Const xmax = 1200 Const ymax = 600 Screen _NewImage(xmax - 1, ymax - 1, 32) _ScreenMove _Middle spbg& = _NewImage(xmax - 1, ymax - 1, 32) _Dest spbg& Line (0, 0)-(xmax - 1, ymax - 1), _RGB32(0, 0, 0), BF cText xmax / 2, ymax / 2, 500, _RGB32(255, 255, 255), "QB64" _Source spbg& Type CircleType x As Integer y As Integer r As Integer n As Integer a As Single c As _Unsigned Long growing As Integer End Type ReDim Shared circles(0) As CircleType Dim Shared flagDone As Integer
While _KeyDown(27) = 0 And flagDone = 0 Cls count = count + 1 newCircle 20 drawCircles _Display _Limit 60 Wend Print "done"
Sub drawCircles For i = 1 To UBound(circles) If circles(i).growing Then 'check new r testr = circles(i).r + 1 If circles(i).x - testr < 0 Or circles(i).x + testr > xmax - 1 Or circles(i).y - testr < 0 Or circles(i).y + testr > ymax - 2 Then circles(i).growing = 0 Else 'check if run into another circle For j = 1 To UBound(circles) If j <> i Then If distLessCheck(circles(j).x, circles(i).x, circles(j).y, circles(i).y, testr + circles(j).r) Then 'IF SQR((circles(j).x - circles(i).x) ^ 2 + (circles(j).y - circles(i).y) ^ 2) <= testr + circles(j).r THEN circles(i).growing = 0: circles(j).growing = 0 Exit For End If End If Next End If End If If circles(i).growing Then circles(i).r = testr star circles(i).x, circles(i).y, .3 * circles(i).r, circles(i).r, circles(i).n, circles(i).a, circles(i).c Next Print UBound(circles) End Sub
Sub newCircle (n) For i = 1 To n attempts = 0 retry: testX = Int(Rnd * xmax): testY = Int(Rnd * ymax) OK = -1 If Point(testX, testY) = _RGB32(255, 255, 255) Then For j = 1 To UBound(circles) If distLessCheck(testX, circles(j).x, testY, circles(j).y, circles(j).r + 3) Then OK = 0: Exit For 'IF SQR((testX - circles(j).x) ^ 2 + (testY - circles(j).y) ^ 2) < circles(j).r + 3 THEN OK = 0: EXIT FOR Next If OK Then new = UBound(circles) + 1 ReDim _Preserve circles(1 To new) As CircleType circles(new).x = testX circles(new).y = testY circles(new).r = 3 circles(new).a = Rnd * _Pi(2) circles(new).n = 5 + Int(Rnd * 5) circles(new).growing = -1 circles(new).c = _RGB32(Rnd * 255 + 55, Rnd * 200 + 55, Rnd * 200 + 55) Else attempts = attempts + 1 If attempts > 3000 Then flagDone = -1: Exit Sub GoTo retry End If Else GoTo retry End If Next End Sub
Sub cText (x, y, textHeight, K As _Unsigned Long, txt$) fg = _DefaultColor 'screen snapshot cur& = _Dest I& = _NewImage(8 * Len(txt$), 16, 32) _Dest I& Color K, _RGBA32(0, 0, 0, 0) _PrintString (0, 0), txt$ mult = textHeight / 16 xlen = Len(txt$) * 8 * mult _PutImage (x - .5 * xlen, y - .5 * textHeight)-Step(xlen, textHeight), I&, cur& Color fg _FreeImage I& End Sub
Sub fIrrPoly (arr(), K As _Unsigned Long) 'this just draws a bunch of triangles according to x, y points in arr() ox = arr(0): oy = arr(1) 'the first 2 items in arr() need to be center For i = 2 To UBound(arr) - 3 Step 2 ftri ox, oy, arr(i), arr(i + 1), arr(i + 2), arr(i + 3), K Next End Sub
Sub star (x, y, rInner, rOuter, nPoints, angleOffset, K As _Unsigned Long) ' x, y are same as for circle, ' rInner is center circle radius ' rOuter is the outer most point of star ' nPoints is the number of points, ' angleOffset = angle offset in radians ' this is to allow us to spin the star
Dim ar(Int(nPoints) * 4 + 3) 'add two for origin pAngle = _Pi(2) / nPoints: radAngleOffset = angleOffset - _Pi(1 / 2) ar(0) = x: ar(1) = y ar(2) = x + rOuter * Cos(radAngleOffset) ar(3) = y + rOuter * Sin(radAngleOffset) idx = 4 For i = 0 To nPoints - 1 ar(idx) = x + rInner * Cos(i * pAngle + radAngleOffset + .5 * pAngle) idx = idx + 1 ar(idx) = y + rInner * Sin(i * pAngle + radAngleOffset + .5 * pAngle) idx = idx + 1 ar(idx) = x + rOuter * Cos((i + 1) * pAngle + radAngleOffset) idx = idx + 1 ar(idx) = y + rOuter * Sin((i + 1) * pAngle + radAngleOffset) idx = idx + 1 Next fIrrPoly ar(), K End Sub
Sub ftri (x1, y1, x2, y2, x3, y3, K As _Unsigned Long) a& = _NewImage(1, 1, 32) _Dest a& PSet (0, 0), K _Dest 0 _MapTriangle _Seamless(0, 0)-(0, 0)-(0, 0), a& To(x1, y1)-(x2, y2)-(x3, y3) _FreeImage a& '<<< this is important! End Sub
Function distLessCheck (x1, x2, y1, y2, checkThis) dx = x1 - x2: dy = y1 - y2 If dx * dx + dy * dy < checkThis * checkThis Then distLessCheck = -1 Else distLessCheck = 0 End Function
![](//storage.proboards.com/7292714/thumbnailer/tCnNVUBCyReoZJPDnZgg.png)
|
|
|
Post by bplus on Mar 17, 2024 19:03:50 GMT
Shamrocks! _Title "N Leafed Shamrocks, How many shamrocks until you get a 7 leafed one? by bplus 2018-03-09" ' Shamrock 2018-03-09 mod to lessons learned with JB version 2018-03-09 tsh tips ' from N Leafed Shamrocks 2018-03-08 ' Draw Angled Heart.bas SmallBASIC 0.12.11 (B+=MGA) 2018-03-07 Randomize Timer Const xmax = 1280 Const ymax = 740 Screen _NewImage(xmax, ymax, 32) _ScreenMove 70, 0 Dim counts(7) Cls , _RGB32(60, 30, 15) While nLeafs < 7 luck = Rnd Select Case luck Case Is < 1 / 625: nLeafs = 7 Case Is < 1 / 125: nLeafs = 6 Case Is < 1 / 25: nLeafs = 5 Case Is < 1 / 5: nLeafs = 4 Case Else: nLeafs = 3 End Select counts(nLeafs) = counts(nLeafs) + 1 counts(1) = counts(1) + 1 stat$ = Str$(counts(3)) For i = 4 To 7 stat$ = stat$ + " :" + Str$(counts(i)) Next stat$ = stat$ + " =" + Str$(counts(1)) _Title stat$ + " N Leafed Shamrocks, How many shamrocks until you get a 7 leafed one? (1 in 625 chance) by bplus 2018-03-09" cc1% = Rnd * 100 + 50 cc2% = Rnd * 100 + 50 While Abs(cc1% - cc2%) < 30 'for contrast of 2 colors cc2% = Rnd * 100 + 50 Wend xp = Rnd * (xmax - 100) + 50 yp = Rnd * (ymax - 100) + 50 size = Int(Rnd * 40) + 10 ang = Rnd * _Pi(2) Color _RGB32(0, cc1%, 0) drawShamrockN xp + 1, yp, size, ang, nLeafs, 1 Color _RGB32(0, cc2%, 0) For r = 1 To size Step 1 drawShamrockN xp, yp, r, ang, nLeafs, 0 Next _Display _Limit 10 Wend Sleep
'draws an arc with center at xCenter, yCenter, radius from center is arcRadius Sub myArc (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 / (.1 * arcRadius)) 'fixed For rAngle = rAngleStart To rAngleEnd Step Stepper If rAngle = rAngleStart Then lastX = xCenter + arcRadius * Cos(rAngle) lastY = yCenter + arcRadius * Sin(rAngle) Else nextX = xCenter + arcRadius * Cos(rAngle) If nextX <= lastX Then useX = nextX - 1 Else useX = nextX + 1 nextY = yCenter + arcRadius * Sin(rAngle) If nextY <= lastY Then useY = nextY - 1 Else useY = nextY + 1 Line (lastX, lastY)-(nextX, nextY) lastX = nextX lastY = nextY End If Next End Sub
Function RAD (a) RAD = _Pi(a / 180) End Function
Function DEG (a) DEG = a * 180 / _Pi End Function
Sub drawHeart (x, y, r, rl, a, solid) 'local x1, x2, x3, x4, x5, x6, y1, y2, y3, y4, y5, y6 'clockwise from due East, the V x1 = x + r * Cos(a) y1 = y + r * Sin(a) x2 = x + rl * Cos(a + _Pi / 2) y2 = y + rl * Sin(a + _Pi / 2) x3 = x + r * Cos(a + _Pi) y3 = y + r * Sin(a + _Pi) x4 = x + r * Cos(a + 3 * _Pi / 2) y4 = y + r * Sin(a + 3 * _Pi / 2) x5 = (x3 + x4) / 2 y5 = (y3 + y4) / 2 x6 = (x4 + x1) / 2 y6 = (y4 + y1) / 2 If solid Then filltri x1, y1, x2, y2, x3, y3 filltri x2, y2, x3, y3, x4, y4 fcirc x5, y5, .5 * r * 2 ^ .5 fcirc x6, y6, .5 * r * 2 ^ .5 Else Line (x1, y1)-(x2, y2) Line (x2, y2)-(x3, y3) 'left hump myArc x5, y5, .5 * r * 2 ^ .5, DEG(a) + 135, 180 'right hump myArc x6, y6, .5 * r * 2 ^ .5, DEG(a) + 225, 180 End If End Sub
Sub drawShamrockN (x, y, r, a, nLeafed, solid) bigR = 2.05 * r * nLeafed / (2 * _Pi) '<<<<<<<<<<<< EDIT for fuller leaves For leaf = 0 To nLeafed - 1 x1 = x + bigR * Cos(a + leaf * 2 * _Pi / nLeafed + 3 * _Pi / 2) y1 = y + bigR * Sin(a + leaf * 2 * _Pi / nLeafed + 3 * _Pi / 2) drawHeart x1, y1, r, bigR, a + leaf * 2 * _Pi / nLeafed, solid Next End Sub
'Steve McNeil's copied from his forum note: Radius is too common a name Sub fcirc (CX As Long, CY As Long, R As Long) Dim subRadius As Long, RadiusError As Long Dim X As Long, Y As Long
subRadius = Abs(R) RadiusError = -subRadius X = subRadius Y = 0
If subRadius = 0 Then PSet (CX, CY): Exit Sub
' 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), , 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), , BF Line (CX - Y, CY + X)-(CX + Y, CY + X), , BF End If X = X - 1 RadiusError = RadiusError - X * 2 End If Y = Y + 1 Line (CX - X, CY - Y)-(CX + X, CY - Y), , BF Line (CX - X, CY + Y)-(CX + X, CY + Y), , BF Wend End Sub
Sub filltri (xx1, yy1, xx2, yy2, xx3, yy3) 'make copies before swapping x1 = xx1: y1 = yy1: x2 = xx2: y2 = yy2: x3 = xx3: y3 = yy3 'thanks Andy Amaya! 'triangle coordinates must be ordered: where x1 < x2 < x3 If x2 < x1 Then Swap x1, x2: Swap y1, y2 If x3 < x1 Then Swap x1, x3: Swap y1, y3 If x3 < x2 Then Swap x2, x3: Swap y2, y3 If x1 <> x3 Then slope1 = (y3 - y1) / (x3 - x1)
'draw the first half of the triangle length = x2 - x1 If length <> 0 Then slope2 = (y2 - y1) / (x2 - x1) For x = 0 To length Line (Int(x + x1), Int(x * slope1 + y1))-(Int(x + x1), Int(x * slope2 + y1)) 'lastx2% = lastx% lastx% = Int(x + x1) Next End If
'draw the second half of the triangle y = length * slope1 + y1: length = x3 - x2 If length <> 0 Then slope3 = (y3 - y2) / (x3 - x2) For x = 0 To length 'IF INT(x + x2) <> lastx% AND INT(x + x2) <> lastx2% THEN 'works! but need 2nd? check If Int(x + x2) <> lastx% Then Line (Int(x + x2), Int(x * slope1 + y))-(Int(x + x2), Int(x * slope3 + y2)) End If Next End If End Sub
|
|
|
Post by bplus on Mar 24, 2024 23:28:19 GMT
Flower Wheel 2 _Title "Flower Wheel 2" ' b+ 2024-03-24 Screen _NewImage(700, 700, 32) _ScreenMove 300, 40 Do Cls o = o + _Pi / 180 drawc _Width / 2, _Height / 2, _Width / 4.1, .45, 4, o _Display _Limit 30 Loop
Sub drawc (x, y, r, a, n, o) If n > 0 Then For t = 0 To _Pi(2) Step _Pi(1 / 3) xx = x + r * Cos(t + o) yy = y + r * Sin(t + o) Circle (xx, yy), r, _RGB32(t * 40 - 60, t * 40 - 60, 128, n * 63) Circle (xx, yy), r - 1, _RGB32(t * 30 - 60, t * 30 - 60, 128, n * 63) Circle (xx, yy), r - 2, _RGB32(t * 30 - 60, t * 30 - 60, 128, n * 63) drawc xx, yy, a * r, a, n - 1, -1.5 * o - n * _Pi / 180 Next End If End Sub
![](//storage.proboards.com/7292714/thumbnailer/aUFM0sMaugsjeDfUCAQV.png)
|
|
|
Post by bplus on Mar 25, 2024 13:11:01 GMT
yes but not about graphics, i suck at 3d stuff and that's what i think the young'ins would prefer, no, i need another tantilizer more in line with my spirit. thanks for the reminder1
|
|
|
Post by bplus on Mar 26, 2024 18:26:24 GMT
Metatrons Cube _Title "Metatrons Cube" ' b+ 2024-03-25 Screen _NewImage(700, 700, 32) _ScreenMove 300, 40 cx = 350: cy = 350: r = 50 a = _Pi(2 / 6) Dim ix(5), iy(5), ox(5), oi(5) For i = 0 To 5 ix(i) = cx + 2 * r * Cos(a * i - _Pi / 2) iy(i) = cy + 2 * r * Sin(a * i - _Pi / 2) ox(i) = cx + 4 * r * Cos(a * i - _Pi / 2) oy(i) = cy + 4 * r * Sin(a * i - _Pi / 2) Next Circle (cx, cy), r For i = 0 To 5 Circle (ix(i), iy(i)), r For j = 0 To 5 Circle (ox(j), oy(j)), r If j <> i Then Line (ix(i), iy(i))-(ix(j), iy(j)) Line (ix(i), iy(i))-(ox(j), oy(j)) Line (ox(i), oy(i))-(ox(j), oy(j)) End If Next Next _Title "Metatrons Cube 2" ' b+ 2024-03-25 Screen _NewImage(700, 700, 32) _ScreenMove 300, 40 cx = 350: cy = 350: r = 20 a = _Pi(2 / 6) Dim ix(5), iy(5), ox(5), oi(5) For cr = r To 8 * r Step .1 Cls For i = 0 To 5 ix(i) = cx + 2 * r * Cos(a * i - _Pi / 2) iy(i) = cy + 2 * r * Sin(a * i - _Pi / 2) ox(i) = cx + 4 * r * Cos(a * i - _Pi / 2) oy(i) = cy + 4 * r * Sin(a * i - _Pi / 2) Next Circle (cx, cy), cr, &HFF0000FF Circle (cx, cy), cr - 1, &HFF0000FF Circle (cx, cy), cr - 2, &HFF0000FF For i = 0 To 5 Circle (ix(i), iy(i)), cr, &HFFFFFF00 Circle (ix(i), iy(i)), cr - 1, &HFFFFFF00 For j = 0 To 5 Circle (ox(j), oy(j)), cr, &HFFFF0000 If j <> i Then Line (ix(i), iy(i))-(ix(j), iy(j)) Line (ix(i), iy(i))-(ox(j), oy(j)) Line (ox(i), oy(i))-(ox(j), oy(j)) End If Next Next _Display _Limit 30 Next ![](//storage.proboards.com/7292714/thumbnailer/CPXGtpIXtjNHf0IjUgQs.png) ![](//storage.proboards.com/7292714/thumbnailer/t0mmhEkFLmNa0YRoLCsa.png)
|
|
druui
New Member
Posts: 1
|
Post by druui on Apr 26, 2024 14:22:56 GMT
awesome!
|
|
|
Post by bplus on May 11, 2024 18:24:10 GMT
Orbit Demo - Make Hairy Wreath _Title "orbit demo make hairy wreath " 'b+ 2024-05-11 Const Xmax = 700, Ymax = 700 Screen _NewImage(Xmax, Ymax, 32) _ScreenMove 290, 20 Randomize Timer x = _Width / 2: y = _Height / 2 ' start in center of screen pentAngle = 72 ' the angles inside a pentagram are 360 / 5 = 72 degrees forward = 10 angle = -36 stepper = 1 r = Rnd * Rnd: g = Rnd * Rnd: b = Rnd * Rnd: dc = 0 Do Until _KeyDown(27) orbit _Width / 2, _Height / 2, Rnd * 360, 200, x, y loops = loops + 1 Locate 1, 1: Print loops If loops = 10 Then Cls: loops = 0: r = Rnd * Rnd: g = Rnd * Rnd: b = Rnd * Rnd: dc = 0 While y > 0 And y < _Height orbit x, y, angle, forward, nextx, nexty Color _RGB32(127 + 127 * Sin(r * dc), 127 + 127 * Sin(g * dc), 127 + 127 * Sin(b * dc)) Line (x, y)-(nextx, nexty) forward = forward - stepper If forward < 0 Then forward = 20 orbit _Width / 2, _Height / 2, Rnd * 360, 200, nextx, nexty angle = Rnd * 360 pentAngle = Rnd * 90 If Rnd < .5 Then pentAngle = -pentAngle stepper = Rnd * 3 + .5 dc = dc + .00936 End If angle = angle + pentAngle ' the absolute angle from 0 degrees accumulates at every turn x = nextx: y = nexty ' restart where we left off _Limit 2000 Wend Loop ' !!!!!! featuring the use of this SUB routine !!!! Sub orbit (X_Origin, Y_Origin, Degrees, Radius, xOut, yOut) ' all default single should be ok xOut = X_Origin + Radius * Cos(_D2R(Degrees)) yOut = Y_Origin + Radius * Sin(_D2R(Degrees)) End Sub
![](//storage.proboards.com/7292714/thumbnailer/qUXzdYUsuOesuxzQwerz.png)
|
|
|
Post by bplus on Jun 14, 2024 2:02:54 GMT
Curlies Screen _NewImage(1200, 700, 12) _ScreenMove 40, 20 Color 15, 4 For j = 3.14 To 6.28 Step .0314 Cls: c = c + 1: Print c, "press any..." x = 600: x1 = x: y = 350: f = 0 For z = 1 To 200000 f = f + j: g = f * f * .25 x = x + Cos(g): x1 = x1 - Cos(g) y = y + Sin(g): p = z Mod 255 PSet (x, y), _RGB(p, p, p) PSet (x1, y), _RGB(p, p, p) Next Sleep Next
![](//storage.proboards.com/7292714/thumbnailer/vRaWX0FKkOswugoTfdRS.png)
|
|
|
Post by bplus on Jun 14, 2024 22:47:29 GMT
Star Vortex Warning: spinning flashing colors _Title "Star Vortex: key 3 to 9 for star points, spacebar for color change" ' Star Vortex.bas SmallBASIC 0.12.9 [B+=MGA] 2017-04-19 ' Inspired by Andy Amaya's recent Neon Vortex at SdlBasic
' ++++++++++++ Instructions ! +++++++++++++ ' Press Spacebar to change Plasma Coloring Setting ' Press Number keys 3 to 9 for that many pointed stars '+++++++++++++++++++++++++++++++++++++++++++++++++++++
Randomize Timer Const xmax = 500 Const ymax = 500 Const cx = xmax / 2 Const cy = ymax / 2 Dim Shared pR, pG, pB, pN
Screen _NewImage(xmax, ymax, 32) _ScreenMove 300, 20
nP = 5: ao = 0 resetPlasma While _KeyDown(27) = 0 k$ = InKey$ If Len(k$) = 1 Then If k$ = " " Then resetPlasma If Val(k$) > 2 And Val(k$) <= 9 Then nP = Val(k$) End If aoo = 0 For i = 170 To 10 Step -1 star cx, cy, i, 3 * i, nP, i + ao, setPlasma~& Next _Display ao = ao - 5 Wend
Sub star (x, y, rInner, rOuter, nPoints, angleOffset, K As _Unsigned Long) ' x, y are same as for circle, ' rInner is center circle radius ' rOuter is the outer most point of star ' nPoints is the number of points, ' angleOffset = angle offset IN DEGREES, it will be converted to radians in sub ' this is to allow us to spin the polygon of n sides Dim pAngle, radAngleOffset, x1, y1, x2, y2, x3, y3, i As Long
pAngle = _D2R(360 / nPoints): radAngleOffset = _D2R(angleOffset) x1 = x + rInner * Cos(radAngleOffset) y1 = y + rInner * Sin(radAngleOffset) For i = 0 To nPoints - 1 x2 = x + rOuter * Cos(i * pAngle + radAngleOffset + .5 * pAngle) y2 = y + rOuter * Sin(i * pAngle + radAngleOffset + .5 * pAngle) x3 = x + rInner * Cos((i + 1) * pAngle + radAngleOffset) y3 = y + rInner * Sin((i + 1) * pAngle + radAngleOffset) FillTriangle x1, y1, x2, y2, x3, y3, K 'triangles leaked Line (x1, y1)-(x2, y2), K Line (x2, y2)-(x3, y3), K Line (x3, y3)-(x1, y1), K x1 = x3: y1 = y3 Next Paint (x, y), K, K End Sub
Sub FillTriangle (x1, y1, x2, y2, x3, y3, K As _Unsigned Long) $Checking:Off Static a&, m As _MEM If a& = 0 Then a& = _NewImage(1, 1, 32): m = _MemImage(a&) _MemPut m, m.OFFSET, K _MapTriangle _Seamless(0, 0)-(0, 0)-(0, 0), a& To(x1, y1)-(x2, y2)-(x3, y3) $Checking:On End Sub
Sub resetPlasma 'all globals pR = Rnd ^ 2: pG = Rnd ^ 2: pB = Rnd ^ 2: pN = 0 End Sub
Function setPlasma~& () 'all globals pN = pN + 1 setPlasma~& = _RGB32(127 + 99 * Sin(pR * pN), 127 + 99 * Sin(pG * pN), 127 + 99 * Sin(pB * pN)) End Function
![](//storage.proboards.com/7292714/thumbnailer/NXjYzUAcXGm0UMVNUFEA.png)
|
|