Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- . Circles 2 Release
- . by EtzGamer (2016)
- .
- . To use this API in any other programs, APIs, OSes,
- . you are required to give visually visible credits
- . in your program/ OS that is accessible by the users
- . or within the first 20 lines of your API code,
- . clearly visible by those viewing the code.
- .
- . Variable Ref:
- . aC = Alpha Calibrated
- . c = Color
- . cN = Color toNumber(ed)
- . x = Center X
- . y = Center Y
- . dX = Delta X
- . dXF = Delta X Floor(ed)
- . dY = Delta Y
- . dYF = Delta X Floor(ed)
- . oC = Outline Color
- . oCN = Outline Color toNumber(ed)
- --]]
- local version = "2.0.3r"
- if not (term.isColor) then
- error("Circles requires advanced computer.")
- end
- function version()
- return version
- end
- function drawCircle(r, x, y, c)
- if (r == nil) or (x == nil) or (y == nil) then
- error("Some params are empty")
- end
- local dX, dY, dYC = 0, 0, 0
- local cN = tonumber(c)
- while dY <= dX do
- dX = math.sqrt(r * r - dY * dY)
- dYC = dY / 1.5
- paintutils.drawPixel(x + dX, y - dYC, cN)
- paintutils.drawPixel(x + dX, y + dYC, cN)
- paintutils.drawPixel(x - dX, y - dYC, cN)
- paintutils.drawPixel(x - dX, y + dYC, cN)
- dY = dY + 1
- end
- dX, dY = 0, 0
- while dX <= dY do
- dY = math.sqrt(r * r - dX * dX)
- dYC = dY / 1.5
- paintutils.drawPixel(x + dX, y - dYC, cN)
- paintutils.drawPixel(x + dX, y + dYC, cN)
- paintutils.drawPixel(x - dX, y - dYC, cN)
- paintutils.drawPixel(x - dX, y + dYC, cN)
- dX = dX + 1
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement