News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Beautiful Lissajous Curve

Started by six_L, October 21, 2024, 01:18:01 PM

Previous topic - Next topic

six_L

Hi,All

Core code:
GenerateAlgoCurve proc uses rbx @@pGraphics:QWORD
    LOCAL Fmin:REAL10
    LOCAL Fmax:REAL10
    local aa:REAL10
    local bb:REAL10
    local theta:REAL10
    local x00:REAL4
    local y00:REAL4
    local x11:REAL4
    local y11:REAL4
    local @Pen:QWORD
    local xPhase:REAL10
    local nn:REAL10

    ;Lissajous Curve
    ;x(@)=a.sin(@)
    ;y(@)=b.sin(n.@+0)    n >= 1 ,(3.14/2) >= 0 >= O
    ;n: Multiple of frequency
       
    finit
   
    fld    FP10(1.0)   
    fstp    Fmin
    fld    FP10(2.0)   
    fstp    Fmax
    invoke  randf,addr Fmax,addr Fmin       
    fstp    nn

    fldz
    fstp    Fmin
    fldpi            ; 3.14
    fld    FP10(2.0)
    fdiv            ; 3.14/2
    fstp    Fmax
    invoke  randf,addr Fmax,addr Fmin        ;st0=[@Fmin,@Fmax)
    fstp    xPhase

   
    fldz
    fstp    theta

    fld    FP10(295.11)    ;a=width
    fstp    aa

    fld    FP10(240.07)    ;b=height
    fstp    bb

    invoke    GdipCreatePen1,0FF00FF00H,FP4(0.5),0,addr @Pen    ;FP4(0.5) pen width,
    xor    rbx,rbx
    .repeat
        fld    theta
        fldpi            ; 3.14
        fmul            ; theta*3.14
        fld    FP10(180.0)
        fdiv
        fsin            ; sin(theta*3.14/180)
        fld    aa
        fmul            ; a*sin(theta*3.14/180)
        fstp    x11
       
        fld    theta
        fldpi            ; 3.14
        fmul            ; theta*3.14/180
        fld    FP10(180.0)
        fdiv
        fld    nn
        fmul            ; n*(theta*3.14/180)
        fld    xPhase
        fadd            ; n*(theta*3.14/180)+xPhase
       
        fsin            ; sin(n*(theta*3.14/180)+xPhase)
        fld    bb
        fmul            ; b*sin(n*(theta*3.14/180)+xPhase)
        fstp    y11
       
        ;move to the center
        fld    FP10(420.5)
        fld    x11
        fadd
        fstp    x00
       
        fld    FP10(310.5)
        fld    y11
        fadd
        fstp    y00
       
        invoke    GdipDrawEllipse,@@pGraphics,@Pen,x00,y00,FP4(2.1),FP4(2.1)
       
        fld    FP10(0.908)        ;step of theta
        fld    theta
        fadd
        fstp    theta

        inc    rbx
    .until rbx == 6000
    invoke    GdipDeletePen,@Pen
    ret

GenerateAlgoCurve endp

the attachment is exe and screenshot.

Say you, Say me, Say the codes together for ever.

fearless

Nice. I had the thought that something like that could be used for a visualizer for music for my media player for example.

TimoVJL

Nice, good for those making rings
May the source be with you