|
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
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
|
|
|
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
|
|
|
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
|
|
|
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
|
|
|
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
|
|
|
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
|
|
|
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
|
|
|
Post by anthonyrbrown on Mar 25, 2024 9:35:50 GMT
Very nice Graphics bplus Have you ever thought about writing a book on it? A.R.B
|
|
|
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
|
|
druui
New Member
Posts: 1
|
Post by druui on Apr 26, 2024 14:22:56 GMT
awesome!
|
|