Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Ellipse trouble
#9
Well the ellipse formula works easily, so I copied and pasted it and ended up making a cat face out of all ellipses.   

Code: (Select All)
'ellipse


Randomize Timer

Dim scx, scy As Integer



scx = 800
scy = 600

Screen _NewImage(scx, scy, 32)


Const PI = 3.141592654#

Dim c0(100) As Long

Dim x, h, r
Dim xx, yy, x1, y1
Dim a, b, c, d, y, xx1, xx2, cc


c0(0) = _RGB(0, 0, 0) 'black
c0(1) = _RGB(255, 255, 255) 'white
c0(2) = _RGB(255, 0, 0) 'red
c0(3) = _RGB(0, 255, 0) 'green
c0(4) = _RGB(0, 0, 255) 'blue
c0(5) = _RGB(115, 135, 0) 'yellow
c0(6) = _RGB(0, 255, 255) 'cyan
c0(7) = _RGB(85, 50, 50) 'magenta
c0(8) = _RGB(200, 150, 150)
c0(9) = _RGB(0, 125, 125)
c0(10) = _RGB(185, 185, 185)
c0(11) = _RGB(55, 255, 55)
c0(12) = _RGB(55, 55, 55)
c0(13) = _RGB(44, 44, 44)
c0(14) = _RGB(66, 66, 66)


Cls


'A = (Sin(x * (PI / 180)))
'B = (Cos(x * (PI / 180)))
'C = (Tan(x * (PI / 180)))






Cls



'ear left
a = 50
b = 120
yy = 210
mm = 260
For j = 0 To b
    y = b - j
    x = Sqr((1 - y ^ 2 / b ^ 2) * a ^ 2)
    Line (mm - x, yy - y)-(mm + x, yy - y), c0(13)
    Line (mm - x, yy + y)-(mm + x, yy + y), c0(13)
Next j

'ear right
a = 50
b = 120
yy = 210
mm = 540
For j = 0 To b
    y = b - j
    x = Sqr((1 - y ^ 2 / b ^ 2) * a ^ 2)
    Line (mm - x, yy - y)-(mm + x, yy - y), c0(13)
    Line (mm - x, yy + y)-(mm + x, yy + y), c0(13)
Next j


'ear left inner
a = 40
b = 110
yy = 210
mm = 260
For j = 0 To b
    y = b - j
    x = Sqr((1 - y ^ 2 / b ^ 2) * a ^ 2)
    Line (mm - x, yy - y)-(mm + x, yy - y), c0(14)
    Line (mm - x, yy + y)-(mm + x, yy + y), c0(14)
Next j

'ear right inner
a = 40
b = 110
yy = 210
mm = 540
For j = 0 To b
    y = b - j
    x = Sqr((1 - y ^ 2 / b ^ 2) * a ^ 2)
    Line (mm - x, yy - y)-(mm + x, yy - y), c0(14)
    Line (mm - x, yy + y)-(mm + x, yy + y), c0(14)
Next j





'face

xx = scx / 2
yy = 300

a = 200
b = 140

For j = 0 To b
    y = b - j
    x = Sqr((1 - y ^ 2 / b ^ 2) * a ^ 2)
    Line (xx - x, yy - y)-(xx + x, yy - y), c0(12)
    Line (xx - x, yy + y)-(xx + x, yy + y), c0(12)
Next j





'chin
a = 40
b = 30
yy = 390

For j = 0 To b
    y = b - j
    x = Sqr((1 - y ^ 2 / b ^ 2) * a ^ 2)
    Line (xx - x, yy - y)-(xx + x, yy - y), c0(13)
    Line (xx - x, yy + y)-(xx + x, yy + y), c0(13)
Next j


'mouth left
a = 40
b = 30
yy = 370
mm = 360
For j = 0 To b
    y = b - j
    x = Sqr((1 - y ^ 2 / b ^ 2) * a ^ 2)
    Line (mm - x, yy - y)-(mm + x, yy - y), c0(14)
    Line (mm - x, yy + y)-(mm + x, yy + y), c0(14)
