Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ellpise routine
#11
Adosorken: Yeah its big but its all integer so its good Smile. I could make a 10 line one with sine / cosine but that would lose pixel quality. I checked back on rel's sources from where he got it from and downloaded all the abc packers (oh my gosh allbasiccode.com is such a horrible site. the admin should buy knives and stab it in their own head 3 times) and got the original algorithm (has no goto's Wink):
Code:
'Calling parameters:
'ox, oy   = origin
'prx      = X radius
'pry      = Y radius
'co       = color
SUB DrawEllipse (ox, oy, prx, pry, co)
  DIM xe AS LONG, ye AS LONG, e AS LONG
  IF pry = 0 THEN 'special cases for horizontal & vertical ellipses
    LINE (ox - prx, oy)-(ox + prx, oy), co
    EXIT SUB
  END IF
  IF prx = 0 THEN
    LINE (ox, oy - pry)-(ox, oy + pry), co
    EXIT SUB
  END IF
  'work with largest axis to avoid rounding errors
  IF pry <= prx THEN
    x = 0: y = pry
    xe = 0: ye = CLNG(prx) * prx
    e = -ye \ 2: c = ye \ pry
    DO
      IF e <= 0 THEN
        DO
          PSET (ox + x, oy + y), co: PSET (ox - x, oy + y), co
          PSET (ox + x, oy - y), co: PSET (ox - x, oy - y), co
          x = x + 1
          xe = xe + pry
          e = e + xe
        LOOP WHILE e <= 0
      ELSE
        PSET (ox + x, oy + y), co: PSET (ox - x, oy + y), co
        PSET (ox + x, oy - y), co: PSET (ox - x, oy - y), co
      END IF
      y = y - 1
      ye = ye - c
      e = e - ye
    LOOP UNTIL y = 0
    PSET (ox + x, oy), co: PSET (ox - x, oy), co
    PSET (ox + x, oy), co: PSET (ox - x, oy), co
  ELSE
    x = 0: y = prx
    xe = 0: ye = CLNG(pry) * pry
    e = -ye \ 2: c = ye \ prx
    DO
      IF e <= 0 THEN
        DO
          PSET (ox + y, oy + x), co: PSET (ox - y, oy + x), co
          PSET (ox + y, oy - x), co: PSET (ox - y, oy - x), co
          x = x + 1
          xe = xe + prx
          e = e + xe
        LOOP WHILE e <= 0
      ELSE
        PSET (ox + y, oy + x), co: PSET (ox - y, oy + x), co
        PSET (ox + y, oy - x), co: PSET (ox - y, oy - x), co
      END IF
      y = y - 1
      ye = ye - c
      e = e - ye
    LOOP UNTIL y = 0
    PSET (ox, oy + x), co: PSET (ox, oy + x), co
    PSET (ox, oy - x), co: PSET (ox, oy - x), co
  END IF
END SUB

na_th_an: Sure ill wait for sources.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)