Lazyoval
#1
Ovals, well... lazy ovals.   


Code: (Select All)
'LazyOval
'this could be better... probably have rotozoom built in too

'demo
Screen _NewImage(800, 500, 32)
k& = _RGB32(200, 100, 50)

lazyoval 200, 200, 50, 30, k&


For h = 1 To 60
    _Limit 60
    Cls
    lazyoval 100, 100, h, 60, k&
    Circle (100, 100), 60, _RGB32(250, 250, 250)
    _Display
Next h
For h = 60 To 1 Step -1
    _Limit 30
    Cls
    lazyoval 100, 100, 60, h, k&
    Circle (100, 100), 60, _RGB32(250, 250, 250)
    _Display
Next h

For h = 1 To 60
    _Limit 60
    Cls
    lazyoval 100, 100, h, 60, k&
    _Display
Next h
For h = 60 To 1 Step -1
    _Limit 30
    Cls
    lazyoval 100, 100, 60, h, k&
    _Display
Next h
Cls
lazyoval 100, 100, 24, 80, k&
_PrintMode _KeepBackground
_PrintString (70, 92), "Lazyoval"
_Display

'the actual routine
Sub lazyoval (xx, yy, hh, ww, K As _Unsigned Long)
    'create a lazyoval by changing the ratio of a circle with the putimage command
    rr = hh
    If ww > rr Then rr = ww
    oo& = _NewImage(rr * 2 + 2, rr * 2 + 2, 32)
    _Dest oo&
    cx = rr
    cy = cx
    Circle (cx, cy), rr, K
    Paint (cx, cy), K, K
    x1 = xx - ww: x2 = xx + ww
    y1 = yy - hh: y2 = yy + hh
    _Dest 0
    _PutImage (x1, y1)-(x2, y2), oo&, 0, (0, 0)-(rr * 2, rr * 2)

    _FreeImage oo& 'don't delete this
End Sub
Reply
#2
That's pretty neat James, a lot more math than I know how to do. Usually when I want an oval, I use the CIRCLE command's number on the very end. It changes it from a circle, which is 1, to different shapes of the oval lesser or more than 1. Here is an example I just threw together for you: 

Code: (Select All)
Screen _NewImage(800, 600, 32)
oval = 1.9
dir = 1
_Title "Changing Coin - Press Esc to End"
Do
    _Limit 20
    For sz = .25 To 100 Step .25
        c = c + .25
        Circle (400, 300), sz, _RGB32(100 + c, 100 + c, 100 + c), , , oval
    Next sz
    c = 0
    If oval < .05 Then dir = 1
    If oval > 4.95 Then dir = 2
    If dir = 2 Then oval = oval - .05
    If dir = 1 Then oval = oval + .05
    _Display
    Cls
Loop Until InKey$ = Chr$(27)
Reply
#3
Decent, but ick...math. Joking of course, my track in college was "Applied Mathematics/Computer Science", I've forgotten more maths than most folk ever learned. Every now and again it's fun to develop a snippet of code that just "brute-forces" a simple solution.
Reply
#4
LOL cool Smile
Reply




Users browsing this thread: 1 Guest(s)