Next j

'mouth right
a = 40
b = 30
yy = 370
mm = 440
For j = 0 To b
    y = b - j
    x = Sqr((1 - y ^ 2 / b ^ 2) * a ^ 2)
    Line (mm - x, yy - y)-(mm + x, yy - y), c0(14)
    Line (mm - x, yy + y)-(mm + x, yy + y), c0(14)
Next j



'upper nose
a = 30
b = 35
yy = 333

For j = 0 To b
    y = b - j
    x = Sqr((1 - y ^ 2 / b ^ 2) * a ^ 2)
    Line (xx - x, yy - y)-(xx + x, yy - y), c0(13)
    Line (xx - x, yy + y)-(xx + x, yy + y), c0(13)
Next j



'nose
a = 30
b = 10
yy = 350

For j = 0 To b
    y = b - j
    x = Sqr((1 - y ^ 2 / b ^ 2) * a ^ 2)
    Line (xx - x, yy - y)-(xx + x, yy - y), c0(7)
    Line (xx - x, yy + y)-(xx + x, yy + y), c0(7)
Next j


'nose
a = 15
b = 10
yy = 360

For j = 0 To b
    y = b - j
    x = Sqr((1 - y ^ 2 / b ^ 2) * a ^ 2)
    Line (xx - x, yy - y)-(xx + x, yy - y), c0(7)
    Line (xx - x, yy + y)-(xx + x, yy + y), c0(7)
Next j





'==================================================================

'==================================================================

'==================================================================

'==================================================================

'==================================================================

'==================================================================



'animate blinking


a = 50 'eye white width
b = 25 'eye white height
c = 25 'eye colour height
d = 7 'eye colour width


xx1 = 300
yy1 = 280

xx2 = 500
yy2 = 120


cc = 13

Dim v, v2, v3, v4 As Long




Do


    'blink down
    For j = 0 To b
        y = b - j
        x = Sqr((1 - y ^ 2 / b ^ 2) * a ^ 2)
        Line (xx1 - x, yy1 - y)-(xx1 + x, yy1 - y), c0(cc)
        Line (xx1 - x, yy1 + y)-(xx1 + x, yy1 + y), c0(cc)
        Line (xx2 - x, yy1 - y)-(xx2 + x, yy1 - y), c0(cc)
        Line (xx2 - x, yy1 + y)-(xx2 + x, yy1 + y), c0(cc)
        For jj = 1 To 100000
        Next jj
    Next j

    For jj = 1 To 1000000
        For jjj = 1 To 30
        Next jjj
    Next jj



    'open eyes
    For j = b To 0 Step -1
        y = b - j
        x = Sqr((1 - y ^ 2 / b ^ 2) * a ^ 2)
        Line (xx1 - x, yy1 - y)-(xx1 + x, yy1 - y), c0(5)
        Line (xx1 - x, yy1 + y)-(xx1 + x, yy1 + y), c0(5)
        Line (xx2 - x, yy1 - y)-(xx2 + x, yy1 - y), c0(5)
        Line (xx2 - x, yy1 + y)-(xx2 + x, yy1 + y), c0(5)
        yc = b - j
        x = Sqr((1 - yc ^ 2 / c ^ 2) * d ^ 2)
        Line (xx1 - x, yy1 - yc)-(xx1 + x, yy1 - yc), c0(0)
        Line (xx1 - x, yy1 + yc)-(xx1 + x, yy1 + yc), c0(0)
        Line (xx2 - x, yy1 - yc)-(xx2 + x, yy1 - yc), c0(0)
        Line (xx2 - x, yy1 + yc)-(xx2 + x, yy1 + yc), c0(0)
        For jj = 1 To 200000
        Next jj
    Next j


    v = (Rnd * 10) + .2
    _Delay v
Loop







End
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: 2 Guest(s)