• by userbinator on 3/28/2022, 4:07:04 AM

    There's an even simpler algorithm if you're fine with "close enough" circles: https://news.ycombinator.com/item?id=15266331

  • by watersb on 3/28/2022, 4:11:00 AM

    I love Yurichev's books on assembly language, and he gives them away (CC-BY-4.0).

    https://beginners.re/

  • by christkv on 3/28/2022, 3:16:48 AM

    You can always try Bresenham’s circle drawing algorithm.

  • by rep_lodsb on 3/28/2022, 3:08:36 PM

    With the error initialized to zero, this algorithm will always step immediately after drawing the first pixel, which will cause that pixel to "stick out".

      y += 1;          // y == 1
      err += 2*y + 1;  // err == 3
      x -= 1;          // x == radius-1
      err -= 2*x + 1;  // err == 2-(2*(radius-1))
    
    You could compare the absolute value of the new and old error, or start with err = -(radius-1) instead.

    And you don't need calculus to come up with the algorithm, just simple high school algebra: (x+1)² - x² = 2x + 1.

  • by dahfizz on 3/28/2022, 2:53:34 AM

    > It requires only additions, subtractions and bit shifts: 2x is the same as x<<1, of course. It also requires only integer arithmetic.

    Does any of this mean anything in JS, where AFAIK there are no real ints? 2x is an fpu operation under the hood, and not a bit shift.

  • by dark-star on 3/28/2022, 11:46:46 AM

    This is how we did it on the C64, back in the 80's :-D