Created
March 24, 2021 01:52
-
-
Save primaryobjects/a7caf148ea341ef49adf0779cd59e633 to your computer and use it in GitHub Desktop.
Algorithm to draw a circle.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* draw_circle xc, yc, r is | |
* | |
* d := r/2 | |
* | |
* x := r | |
* | |
* y := 0 | |
* | |
* | |
* | |
* while x >= y loop | |
* | |
* plot xc + x, yc + y | |
* | |
* plot xc - x, yc + y | |
* | |
* plot xc + x, yc - y | |
* | |
* plot xc - x, yc - y | |
* | |
* plot xc + y, yc + x | |
* | |
* plot xc - y, yc + x | |
* | |
* plot xc + y, yc - x | |
* | |
* plot xc - y, yc - x | |
* | |
* | |
* | |
* y := y + 1 | |
* | |
* d := d - y | |
* | |
* if d < 0 then | |
* | |
* x := x - 1 | |
* | |
* d := d + x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment