Ellipse trouble
#8
Here is tilted ellipsii with some fun coloring:
Code: (Select All)
Screen _NewImage(800, 600, 32)
_ScreenMove 250, 50
Dim Shared pR, pG, pB, pA, cN

Do
    lc = lc + 1
    If lc = 100 Then Cls: lc = 0
    resetPlasma
    cx = Rnd * _Width: cy = Rnd * _Height: a = Rnd * 100: b = Rnd * 100: ang = _Pi(Rnd * 2)
    For i = 0 To 1 Step .0005
        EllipseTilt cx, cy, i * a, i * b, ang, Plasma~&
    Next
    _Limit 30
Loop Until _KeyDown(27)


Function Plasma~& () ' this creates a wonderful sequence of colors  cN, pR, pG, pB are Shared
    cN = cN + .1 ' might want to keep cN single and increment by .5, .1.. depending on needs
    Plasma~& = _RGB32(127 + 127 * Sin(pR * cN), 127 + 127 * Sin(pG * cN), 127 + 127 * Sin(pB * cN), 3)
End Function

Sub resetPlasma ' this sets up to use changePlasma pR, pG, pB are Shared
    pR = Rnd ^ 2: pG = Rnd ^ 2: pB = Rnd ^ 2: pA = Rnd * 100: cN = 0
End Sub


'=========================================================================================================== drawing
'thanks STxAxTIC from Toolbox
Sub EllipseTilt (CX, CY, a, b, ang, C As _Unsigned Long)
    Dim k, i, j
    '  CX = center x coordinate
    '  CY = center y coordinate
    '   a = semimajor axis  major radius
    '   b = semiminor axis  minor radius
    ' ang = clockwise orientation of semimajor axis in radians (0 default)
    '   C = fill color
    For k = 0 To 6.283185307179586 Step .025 'not sure about the stepper it should depend on a and b
        i = a * Cos(k) * Cos(ang) + b * Sin(k) * Sin(ang)
        j = -a * Cos(k) * Sin(ang) + b * Sin(k) * Cos(ang)
        i = i + CX
        j = -j + CY
        If k <> 0 Then
            Line -(i, j), C
        Else
            PSet (i, j), C
        End If
    Next
End Sub

Hmm... looks like imperfect overlap occasionally.

Update: Overlap problem fixed, I think.
b = b + ...
Reply


Messages In This Thread
Ellipse trouble - by james2464 - 08-23-2022, 03:29 PM
RE: Ellipse trouble - by dcromley - 08-23-2022, 04:07 PM
RE: Ellipse trouble - by james2464 - 08-23-2022, 06:37 PM
RE: Ellipse trouble - by bplus - 08-23-2022, 04:54 PM
RE: Ellipse trouble - by james2464 - 08-23-2022, 06:43 PM
RE: Ellipse trouble - by James D Jarvis - 08-23-2022, 05:37 PM
RE: Ellipse trouble - by james2464 - 08-23-2022, 06:48 PM
RE: Ellipse trouble - by bplus - 08-23-2022, 08:51 PM
RE: Ellipse trouble - by james2464 - 08-23-2022, 11:33 PM
RE: Ellipse trouble - by Pete - 08-24-2022, 12:47 AM
RE: Ellipse trouble - by james2464 - 08-24-2022, 01:59 PM
RE: Ellipse trouble - by Pete - 08-25-2022, 02:23 AM
RE: Ellipse trouble - by james2464 - 08-25-2022, 11:38 AM
RE: Ellipse trouble - by Pete - 08-25-2022, 08:58 PM
RE: Ellipse trouble - by james2464 - 08-25-2022, 10:52 PM



Users browsing this thread: 6 Guest(s)