Τετάρτη 22 Ιουλίου 2026

Super Ellipse Plot

https://rosettacode.org/wiki/Superellipse#M2000_Interpreter

You can use: Font "Courier New": Window Mode, 12000, 10000;  for the exact output as in the rosettacode.org example.


Module Checkit {
Module Superellipse (a As Long, b As Long, n As Double) {
Const m_x = scale.x div 2
Const m_y = scale.y div 2
' myStep *2 because we set line Width 2 pixels
    Long x, m, myStep=twipsX*2, top=a div myStep
Dim y(0 to top) as long

    y(0) = b ' value for x = 0
    y(top) = 0 ' value for x = a
    ' 0,0 is in upper left corner

    Move m_x, m_y - y(0) ' set starting point
Pen #FFBBCC {
Width 2 {
For x = 1 To a-1 Step myStep
        y(m) = Int( Exp( Ln(1 - ((x / a) ^ n)) / n ) * b )
        draw to m_x + x, m_y - y(m):m++
    Next
    For x = a To 0 Step myStep
        draw to m_x + x, m_y + y(m):m--
    Next
    For x = 0 To a Step myStep
        m++:draw to m_x - x, m_y + y(m)
    Next
    For x = a To 0 Step myStep
        draw to m_x - x, m_y - y(m):m--
    Next
    }
    }
}
Cls #003300, 0
Pen #ccffdd


VirtualScreenWidth=800
VirtualScreenHeight=800
VirtualEllipseSemiHeight=150
VirtualEllipseSemiDiameter=200

Long a=VirtualEllipseSemiDiameter/VirtualScreenWidth*scale.x
Long b=VirtualEllipseSemiDiameter/VirtualScreenHeight*scale.y
Double n = 2.5
Refresh 2000 ' draw without refreshing the screen
Superellipse a, b, n
Refresh 25 ' final refresh
Cursor 0, height-1
Print Over $(6),"hit any key to end program"
Push Key$:Drop
Cls
}
Checkit


Δεν υπάρχουν σχόλια:

Δημοσίευση σχολίου

You can feel free to write any suggestion, or idea on the subject.